Repository navigation
[Inductor][TP] Fuse slice-cat TP collective patterns - #184911
Closed
sanketpurandare wants to merge 1 commit into
Closed
sanketpurandare wants to merge 1 commit into
sanketpurandare wants to merge 1 commit into
Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/184911
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 932b565 with merge base 90e9fa9 ( BROKEN TRUNK - The following job failed but were present on the merge base:👉 Rebase onto the `viable/strict` branch to avoid these failures
This comment was automatically generated by Dr. CI and updates every 15 minutes. |
sanketpurandare
force-pushed
the
sanketpurandare/stack/15
branch
from
May 22, 2026 17:32
ad37664 to
078fbe2
Compare
sanketpurandare
added a commit
that referenced
this pull request
May 22, 2026
Graph-level chunking can expose tensor-parallel collective values through simple slice/cat reassembly before a matmul, or can feed reduce-scatter from an equivalent slice/cat form after a matmul. The existing micro-pipeline TP matcher only recognized the direct all-gather/matmul and matmul/reduce-scatter patterns, so these semantically equivalent graphs missed fusion. Teach the all-gather and reduce-scatter matchers to recognize slice/cat forms that reassemble a single collective value without changing the TP communication contract. The replacement and erase logic remains scoped to the matched nodes, and the matmul multi-user guard still rejects users outside the matched reassembly. Fixes #184833 Test Plan: python test/distributed/tensor/parallel/test_micro_pipeline_tp.py MicroPipelineTPTest.test_find_all_gather_patterns MicroPipelineTPTest.test_find_reduce_scatter_patterns MicroPipelineTPTest.test_fuse_all_gather_matmul_slice_cat MicroPipelineTPTest.test_fuse_all_gather_matmul_slice_cat_trim MicroPipelineTPTest.test_fuse_matmul_reduce_scatter_slice_cat -v lintrunner --config=.lintrunner.toml torch/_inductor/fx_passes/micro_pipeline_tp.py test/distributed/tensor/parallel/test_micro_pipeline_tp.py stack-info: PR: #184911, branch: sanketpurandare/stack/15
This was referenced May 22, 2026
sanketpurandare
marked this pull request as draft
May 22, 2026 19:26
sanketpurandare
force-pushed
the
sanketpurandare/stack/15
branch
from
May 22, 2026 19:27
078fbe2 to
f059ca5
Compare
sanketpurandare
added a commit
that referenced
this pull request
May 22, 2026
Graph-level chunking can expose tensor-parallel collective values through simple slice/cat reassembly before a matmul, or can feed reduce-scatter from an equivalent slice/cat form after a matmul. The existing micro-pipeline TP matcher only recognized the direct all-gather/matmul and matmul/reduce-scatter patterns, so these semantically equivalent graphs missed fusion. Teach the all-gather and reduce-scatter matchers to recognize slice/cat forms that reassemble a single collective value without changing the TP communication contract. The replacement and erase logic remains scoped to the matched nodes, and the matmul multi-user guard still rejects users outside the matched reassembly. Fixes #184833 Test Plan: python test/distributed/tensor/parallel/test_micro_pipeline_tp.py MicroPipelineTPTest.test_find_all_gather_patterns MicroPipelineTPTest.test_find_reduce_scatter_patterns MicroPipelineTPTest.test_fuse_all_gather_matmul_slice_cat MicroPipelineTPTest.test_fuse_all_gather_matmul_slice_cat_trim MicroPipelineTPTest.test_fuse_matmul_reduce_scatter_slice_cat -v lintrunner --config=.lintrunner.toml torch/_inductor/fx_passes/micro_pipeline_tp.py test/distributed/tensor/parallel/test_micro_pipeline_tp.py stack-info: PR: #184911, branch: sanketpurandare/stack/15
sanketpurandare
marked this pull request as ready for review
May 22, 2026 19:27
sanketpurandare
marked this pull request as draft
May 22, 2026 19:42
sanketpurandare
force-pushed
the
sanketpurandare/stack/15
branch
from
May 22, 2026 19:42
f059ca5 to
bd96437
Compare
sanketpurandare
added a commit
that referenced
this pull request
May 22, 2026
Graph-level chunking can expose tensor-parallel collective values through simple slice/cat reassembly before a matmul, or can feed reduce-scatter from an equivalent slice/cat form after a matmul. The existing micro-pipeline TP matcher only recognized the direct all-gather/matmul and matmul/reduce-scatter patterns, so these semantically equivalent graphs missed fusion. Teach the all-gather and reduce-scatter matchers to recognize slice/cat forms that reassemble a single collective value without changing the TP communication contract. The replacement and erase logic remains scoped to the matched nodes, and the matmul multi-user guard still rejects users outside the matched reassembly. Fixes #184833 Test Plan: python test/distributed/tensor/parallel/test_micro_pipeline_tp.py MicroPipelineTPTest.test_find_all_gather_patterns MicroPipelineTPTest.test_find_reduce_scatter_patterns MicroPipelineTPTest.test_fuse_all_gather_matmul_slice_cat MicroPipelineTPTest.test_fuse_all_gather_matmul_slice_cat_trim MicroPipelineTPTest.test_fuse_matmul_reduce_scatter_slice_cat -v lintrunner --config=.lintrunner.toml torch/_inductor/fx_passes/micro_pipeline_tp.py test/distributed/tensor/parallel/test_micro_pipeline_tp.py stack-info: PR: #184911, branch: sanketpurandare/stack/15
sanketpurandare
marked this pull request as ready for review
May 22, 2026 19:42
pianpwk
approved these changes
May 22, 2026
sanketpurandare
force-pushed
the
sanketpurandare/stack/15
branch
from
May 27, 2026 04:34
873deee to
ff08758
Compare
sanketpurandare
marked this pull request as ready for review
May 27, 2026 04:34
sanketpurandare
marked this pull request as draft
June 4, 2026 19:00
sanketpurandare
force-pushed
the
sanketpurandare/stack/15
branch
from
June 4, 2026 19:00
ff08758 to
fd55259
Compare
sanketpurandare
marked this pull request as ready for review
June 4, 2026 19:01
sanketpurandare
marked this pull request as draft
June 4, 2026 19:06
sanketpurandare
marked this pull request as ready for review
June 4, 2026 19:07
sanketpurandare
changed the base branch from
gh/sanketpurandare/1/head
to
sanketpurandare/stack/10
June 4, 2026 20:54
sanketpurandare
marked this pull request as draft
June 4, 2026 22:31
sanketpurandare
force-pushed
the
sanketpurandare/stack/15
branch
from
June 4, 2026 22:32
fd55259 to
03cd299
Compare
sanketpurandare
marked this pull request as ready for review
June 4, 2026 22:32
pytorchmergebot
pushed a commit
that referenced
this pull request
Jun 5, 2026
Stacked PRs: * #183838 * #186255 * #183839 * #183840 * #183837 * #184911 * __->__#183545 --- --- --- ### [DTensor] Use explicit hints for unbacked sharding DTensor sharding falls back to conservative behavior when a shard size is unbacked because divisibility and sharding metadata often require Python decisions. That is correct for arbitrary symbolic sizes, but it is too conservative for tracing paths that explicitly override optimization hints and know that a sharded dimension or strict-view split factor is stable. This change only trusts explicit optimization hint overrides for those Python decisions. When a hint selects a no-padding or shardable branch, the traced graph still emits the symbolic torch._check for the correctness predicate, so runtime values that satisfy the predicate continue to work and values that violate it fail closed. The hint chooses the trace-time policy branch; it is not baked in as a concrete tensor extent. For _StridedShard, view propagation now preserves a symbolic split_factor when the split factor came from symbolic shape propagation. The C++ placement still needs an int64_t unroll count for list-based lowering, so the Python wrapper stores the symbolic split factor separately and uses the explicit hint only as a guarded unroll count. The equality assertion is deferred instead of directly calling torch._check(symbol == hint), because the direct check immediately refines the ShapeEnv replacement and destroys the symbolic split_factor metadata we need to preserve. Assisted by Codex. Fixes #183678 Test Plan: ```bash python -m pytest -q test/distributed/tensor/test_placement_types.py test/distributed/tensor/test_view_ops.py::TestViewOps::test_view_groups_unbacked_sharding_propagation ``` ```bash lintrunner --config=.lintrunner.toml torch/distributed/tensor/placement_types.py torch/distributed/tensor/_ops/_view_ops.py torch/distributed/tensor/_ops/utils.py test/distributed/tensor/test_placement_types.py test/distributed/tensor/test_view_ops.py ``` Pull Request resolved: #183545 Approved by: https://github.com/pianpwk
sanketpurandare
marked this pull request as draft
June 5, 2026 20:59
sanketpurandare
force-pushed
the
sanketpurandare/stack/15
branch
from
June 5, 2026 20:59
03cd299 to
e4899da
Compare
Graph-level chunking can expose tensor-parallel collective values through simple slice/cat reassembly before a matmul, or can feed reduce-scatter from an equivalent slice/cat form after a matmul. The existing micro-pipeline TP matcher only recognized the direct all-gather/matmul and matmul/reduce-scatter patterns, so these semantically equivalent graphs missed fusion. Teach the all-gather and reduce-scatter matchers to recognize slice/cat forms that reassemble a single collective value without changing the TP communication contract. The replacement and erase logic remains scoped to the matched nodes, and the matmul multi-user guard still rejects users outside the matched reassembly. Fixes #184833 Test Plan: python test/distributed/tensor/parallel/test_micro_pipeline_tp.py MicroPipelineTPTest.test_find_all_gather_patterns MicroPipelineTPTest.test_find_reduce_scatter_patterns MicroPipelineTPTest.test_fuse_all_gather_matmul_slice_cat MicroPipelineTPTest.test_fuse_all_gather_matmul_slice_cat_trim MicroPipelineTPTest.test_fuse_matmul_reduce_scatter_slice_cat -v lintrunner --config=.lintrunner.toml torch/_inductor/fx_passes/micro_pipeline_tp.py test/distributed/tensor/parallel/test_micro_pipeline_tp.py stack-info: PR: #184911, branch: sanketpurandare/stack/15
Contributor
Author
|
@pytorchbot merge |
Collaborator
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 |
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.
Stacked PRs:
[Inductor][TP] Fuse slice-cat TP collective patterns
Graph-level chunking can expose tensor-parallel collective values through simple slice/cat reassembly before a matmul, or can feed reduce-scatter from an equivalent slice/cat form after a matmul. The existing micro-pipeline TP matcher only recognized the direct all-gather/matmul and matmul/reduce-scatter patterns, so these semantically equivalent graphs missed fusion.
Teach the all-gather and reduce-scatter matchers to recognize slice/cat forms that reassemble a single collective value without changing the TP communication contract. The replacement and erase logic remains scoped to the matched nodes, and the matmul multi-user guard still rejects users outside the matched reassembly.
Fixes #184833
Test Plan:
python test/distributed/tensor/parallel/test_micro_pipeline_tp.py MicroPipelineTPTest.test_find_all_gather_patterns MicroPipelineTPTest.test_find_reduce_scatter_patterns MicroPipelineTPTest.test_fuse_all_gather_matmul_slice_cat MicroPipelineTPTest.test_fuse_all_gather_matmul_slice_cat_trim MicroPipelineTPTest.test_fuse_matmul_reduce_scatter_slice_cat -v
lintrunner --config=.lintrunner.toml torch/_inductor/fx_passes/micro_pipeline_tp.py test/distributed/tensor/parallel/test_micro_pipeline_tp.py
cc @voznesenskym @penguinwu @EikanWang @jgong5 @Guobing-Chen @XiaobingSuper @zhuhaozhe @blzheng @wenzhe-nrv @jiayisunx @ipiszy @kadeng @muchulee8 @amjames @chauhang @aakhundov @coconutruben @jataylo