Fix fbcode CI torch.compile fusion with newer PyTorch#2567
Open
choijon5 wants to merge 1 commit into
Open
Conversation
eb5d719 to
91be000
Compare
oulgen
reviewed
May 23, 2026
Comment on lines
+849
to
+865
| _scheduler_node_has_aliasing_or_mutation = SchedulerNode.has_aliasing_or_mutation | ||
|
|
||
|
|
||
| def _helion_scheduler_node_has_aliasing_or_mutation( | ||
| self: SchedulerNode, | ||
| ) -> bool: | ||
| if isinstance(self.node, HelionTemplateBuffer): | ||
| return False | ||
| return _scheduler_node_has_aliasing_or_mutation(self) | ||
|
|
||
|
|
||
| # Inductor's generic template prologue check rejects any template with mutation | ||
| # outputs. Helion already limits prologue fusion to non-mutated inputs via | ||
| # allowed_prologue_inps, so non-mutated pointwise producers can still fuse safely. | ||
| SchedulerNode.has_aliasing_or_mutation = ( # pyrefly: ignore[bad-assignment] | ||
| _helion_scheduler_node_has_aliasing_or_mutation | ||
| ) |
Contributor
There was a problem hiding this comment.
what's going on here? this code looks very suspicious
Contributor
Author
There was a problem hiding this comment.
Yep it was too broad. Addressed now.
1025482 to
575afbd
Compare
jansel
requested changes
May 24, 2026
| # Inductor has no template hook for the prologue-fusion mutation gate. Route | ||
| # Helion templates through the narrower check above while leaving every other | ||
| # SchedulerNode on Inductor's implementation. | ||
| SchedulerNode.has_aliasing_or_mutation = ( # pyrefly: ignore[bad-assignment] |
Contributor
There was a problem hiding this comment.
Can we fix this on the PyTorch side rather than monkey patching?
575afbd to
4c442a1
Compare
4c442a1 to
5db18b9
Compare
jansel
approved these changes
May 27, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix Helion torch.compile fusion failures seen in fbcode CI with a newer PyTorch/Inductor version.
Newer Inductor rejects template prologue fusion when the template scheduler node reports mutation. PyTorch PR pytorch/pytorch#185317 adds a template hook for that gate, and this Helion change implements the hook instead of monkey patching SchedulerNode.
Helion allows independent non-mutated prologue producers while still blocking aliases, real mutations, direct mutation inputs, and producers that read mutated inputs through allowed_prologue_inps.
Also refreshes Inductor range-tree symbol mappings after fusion hook setup to fix
Unregistered range symbolfailures from renamed prologue/epilogue range variables.Adds a regression test for the allowed and blocked prologue-fusion cases.