Skip to content

Replace deprecated AT_ERROR and AT_ASSERT macros#3979

Open
cyyever wants to merge 3 commits into
intel:mainfrom
cyyever:agent/replace-deprecated-error-macros
Open

Replace deprecated AT_ERROR and AT_ASSERT macros#3979
cyyever wants to merge 3 commits into
intel:mainfrom
cyyever:agent/replace-deprecated-error-macros

Conversation

@cyyever

@cyyever cyyever commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

Replaces all remaining uses of the deprecated AT_ERROR and AT_ASSERT macros (deprecated upstream in c10/util/Exception.h, see pytorch/pytorch#20287):

  • AT_ERROR(...) -> TORCH_CHECK(false, ...) (4 sites)
  • AT_ASSERT(...) -> TORCH_INTERNAL_ASSERT(...), or TORCH_CHECK in Copy.cpp to match upstream Copy.cu (9 sites)

Each site was checked against its upstream CUDA counterpart; where upstream has already modernized (Copy.cu, MaxUnpooling.cu, SummaryOps.cu, mkl SpectralOps.cpp) the replacement matches it exactly. Where upstream still uses AT_ASSERT (Reduce.cuh, EmbeddingBag.cu, ReduceOps.cpp, AdaptiveAveragePooling.cu, SparseCUDATensorMath.cu), the documented replacement TORCH_INTERNAL_ASSERT is used instead of copying the deprecated macro; semantics are identical.

Intentional divergences from upstream, beyond the macro rename:

  • Dropped TORCH_INTERNAL_ASSERT(grad_input_values.is_xpu()) in SparseTensorMathKernels.cpp: trivially true, the tensor is created two lines above with XPU options.
  • Dropped TORCH_INTERNAL_ASSERT(input_width > 0 && output_width > 0) in UpSampleLinear1dKernels.cpp: already enforced by the structured op meta check (upsample_1d_common_check).
  • Folded if (cond) { TORCH_CHECK(false, ...) } into single TORCH_CHECK(!cond, ...) calls in SummaryOpsKernels.cpp and MaxUnpoolingKernels.cpp; messages unchanged.

Error messages and failure behavior are unchanged at every site.

Test: none (mechanical macro replacement; no behavior change)

Authored with an AI assistant.

AT_ERROR becomes TORCH_CHECK(false, ...) and AT_ASSERT becomes
TORCH_INTERNAL_ASSERT (or TORCH_CHECK where the upstream CUDA
counterpart uses it), matching upstream where it has already
modernized. Error messages and failure behavior are unchanged.

Also drops two asserts that are trivially true at their call sites
and folds two if + TORCH_CHECK(false, ...) blocks into single
TORCH_CHECK(cond, ...) calls.

Test: none (mechanical macro replacement; no behavior change)

Authored with an AI assistant.

@guangyey guangyey left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants