8000 [inductor][dynamo] Include operator name in size/stride/alignment assertion by karthickai · Pull Request #152353 · pytorch/pytorch · GitHub
[go: up one dir, main page]

Skip to content

[inductor][dynamo] Include operator name in size/stride/alignment assertion #152353

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 15 commits into from

Conversation

karthickai
Copy link
Collaborator
@karthickai karthickai commented Apr 28, 2025

Fixes #151930

This PR updates the assert_size_stride and assert_alignment functions in guards.cpp to accept an optional op_name argument and includes it in the error messages.

The corresponding type stubs in guards.pyi are updated to match the new function arg.

In inductor/ir.py extracts the operator name from the FX graph and passes it into the codegen_size_asserts and codegen_alignment_asserts functions, so that generated assertions in Triton code include the op name for better debugging.

Added unit tests inside test_torchinductor.py.

  • Verified both successful and failing assertion cases include the operator name.
  • Verified that generated Triton code contains the op name inside the asserts.

cc @H-Huang @awgu @wanchaol @fegin @fduwjj @wz337 @wconstab @d4l3k @voznesenskym @penguinwu @EikanWang @jgong5 @Guobing-Chen @XiaobingSuper @zhuhaozhe @blzheng @wenzhe-nrv @jiayisunx @ipiszy @chenyang78 @kadeng @muchulee8 @amjames @chauhang @aakhundov @shunting314 @eellison

Copy link
pytorch-bot bot commented Apr 28, 2025

🔗 Helpful Links

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

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

✅ You can merge normally! (1 Unrelated Failure)

As of commit a7888fa with merge base 6a78161 (image):

UNSTABLE - The following job is marked as unstable, possibly due to flakiness on trunk:

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

Copy link
linux-foundation-easycla bot commented Apr 28, 2025

CLA Signed

The committers listed above are authorized under a signed CLA.

@karthickai
Copy link
Collaborator Author

@pytorchbot label "topic: not user facing"

@pytorch-bot pytorch-bot bot added the topic: not user facing topic category label Apr 28, 2025
@jerryzh168 jerryzh168 added the triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module label Apr 29, 2025
@jansel
Copy link
Contributor
jansel commented Apr 29, 2025

Also looks like lints are failing.

@karthickai
Copy link
Collaborator Author

Thank you @jansel, I’ve pushed updates with your suggestions.

shunting314
shunting314 previously approved these changes Apr 29, 2025
@shunting314
Copy link
Contributor

The lint job still fails. Not sure if this is some transient error though

@jansel
Copy link
Contributor
jansel commented Apr 29, 2025

You should be able to fix the lints with:

make setup_lint
lintrunner -a

@karthickai
Copy link
Collaborator Author

@jansel @shunting314 I believe the lint error is now resolved with the latest commit.

jansel
jansel previously approved these changes Apr 30, 2025
@jansel
Copy link
Contributor
jansel commented Apr 30, 2025

@pytorchbot merge

@pytorch-bot pytorch-bot bot added the ciflow/trunk Trigger trunk jobs on your pull request label Apr 30, 2025
@pytorchmergebot
Copy link
Collaborator

Merge started

Your change will be merged once all checks pass (ETA 0-4 Hours).

Learn more about merging in the wiki.

Questions? Feedback? Please reach out to the PyTorch DevX Team

Advanced Debugging
Check the merge workflow status
here

@pytorchmergebot
Copy link
Collaborator

Merge failed

Reason: 1 mandatory check(s) failed. The first few are:

Dig deeper by viewing the failures on hud

Details for Dev Infra team Raised by workflow job

Failing merge rule: Core Maintainers

@karthickai
Copy link
Collaborator Author

@pytorchbot label "skip-url-lint"

@pytorch-bot pytorch-bot bot added skip-url-lint and removed ciflow/trunk Trigger trunk jobs on your pull request labels May 1, 2025
@karthickai
Copy link
Collaborator Author

cc @jansel @shunting314. I've added the skip-url-lint label to bypass transient outages in the Lint link check. In the latest commit, I updated existing tests to reflect recent changes in assert_size_stride and fixed the get_op_name to avoid duplicate namespace segments when combining op_namespace and target.

Copy link
Contributor
@jansel jansel left a comment

Choose a reason for hiding this comment

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

Test failures?

@karthickai
Copy link
Collaborator Author

@pytorchbot label ciflow/inductor ciflow/trunk

@pytorch-bot pytorch-bot bot added ciflow/inductor ciflow/trunk Trigger trunk jobs on your pull request labels Jun 1, 2025
@facebook-github-bot
Copy link
Contributor

@jansel has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

…e_has_size_stride_assert and test_generated_code_has_alignment_assert
@pytorch-bot pytorch-bot bot removed ciflow/trunk Trigger trunk jobs on your pull request ciflow/inductor labels Jun 2, 2025
@karthickai
Copy link
Collaborator Author

@pytorchbot label ciflow/inductor ciflow/trunk

Copy link
pytorch-bot bot commented Jun 2, 2025

To add these label(s) (ciflow/inductor, ciflow/trunk) to the PR, please first approve the workflows that are awaiting approval (scroll to the bottom of this page).

This helps ensure we don't trigger CI on this PR until it is actually authorized to do so. Please ping one of the reviewers if you do not have access to approve and run workflows.

@facebook-github-bot
Copy link
Contributor

@jansel has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@pytorch-bot pytorch-bot bot added the ciflow/trunk Trigger trunk jobs on your pull request label Jun 2, 2025
@facebook-github-bot
Copy link
Contributor

@pytorchbot merge

(Initiating merge automatically since Phabricator Diff has merged)

@pytorchmergebot
Copy link
Collaborator

Merge started

Your change will be merged once all checks pass (ETA 0-4 Hours).

Learn more about merging in the wiki.

Questions? Feedback? Please reach out to the PyTorch DevX Team

Advanced Debugging
Check the merge workflow status
here

@pytorchmergebot
Copy link
Collaborator

Merge failed

Reason: 1 jobs have failed, first few of them are: Meta Internal-Only Changes Check

Details for Dev Infra team Raised by workflow job

@jansel
Copy link
Contributor
jansel commented Jun 3, 2025

@pytorchbot merge -f "landed in fbcode"

@pytorchmergebot
Copy link
Collaborator

Merge started

Your change will be merged immediately since you used the force (-f) flag, bypassing any CI checks (ETA: 1-5 minutes). Please use -f as last resort and instead consider -i/--ignore-current to continue the merge ignoring current failures. This will allow currently pending tests to finish and report signal before the merge.

Learn more about merging in the wiki.

Questions? Feedback? Please reach out to the PyTorch DevX Team

Advanced Debugging
Check the merge workflow status
here

pytorchmergebot pushed a commit to Eliasj42/pytorch that referenced this pull request Jun 3, 2025
…ertion (pytorch#152353)

Fixes pytorch#151930

This PR updates the `assert_size_stride` and `assert_alignment` functions in [guards.cpp](https://github.com/pytorch/pytorch/blob/main/torch/csrc/dynamo/guards.cpp) to accept an optional `op_name` argument and includes it in the error messages.

The corresponding type stubs in [guards.pyi](https://github.com/pytorch/pytorch/blob/main/torch/_C/_dynamo/guards.pyi) are updated to match the new function arg.

In [inductor/ir.py](https://github.com/pytorch/pytorch/blob/main/torch/_inductor/ir.py) extracts the operator name from the FX graph and passes it into the `codegen_size_asserts` and `codegen_alignment_asserts` functions, so that generated assertions in Triton code include the op name for better debugging.

Added unit tests inside [test_torchinductor.py](https://github.com/pytorch/pytorch/blob/main/test/inductor/test_torchinductor.py).
- Verified both successful and failing assertion cases include the operator name.
- Verified that generated Triton code contains the op name inside the asserts.

Pull Request resolved: pytorch#152353
Approved by: https://github.com/jansel, https://github.com/shunting314
iupaikov-amd pushed a commit to ROCm/pytorch that referenced this pull request Jun 4, 2025
…ertion (pytorch#152353)

Fixes pytorch#151930

This PR updates the `assert_size_stride` and `assert_alignment` functions in [guards.cpp](https://github.com/pytorch/pytorch/blob/main/torch/csrc/dynamo/guards.cpp) to accept an optional `op_name` argument and includes it in the error messages.

The corresponding type stubs in [guards.pyi](https://github.com/pytorch/pytorch/blob/main/torch/_C/_dynamo/guards.pyi) are updated to match the new function arg.

In [inductor/ir.py](https://github.com/pytorch/pytorch/blob/main/torch/_inductor/ir.py) extracts the operator name from the FX graph and passes it into the `codegen_size_asserts` and `codegen_alignment_asserts` functions, so that generated assertions in Triton code include the op name for better debugging.

Added unit tests inside [test_torchinductor.py](https://github.com/pytorch/pytorch/blob/main/test/inductor/test_torchinductor.py).
- Verified both successful and failing assertion cases include the operator name.
- Verified that generated Triton code contains the op name inside the asserts.

Pull Request resolved: pytorch#152353
Approved by: https://github.com/jansel, https://github.com/shunting314
angelayi pushed a commit to angelayi/pytorch that referenced this pull request Jun 5, 2025
…ertion (pytorch#152353)

Fixes pytorch#151930

This PR updates the `assert_size_stride` and `assert_alignment` functions in [guards.cpp](https://github.com/pytorch/pytorch/blob/main/torch/csrc/dynamo/guards.cpp) to accept an optional `op_name` argument and includes it in the error messages.

The corresponding type stubs in [guards.pyi](https://github.com/pytorch/pytorch/blob/main/torch/_C/_dynamo/guards.pyi) are updated to match the new function arg.

In [inductor/ir.py](https://github.com/pytorch/pytorch/blob/main/torch/_inductor/ir.py) extracts the operator name from the FX graph and passes it into the `codegen_size_asserts` and `codegen_alignment_asserts` functions, so that generated assertions in Triton code include the op name for better debugging.

Added unit tests inside [test_torchinductor.py](https://github.com/pytorch/pytorch/blob/main/test/inductor/test_torchinductor.py).
- Verified both successful and failing assertion cases include the operator name.
- Verified that generated Triton code contains the op name inside the asserts.

Pull Request resolved: pytorch#152353
Approved by: https://github.com/jansel, https://github.com/shunting314
vijayabhaskar-ev pushed a commit to vijayabhaskar-ev/pytorch that referenced this pull request Jun 22, 2025
…ertion (pytorch#152353)

Fixes pytorch#151930

This PR updates the `assert_size_stride` and `assert_alignment` functions in [guards.cpp](https://github.com/pytorch/pytorch/blob/main/torch/csrc/dynamo/guards.cpp) to accept an optional `op_name` argument and includes it in the error messages.

The corresponding type stubs in [guards.pyi](https://github.com/pytorch/pytorch/blob/main/torch/_C/_dynamo/guards.pyi) are updated to match the new function arg.

In [inductor/ir.py](https://github.com/pytorch/pytorch/blob/main/torch/_inductor/ir.py) extracts the operator name from the FX graph and passes it into the `codegen_size_asserts` and `codegen_alignment_asserts` functions, so that generated assertions in Triton code include the op name for better debugging.

Added unit tests inside [test_torchinductor.py](https://github.com/pytorch/pytorch/blob/main/test/inductor/test_torchinductor.py).
- Verified both successful and failing assertion cases include the operator name.
- Verified that generated Triton code contains the op name inside the asserts.

Pull Request resolved: pytorch#152353
Approved by: https://github.com/jansel, https://github.com/shunting314
vijayabhaskar-ev pushed a commit to vijayabhaskar-ev/pytorch that referenced this pull request Jul 14, 2025
…ertion (pytorch#152353)

Fixes pytorch#151930

This PR updates the `assert_size_stride` and `assert_alignment` functions in [guards.cpp](https://github.com/pytorch/pytorch/blob/main/torch/csrc/dynamo/guards.cpp) to accept an optional `op_name` argument and includes it in the error messages.

The corresponding type stubs in [guards.pyi](https://github.com/pytorch/pytorch/blob/main/torch/_C/_dynamo/guards.pyi) are updated to match the new function arg.

In [inductor/ir.py](https://github.com/pytorch/pytorch/blob/main/torch/_inductor/ir.py) extracts the operator name from the FX graph and passes it into the `codegen_size_asserts` and `codegen_alignment_asserts` functions, so that generated assertions in Triton code include the op name for better debugging.

Added unit tests inside [test_torchinductor.py](https://github.com/pytorch/pytorch/blob/main/test/inductor/test_torchinductor.py).
- Verified both successful and failing assertion cases include the operator name.
- Verified that generated Triton code contains the op name inside the asserts.

Pull Request resolved: pytorch#152353
Approved by: https://github.com/jansel, https://github.com/shunting314
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ci-no-td Do not run TD on this PR ciflow/trunk Trigger trunk jobs on your pull request keep-going Don't stop on first failure, keep running tests until the end Merged module: dynamo module: inductor oncall: distributed Add this issue/PR to distributed oncall triage queue open source Reverted skip-url-lint topic: not user facing topic category triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add operator name to the size/strides/alignment assertion
9 participants
0