Repository navigation
Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/184287
Note: Links to docs will display an error until the docs builds have been completed. ❗ 1 Active SEVsThere are 1 currently active SEVs. If your PR is affected, please view them below: ✅ You can merge normally! (1 Unrelated Failure)As of commit 6ad6290 with merge base 4908f4e ( FLAKY - The following job failed but was likely due to flakiness present on trunk:
This comment was automatically generated by Dr. CI and updates every 15 minutes. |
|
@claude review these changes |
|
Claude finished @jansel's task in 3m 0s —— View job Review: Fix Inductor gather bounds for negative indices
Summary: This PR correctly fixes a semantic mismatch between eager and compiled AnalysisThe bug (two interrelated issues):
The fixes:
FeedbackLooks good overall. The logic is sound and the changes are minimal. A few observations:
LGTM — no issues found. The PR is well-scoped, fixes a real correctness issue (compiled code silently producing wrong results when eager would error), and has comprehensive tests. |
|
@pytorchbot merge |
Merge startedYour 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 |
Inductor should preserve eager gather/NLLLoss bounds semantics when negative indices are not valid inputs, including symbolic and CSE index paths. Fixes pytorch#135546 Generated by my agent Pull Request resolved: pytorch#184287 Approved by: https://github.com/oulgen
Inductor should preserve eager gather/NLLLoss bounds semantics when negative indices are not valid inputs, including symbolic and CSE index paths. Fixes pytorch#135546 Generated by my agent Pull Request resolved: pytorch#184287 Approved by: https://github.com/oulgen
Inductor should preserve eager gather/NLLLoss bounds semantics when negative indices are not valid inputs, including symbolic and CSE index paths. Fixes pytorch#135546 Generated by my agent Pull Request resolved: pytorch#184287 Approved by: https://github.com/oulgen
Inductor should preserve eager gather/NLLLoss bounds semantics when negative indices are not valid inputs, including symbolic and CSE index paths. Fixes pytorch#135546 Generated by my agent Pull Request resolved: pytorch#184287 Approved by: https://github.com/oulgen
Human context: fix for #194490) exposed by #184287 although the underlying cause was prior CSE / loop hoisting logic (and ultimately the fact that this is all tied to one very complicated file).. Triton load placement and CSE lifetime used separate heuristics. An indirect load emitted inside a loop could consequently remain cached after loop closure and be reused by an epilogue even though its temporary did not dominate that use. Use the selected load buffer as the source of truth for whether a CSE value survives loop closure. Also prevent loads carrying reduction masks from being hoisted before those masks are defined. Test Plan: ``` python test/inductor/test_indexing.py ReductionInvariantIndexingTests python test/inductor/test_codegen_triton.py -k reduction_invariant_load_indexing git diff --check lintrunner -a test/inductor/test_indexing.py torch/_inductor/codegen/triton.py ``` The two test commands and git diff check pass. Lintrunner was invoked, but Pyrefly failed on unrelated repository-wide missing-attribute errors because this detached worktree has no initialized lintrunner data. AI-Assisted: Author reviewed and validated all AI-generated content. Pull Request resolved: #194786 Approved by: https://github.com/atalman, https://github.com/karthickai
…me (#194786) (#194833) * [inductor] Fix loop-local load CSE lifetime (#194786) Manual cherry-pick of 60598ed (#194786) onto release/2.14. Triton load placement and CSE lifetime used separate heuristics. An indirect load emitted inside a loop could remain cached after loop closure and be reused by an epilogue even though its temporary did not dominate that use. Use the selected load buffer as the source of truth for whether a CSE value survives loop closure, and stop hoisting loads that carry reduction masks before those masks are defined. Conflict resolution: * torch/_inductor/codegen/triton.py: upstream also deletes the reduction_axes_omitted bookkeeping added by #184287, which is not on this branch, so that deletion is already satisfied and the surrounding code is left as-is. The two substantive changes (the has_rmask() guard on lifting, and load_buffer is self.body as the CSE-lifetime test) apply unchanged. * test/inductor/test_indexing.py: upstream adds the regression test to ReductionInvariantIndexingTests, a class that #184287 introduced and which does not exist here. The regression test is ported verbatim into a new TestLoopLocalLoadCSELifetime class with the imports it needs (run_and_get_kernels, FileCheck, HAS_CUDA_AND_TRITON, config), all of which exist on this branch. The unrelated @parametrize("dense_indexing") hunk is dropped, since it belongs to a #184287 test. Fixes #194490 on the release branch. * Fix PYFMT import ordering --------- Co-authored-by: eellison <[email protected]>
Human context: fix for pytorch#194490) exposed by pytorch#184287 although the underlying cause was prior CSE / loop hoisting logic (and ultimately the fact that this is all tied to one very complicated file).. Triton load placement and CSE lifetime used separate heuristics. An indirect load emitted inside a loop could consequently remain cached after loop closure and be reused by an epilogue even though its temporary did not dominate that use. Use the selected load buffer as the source of truth for whether a CSE value survives loop closure. Also prevent loads carrying reduction masks from being hoisted before those masks are defined. Test Plan: ``` python test/inductor/test_indexing.py ReductionInvariantIndexingTests python test/inductor/test_codegen_triton.py -k reduction_invariant_load_indexing git diff --check lintrunner -a test/inductor/test_indexing.py torch/_inductor/codegen/triton.py ``` The two test commands and git diff check pass. Lintrunner was invoked, but Pyrefly failed on unrelated repository-wide missing-attribute errors because this detached worktree has no initialized lintrunner data. AI-Assisted: Author reviewed and validated all AI-generated content. Pull Request resolved: pytorch#194786 Approved by: https://github.com/atalman, https://github.com/karthickai
Stack from ghstack (oldest at bottom):
Inductor should preserve eager gather/NLLLoss bounds semantics when negative indices are not valid inputs, including symbolic and CSE index paths.
Fixes #135546
Generated by my agent
cc @voznesenskym @penguinwu @EikanWang @jgong5 @Guobing-Chen @XiaobingSuper @zhuhaozhe @blzheng @wenzhe-nrv @jiayisunx @ipiszy @kadeng @muchulee8 @amjames @chauhang @aakhundov @coconutruben @jataylo @mlazos