Skip to content

Migrate check_op_args.h validations to meta kernels and remove it (#19207)#19207

Open
mcremon-meta wants to merge 1 commit intomainfrom
export-D102624163
Open

Migrate check_op_args.h validations to meta kernels and remove it (#19207)#19207
mcremon-meta wants to merge 1 commit intomainfrom
export-D102624163

Conversation

@mcremon-meta
Copy link
Copy Markdown
Contributor

@mcremon-meta mcremon-meta commented Apr 29, 2026

Summary:

Move operator argument validation from runtime C++ checks (check_op_args.h) to
AOT meta kernels (ops_registrations.py), enabling compile-time error detection
and reducing on-device binary size.

  • Delete check_op_args.h (~3,244 lines) and check_macros.h (~175 lines)
  • Add torch._check() validation to ~50 meta kernels in ops_registrations.py
    covering dtype, dimension, shape, and scalar parameter constraints
  • Inline the 4 data-dependent runtime checks (division-by-zero, attention_mask
    bounds) directly into kernel implementations across generic, HiFi, and G3
    backends
  • Remove codegen wrapper generation from codegen.py (generate_wrapper_code,
    insert_runtime_context, etc.) since checks no longer need wrapper functions
  • Update ops.bzl to remove wrapper.cpp references and wrapper library creation
  • Update targets.bzl to remove deleted header references

Reviewed By: abeakkas

Differential Revision: D102624163

@pytorch-bot
Copy link
Copy Markdown

pytorch-bot Bot commented Apr 29, 2026

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/19207

Note: Links to docs will display an error until the docs builds have been completed.

❗ 1 Active SEVs

There are 1 currently active SEVs. If your PR is affected, please view them below:

❌ 1 New Failure, 2 Unrelated Failures

As of commit f639c2d with merge base d767516 (image):

NEW FAILURE - The following job has failed:

BROKEN TRUNK - The following jobs failed but were present on the merge base:

👉 Rebase onto the `viable/strict` branch to avoid these failures

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Apr 29, 2026
@meta-codesync
Copy link
Copy Markdown
Contributor

meta-codesync Bot commented Apr 29, 2026

@mcremon-meta has exported this pull request. If you are a Meta employee, you can view the originating Diff in D102624163.

@github-actions
Copy link
Copy Markdown

This PR needs a release notes: label

If your change should be included in the release notes (i.e. would users of this library care about this change?), please use a label starting with release notes:. This helps us keep track and include your important work in the next release notes.

To add a label, you can comment to pytorchbot, for example
@pytorchbot label "release notes: none"

For more information, see
https://github.com/pytorch/pytorch/wiki/PyTorch-AutoLabel-Bot#why-categorize-for-release-notes-and-how-does-it-work.

@meta-codesync meta-codesync Bot changed the title Migrate check_op_args.h validations to meta kernels and remove it Migrate check_op_args.h validations to meta kernels and remove it (#19207) Apr 29, 2026
@meta-codesync meta-codesync Bot force-pushed the export-D102624163 branch from 533254a to 3dccdc2 Compare April 29, 2026 18:05
meta-codesync Bot pushed a commit that referenced this pull request Apr 29, 2026
…9207)

Summary:

Move operator argument validation from runtime C++ checks (check_op_args.h) to
AOT meta kernels (ops_registrations.py), enabling compile-time error detection
and reducing on-device binary size.

- Delete check_op_args.h (~3,244 lines) and check_macros.h (~175 lines)
- Add torch._check() validation to ~50 meta kernels in ops_registrations.py
  covering dtype, dimension, shape, and scalar parameter constraints
- Inline the 4 data-dependent runtime checks (division-by-zero, attention_mask
  bounds) directly into kernel implementations across generic, HiFi, and G3
  backends
- Remove codegen wrapper generation from codegen.py (generate_wrapper_code,
  insert_runtime_context, etc.) since checks no longer need wrapper functions
- Update ops.bzl to remove wrapper.cpp references and wrapper library creation
- Update targets.bzl to remove deleted header references

Reviewed By: abeakkas

Differential Revision: D102624163
…9207)

Summary:

Move operator argument validation from runtime C++ checks (check_op_args.h) to
AOT meta kernels (ops_registrations.py), enabling compile-time error detection
and reducing on-device binary size.

- Delete check_op_args.h (~3,244 lines) and check_macros.h (~175 lines)
- Add torch._check() validation to ~50 meta kernels in ops_registrations.py
  covering dtype, dimension, shape, and scalar parameter constraints
- Inline the 4 data-dependent runtime checks (division-by-zero, attention_mask
  bounds) directly into kernel implementations across generic, HiFi, and G3
  backends
- Remove codegen wrapper generation from codegen.py (generate_wrapper_code,
  insert_runtime_context, etc.) since checks no longer need wrapper functions
- Update ops.bzl to remove wrapper.cpp references and wrapper library creation
- Update targets.bzl to remove deleted header references

Reviewed By: abeakkas

Differential Revision: D102624163
@meta-codesync meta-codesync Bot force-pushed the export-D102624163 branch from 3dccdc2 to f639c2d Compare April 29, 2026 23:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. fb-exported meta-exported

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant