Repository navigation
[Frontend] One module for our FX graph rewrites: rewrite_fx_graph.py - #323
Merged
Merged
Conversation
extension_decomposition (histc, polar), extension_topk, extension_grouped_mm, extension_complex_to_real and the extension_fx chain they share all did one thing -- rewrite ops with no npu kernel into aten ops the backend lowers, so the work stays in the graph -- and were installed three different ways. They are now one module with one install(), called once from torch_openreg. The rewrites are unchanged; the chain keeps its order (grouped_mm, topk, complex) and its keys, so Inductor cache keys do not move. Comments are cut to the docstring rule. CLAUDE.md points at the new module and says where work goes now: a branch on PSAL-POSTECH/PyTorchSim and a PR into pytorchsim-triton-backend. Verified on a cleared cache: test_complex_to_real, test_polar, test_histc, test_expert_mask, test_topk, test_add pass; the only extern left is histc on a float input, which the decomposition leaves to the CPU by design. Qwen2-MoE (--preset 2-moe) fails in the compiler's TTGIR lowering of a sort kernel, the same failure at the same point on 6ba6e62 without this change.
This was referenced Oct 23, 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.
Merges
extension_decomposition.py(histc, polar),extension_topk.py,extension_grouped_mm.py,extension_complex_to_real.pyand theextension_fx.pychain they share into one module,PyTorchSimFrontend/rewrite_fx_graph.py, with a singleinstall()called fromtorch_openreg.All five did the same job: rewrite ops with no npu kernel into aten ops the backend lowers, so the work stays on the device instead of falling back to the CPU. They were installed three different ways (on import, by an explicit
install(), by decorator). The rewrites themselves are unchanged; the post-grad chain keeps its order (grouped_mm, topk, complex) and its keys, so Inductor cache keys do not move. Comments are cut to the repo's docstring rule.CLAUDE.md now points at the new module and says where work goes: a branch on PSAL-POSTECH/PyTorchSim and a PR into
pytorchsim-triton-backend.Verified (cleared cache, functional mode)
aten.histcon a float input, which the decomposition leaves to the CPU by design--preset 2-moefails in the compiler's TTGIR lowering of a sort kernel -- the same failure at the same point on 6ba6e62 without this changeTiming mode was not run: the branch head's TOGSim is at producer ABI 14 while PTB main still emits ABI 13 (see #321).