Repository navigation
[Frontend] A complex scalar times a complex value is a complex product in the real pairs - #438
Merged
Merged
Conversation
…t in the real pairs ComplexToRealPairs multiplied the [..., 2] pair of a complex value by the other operand whenever that operand was not a complex node. Post-grad, z * (1+2j) is aten.mul.Tensor(z, (1+2j)), so the pair was multiplied by the Python complex itself: the result came out complex64 with the wrong values and no warning. A Python complex operand now takes the same (ar*br - ai*bi, ar*bi + ai*br) form as two complex nodes; a real scalar or tensor still scales the pair. The pass uuid moves to -3 so Inductor's FX cache does not replay a graph the old pass rewrote. torch 2.14 still does not lower complex mul (lowering.py warns and falls back; only complex add is decomposed), so the pass stays. tests/ops/misc/test_complex_to_real.py: test_complex_scalar_multiply puts a complex scalar on each side; it fails on the old pass (three aten.mul.Tensor left complex) and passes now.
This was referenced Oct 23, 2026
Merged
YWHyuk
marked this pull request as ready for review
October 23, 2026 13:24
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.
Split out of #433 by @student-Jungmin (commit 31747c8), author kept. Applies to the current
pytorchsim-triton-backendunchanged.What
ComplexToRealPairsmultiplied the[..., 2]pair of a complex value by the other operand whenever that operand was not a complex node. Post-grad,z * (1+2j)isaten.mul.Tensor(z, (1+2j)), so the pair was multiplied by the Python complex itself: the result came out complex64 with wrong values and no warning. A Python complex operand now takes the same(ar*br - ai*bi, ar*bi + ai*br)form as two complex nodes; a real scalar or tensor still scales the pair. The pass uuid moves to-3so Inductor's FX cache does not replay a graph the old pass rewrote. torch 2.14 still does not lower complex mul, so the pass stays.Tests
tests/ops/misc/test_complex_to_real.pytest_complex_scalar_multiplyputs a complex scalar on each side; it fails on the old pass (threeaten.mul.Tensorleft complex). Run on this branch (functional mode, timing off): rewritten graph, complex scalar and RoPE-on-device pass.Split of #433
#433 (@student-Jungmin, branch
refactor/post-grad-pass) is split into four PRs. #433 itself is left as it is.split/433-complex-scalarpytorchsim-triton-backendsplit/433-npu-topkpytorchsim-triton-backendsplit/433-grouped-mm-fallbackgrouped_mm_fallbacktakesaten._grouped_mm's npu kernel (6886059)pytorchsim-triton-backendsplit/433-post-grad-passpytorchsim-triton-backendThe three feature PRs each apply to the current base on their own, in the pre-refactor file layout (
rewrite_fx_graph.py). #439 and #440 both remove a rewrite fromrewrite_fx_graph.pynext to each other, so whichever merges second needs a trivial rebase; #441 already holds that resolution. Applying #438 → #439 → #440 → #441 gives exactly the tree of #433's head 9ff24d3 rebased onto the current base (git diffempty).🤖 Generated with Claude Code
https://claude.ai/code/session_011cGNfHFySFsi7feZKKvq7e