Repository navigation
[ATen][ProxyTensor] Preserve unbacked batch dims in SDPA tracing - #183398
sanketpurandare wants to merge 1 commit into
Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/183398
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: ❌ 1 New Failure, 1 Unrelated Failure, 1 Unclassified FailureAs of commit 66f7e43 with merge base 3c77e64 ( NEW FAILURE - The following job has failed:
UNCLASSIFIED FAILURE - DrCI could not classify the following job because the workflow did not run on the merge base. The failure may be pre-existing on trunk or introduced by this PR:
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. |
7c8e667 to
715c611
Compare
0dd03c3 to
38b9aa0
Compare
The general batched matmul path still converted broadcast batch dimensions to concrete int64_t sizes before expanding, reshaping, and viewing through bmm. That breaks tracing for rank-4 inputs with an unbacked batch symbol, including the math scaled-dot-product-attention path, because SDPA lowers through batched matmul. Carry symbolic sizes through the broadcasted bmm path by replacing sizes() and IntArrayRef/DimVector shape plumbing with sym_sizes(), SymDimVector, infer_size_symdimvector(), expand_symint(), reshape_symint(), _unsafe_view_symint(), and symbolic output resize. Keep the existing gradient broadcast shortcut but evaluate its symbolic predicates with guard helpers. Add fake tensor regressions for rank-4 matmul and math SDPA with an unbacked batch dimension, both traced through make_fx. Test Plan: python test/test_fake_tensor.py FakeTensorTest.test_linear_rank3_unbacked_batch_dim FakeTensorTest.test_matmul_rank4_unbacked_batch_dim FakeTensorTest.test_sdpa_math_unbacked_batch_dim lintrunner --config=.lintrunner.toml aten/src/ATen/native/LinearAlgebra.cpp torch/_decomp/decompositions.py test/test_fake_tensor.py Fixes pytorch/torchtitan#3324 stack-info: PR: #183398, branch: sanketpurandare/stack/7
There was a problem hiding this comment.
Pull request overview
This PR fixes symbolic-shape (unbacked SymInt) handling in the general batched matmul lowering path by keeping batch dimensions symbolic through broadcast/expand/reshape/view logic, preventing tracing breakages for rank-4 matmul and the math SDPA path that lowers through it.
Changes:
- Update the broadcasted
bmm-basedmatmulpath to usesym_sizes()/SymDimVector/infer_size_symdimvector()and SymInt-aware expand/reshape/view/output-resize APIs. - Preserve the existing gradient/broadcast shortcut while evaluating symbolic predicates via guard helpers.
- Add fake tensor regressions covering rank-4
matmuland math SDPA with an unbacked batch dim traced viamake_fx.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| aten/src/ATen/native/LinearAlgebra.cpp | Switch broadcasted batched-matmul shape plumbing to SymInt/SymDimVector-based operations to preserve unbacked batch symbols. |
| test/test_fake_tensor.py | Add fake-tensor regression tests (rank-4 matmul, math SDPA) and a helper for constructing inputs with an unbacked batch dim. |
| shape_env = ShapeEnv() | ||
| fake_mode = FakeTensorMode(allow_non_fake_inputs=True, shape_env=shape_env) | ||
| fakes = [] | ||
| with fake_mode, shape_env.ignore_fresh_unbacked_symbols(): |
There was a problem hiding this comment.
Added a comment here explaining why this helper intentionally uses ignore_fresh_unbacked_symbols(). The helper creates already-bound fake input batch symbols before tracing; without the context those input symbols remain in pending_fresh_unbacked_symbols, and make_fx fails while binding the fake inputs instead of exercising the SDPA/matmul behavior under test.
| ret.append({n, m1}); | ||
| return ret; | ||
| }(); | ||
| const auto tensor1_expanded = at::reshape_symint( |
There was a problem hiding this comment.
nit:
const auto tensor1_expanded = tensor1
.expand_symint(tensor1_expand_size)
.reshape_symint({expand_batch_product, n, m1});
better readability same for other locations
There was a problem hiding this comment.
Updated the tensor1_expanded expression to use the chained expand_symint(...).reshape_symint(...) form.
| auto tensor2_expanded = tensor2.expand_symint(tensor2_expand_size); | ||
| if (vector_rhs) { | ||
| tensor2_expanded = tensor2_expanded.reshape({expand_batch_product, m2}).unsqueeze(2); | ||
| tensor2_expanded = at::reshape_symint( |
There was a problem hiding this comment.
nit:
tensor2_expanded = tensor2_expanded
.reshape_symint({expand_batch_product, m2})
.unsqueeze(2);
There was a problem hiding this comment.
Updated the tensor2_expanded reshape path to use the chained form before unsqueeze(2).
38b9aa0 to
1203d93
Compare
1203d93 to
0fdac5c
Compare
36888a5 to
66f7e43
Compare
Add the scheduling layer for graph_trainer's public ep_overlap pass. The previous commit creates the correctness-preserving chunked graph; this commit consumes that chunked graph after FSDP bucketing and reorders EP dispatch/combine phases so paired chunk all-to-all launches can run before their delayed wait suffixes. The scheduling logic lives in ep_overlap_pass.py and is intentionally separate from chunking. Its input contract is an already chunked graph with exactly two chunks per selected region, chunk body nodes tagged with chunk_id and chunked_region metadata, and MoE dispatcher regions annotated with custom EP metadata for dispatch and combine. The scheduler validates canonical chunk order, extracts dispatch/combine phases, annotates delayed wait suffixes with EP_wait=True, and applies a priority topological sort. It does not duplicate nodes, delete nodes, split tensors, concatenate tensors, or otherwise change tensor values. Wire the public ep_overlap pipeline as two stages: chunking runs after CPU offload and SAC/rematerialization, while scheduling runs after downstream FSDP bucketing/reordering. This keeps chunk planning aligned with the final recompute graph and lets bucketing place shared full waits before the overlap scheduler establishes the final EP launch/wait order. The distributed DSV3 bitwise numerics tests introduced in the previous commit now cover this composed public ep_overlap path as well. Since this scheduling pass is value-preserving, those tests validate that adding the scheduler on top of graph chunking does not change the eager-chunk-equivalent loss/gradient behavior. Existing tlparse validation artifacts show the intended rank-code order: dispatch chunk0 launch, dispatch chunk1 launch, delayed dispatch waits, combine chunk0 launch, combine chunk1 launch, and delayed combine waits annotated with EP_wait=True. This pass stack relies on pending PyTorch support for hinted unbacked symbolic dimensions in the tracing and distributed compiler paths: - FakeTensor folded matmul: pytorch/pytorch#183397 - ProxyTensor SDPA tracing: pytorch/pytorch#183398 - Inductor bucketing trace isolation from ambient unbacked symbols: pytorch/pytorch#183495 - Inductor collective bucketing with hinted unbacked SymInts: pytorch/pytorch#183544 - DTensor sharding padding for hinted even unbacked shards: pytorch/pytorch#183545 Test Plan: - pytest torchtitan/experiments/graph_trainer/tests/test_passes.py -k 'ep_overlap or chunk' -q - 8 passed, 73 deselected, 2 subtests passed - pytest torchtitan/experiments/graph_trainer/tests/test_numerics.py -k ep_overlap -q - 3 passed, 20 deselected stack-info: PR: #3328, branch: sanketpurandare/stack/14
|
@pytorchbot merge -i |
Merge startedYour change will be merged while ignoring the following 3 checks: pull / linux-jammy-py3.14-clang18 / test (default, 3, 5, linux.4xlarge), inductor / unit-test / inductor-test / test (inductor_cpp_wrapper, 1, 2, linux.g5.4xlarge.nvidia.gpu), trunk / linux-jammy-aarch64-py3.10 / test (default, 2, 5, linux.arm64.m7g.4xlarge) Learn more about merging in the wiki. Questions? Feedback? Please reach out to the PyTorch DevX Team |
Add the scheduling layer for graph_trainer's public ep_overlap pass. The graph and eager chunking producers create correctness-preserving chunked graphs; this commit consumes their shared chunk metadata after FSDP bucketing and reorders EP dispatch/combine phases so paired chunk all-to-all launches can run before their delayed wait suffixes. The scheduling logic lives in ep_overlap_pass.py and is intentionally separate from chunking. Its input contract is an already chunked graph with exactly two chunks per selected region, chunk body nodes tagged with chunk_id and chunked_region metadata, and MoE dispatcher regions annotated with custom EP metadata for dispatch and combine. The scheduler validates the chunk metadata, uses the last all-to-all in each EP phase as the overlap boundary, annotates delayed wait suffixes with EP_wait=True, and applies a priority topological sort. It does not duplicate nodes, delete nodes, split tensors, concatenate tensors, or otherwise change tensor values. For forward dispatch, the overlap boundary is deliberately the final token-exchange all-to-all, not the earlier split-size exchange. Forward regions schedule dispatch then combine. Backward autograd sees combine gradients before dispatch gradients, so the scheduler derives the observed EP phase chunk order instead of imposing a hardcoded chunk order. Wire the public ep_overlap pipeline as two stages: chunking runs before memory/offload/remat and bucketing, while scheduling runs after downstream FSDP bucketing/reordering. This lets distributed bucketing place shared full-value waits first, then lets the EP scheduler establish the final EP launch/wait order. Add focused scheduler tests and H100 full-Inductor integration coverage for graph chunking and eager chunking across SDPA and FlexAttention debug-model variants. The distributed bitwise numerics tests introduced with graph chunking cover this composed public ep_overlap path because scheduling is value-preserving. This pass stack relies on pending PyTorch support for hinted unbacked symbolic dimensions in the tracing and distributed compiler paths: - FakeTensor folded matmul: pytorch/pytorch#183397 - ProxyTensor SDPA tracing: pytorch/pytorch#183398 - Inductor bucketing trace isolation from ambient unbacked symbols: pytorch/pytorch#183495 - Inductor collective bucketing with hinted unbacked SymInts: pytorch/pytorch#183544 - DTensor sharding padding for hinted even unbacked shards: pytorch/pytorch#183545 - HOP fake traces with discarded unbacked symbols: pytorch/pytorch#183837 - FlexAttention chunked unbacked input extents: pytorch/pytorch#183838 - FakeTensor trace metadata for hinted symbolic storage: pytorch/pytorch#183839 - Inductor symbolic stride ordering with unbacked hints: pytorch/pytorch#183840 Test Plan: - pytest -q torchtitan/experiments/graph_trainer/tests/test_passes.py - 84 passed, 1 skipped, 14 warnings, 5 subtests passed - pytest -q torchtitan/experiments/graph_trainer/tests/test_numerics.py -k ep_overlap - PYTHONPATH=$PWD python torchtitan/experiments/graph_trainer/tests/integration_tests.py /tmp/torchtitan_ep_overlap_integration_20260514_174529 --test_suite graph_trainer_h100 --test_name aot_fx_trace_deepseek_v3_sdpa_full_inductor_ep_overlap_transformer_batch --ngpu 8 - PYTHONPATH=$PWD python torchtitan/experiments/graph_trainer/tests/integration_tests.py /tmp/torchtitan_ep_overlap_integration_20260514_174529 --test_suite graph_trainer_h100 --test_name aot_fx_trace_deepseek_v3_sdpa_full_inductor_ep_overlap_moe_batch --ngpu 8 - PYTHONPATH=$PWD python torchtitan/experiments/graph_trainer/tests/integration_tests.py /tmp/torchtitan_ep_overlap_integration_20260514_174529 --test_suite graph_trainer_h100 --test_name aot_fx_trace_deepseek_v3_sdpa_full_inductor_ep_overlap_moe_seq --ngpu 8 - PYTHONPATH=$PWD python torchtitan/experiments/graph_trainer/tests/integration_tests.py /tmp/torchtitan_ep_overlap_integration_20260514_174529 --test_suite graph_trainer_h100 --test_name aot_fx_trace_deepseek_v3_flexattn_full_inductor_ep_overlap_transformer_batch --ngpu 8 - PYTHONPATH=$PWD python torchtitan/experiments/graph_trainer/tests/integration_tests.py /tmp/torchtitan_ep_overlap_integration_20260514_174529 --test_suite graph_trainer_h100 --test_name aot_fx_trace_deepseek_v3_flexattn_full_inductor_ep_overlap_moe_batch --ngpu 8 - PYTHONPATH=$PWD python torchtitan/experiments/graph_trainer/tests/integration_tests.py /tmp/torchtitan_ep_overlap_integration_20260514_174529 --test_suite graph_trainer_h100 --test_name aot_fx_trace_deepseek_v3_flexattn_full_inductor_ep_overlap_moe_seq --ngpu 8 - PYTHONPATH=$PWD python torchtitan/experiments/graph_trainer/tests/integration_tests.py /tmp/torchtitan_ep_overlap_integration_20260514_174529 --test_suite graph_trainer_h100 --test_name aot_fx_trace_deepseek_v3_sdpa_full_inductor_ep_overlap_eager_transformer_batch --ngpu 8 - PYTHONPATH=$PWD python torchtitan/experiments/graph_trainer/tests/integration_tests.py /tmp/torchtitan_ep_overlap_integration_20260514_174529 --test_suite graph_trainer_h100 --test_name aot_fx_trace_deepseek_v3_flexattn_full_inductor_ep_overlap_eager_transformer_batch --ngpu 8 - all 8 H100 integration tests passed stack-info: PR: #3328, branch: sanketpurandare/stack/14
Add the scheduling layer for graph_trainer's public ep_overlap pass. The graph and eager chunking producers create correctness-preserving chunked graphs; this commit consumes their shared chunk metadata after FSDP bucketing and reorders EP dispatch/combine phases so paired chunk all-to-all launches can run before their delayed wait suffixes. The scheduling logic lives in ep_overlap_pass.py and is intentionally separate from chunking. Its input contract is an already chunked graph with exactly two chunks per selected region, chunk body nodes tagged with chunk_id and chunked_region metadata, and MoE dispatcher regions annotated with custom EP metadata for dispatch and combine. The scheduler validates the chunk metadata, uses the last all-to-all in each EP phase as the overlap boundary, annotates delayed wait suffixes with EP_wait=True, and applies a priority topological sort. It does not duplicate nodes, delete nodes, split tensors, concatenate tensors, or otherwise change tensor values. For forward dispatch, the overlap boundary is deliberately the final token-exchange all-to-all, not the earlier split-size exchange. Forward regions schedule dispatch then combine. Backward autograd sees combine gradients before dispatch gradients, so the scheduler derives the observed EP phase chunk order instead of imposing a hardcoded chunk order. Wire the public ep_overlap pipeline as two stages: chunking runs before memory/offload/remat and bucketing, while scheduling runs after downstream FSDP bucketing/reordering. This lets distributed bucketing place shared full-value waits first, then lets the EP scheduler establish the final EP launch/wait order. Add focused scheduler tests and H100 full-Inductor integration coverage for graph chunking and eager chunking across SDPA and FlexAttention debug-model variants. The distributed bitwise numerics tests introduced with graph chunking cover this composed public ep_overlap path because scheduling is value-preserving. This pass stack relies on pending PyTorch support for hinted unbacked symbolic dimensions in the tracing and distributed compiler paths: - FakeTensor folded matmul: pytorch/pytorch#183397 - ProxyTensor SDPA tracing: pytorch/pytorch#183398 - Inductor bucketing trace isolation from ambient unbacked symbols: pytorch/pytorch#183495 - Inductor collective bucketing with hinted unbacked SymInts: pytorch/pytorch#183544 - DTensor sharding padding for hinted even unbacked shards: pytorch/pytorch#183545 - HOP fake traces with discarded unbacked symbols: pytorch/pytorch#183837 - FlexAttention chunked unbacked input extents: pytorch/pytorch#183838 - FakeTensor trace metadata for hinted symbolic storage: pytorch/pytorch#183839 - Inductor symbolic stride ordering with unbacked hints: pytorch/pytorch#183840 Test Plan: - pytest -q torchtitan/experiments/graph_trainer/tests/test_passes.py - 84 passed, 1 skipped, 14 warnings, 5 subtests passed - pytest -q torchtitan/experiments/graph_trainer/tests/test_numerics.py -k ep_overlap - PYTHONPATH=$PWD python torchtitan/experiments/graph_trainer/tests/integration_tests.py /tmp/torchtitan_ep_overlap_integration_20260514_174529 --test_suite graph_trainer_h100 --test_name aot_fx_trace_deepseek_v3_sdpa_full_inductor_ep_overlap_transformer_batch --ngpu 8 - PYTHONPATH=$PWD python torchtitan/experiments/graph_trainer/tests/integration_tests.py /tmp/torchtitan_ep_overlap_integration_20260514_174529 --test_suite graph_trainer_h100 --test_name aot_fx_trace_deepseek_v3_sdpa_full_inductor_ep_overlap_moe_batch --ngpu 8 - PYTHONPATH=$PWD python torchtitan/experiments/graph_trainer/tests/integration_tests.py /tmp/torchtitan_ep_overlap_integration_20260514_174529 --test_suite graph_trainer_h100 --test_name aot_fx_trace_deepseek_v3_sdpa_full_inductor_ep_overlap_moe_seq --ngpu 8 - PYTHONPATH=$PWD python torchtitan/experiments/graph_trainer/tests/integration_tests.py /tmp/torchtitan_ep_overlap_integration_20260514_174529 --test_suite graph_trainer_h100 --test_name aot_fx_trace_deepseek_v3_flexattn_full_inductor_ep_overlap_transformer_batch --ngpu 8 - PYTHONPATH=$PWD python torchtitan/experiments/graph_trainer/tests/integration_tests.py /tmp/torchtitan_ep_overlap_integration_20260514_174529 --test_suite graph_trainer_h100 --test_name aot_fx_trace_deepseek_v3_flexattn_full_inductor_ep_overlap_moe_batch --ngpu 8 - PYTHONPATH=$PWD python torchtitan/experiments/graph_trainer/tests/integration_tests.py /tmp/torchtitan_ep_overlap_integration_20260514_174529 --test_suite graph_trainer_h100 --test_name aot_fx_trace_deepseek_v3_flexattn_full_inductor_ep_overlap_moe_seq --ngpu 8 - PYTHONPATH=$PWD python torchtitan/experiments/graph_trainer/tests/integration_tests.py /tmp/torchtitan_ep_overlap_integration_20260514_174529 --test_suite graph_trainer_h100 --test_name aot_fx_trace_deepseek_v3_sdpa_full_inductor_ep_overlap_eager_transformer_batch --ngpu 8 - PYTHONPATH=$PWD python torchtitan/experiments/graph_trainer/tests/integration_tests.py /tmp/torchtitan_ep_overlap_integration_20260514_174529 --test_suite graph_trainer_h100 --test_name aot_fx_trace_deepseek_v3_flexattn_full_inductor_ep_overlap_eager_transformer_batch --ngpu 8 - all 8 H100 integration tests passed stack-info: PR: #3328, branch: sanketpurandare/stack/14
) Stacked PRs: * pytorch#183545 * pytorch#183544 * pytorch#183495 * pytorch#183398 * __->__#183397 --- --- --- ### [ATen][FakeTensor] Handle unbacked dims in folded matmul The folded matmul path used for ND @ 1D/2D tensors was still forcing concrete sizes in two places: the empty-tensor check used numel(), and the fold/view path built concrete DimVector shapes from sizes(). With unbacked input dimensions, both paths can require specializing a data-dependent symbol even though the operation can be represented symbolically. Keep the folded path symbolic by using sym_numel(), sym_sizes(), sym_strides(), reshape_symint(), _unsafe_view_symint(), and symbolic output resize. The contiguity predicate now uses symbolic equality guarded through TORCH_GUARD_OR_FALSE instead of forcing concrete stride/shape integers. Also let fake view metadata recover from hinted unbacked contiguity relations by emitting symbolic equality checks for stride relations that are true at the traced hint. This handles shapes such as 2 * (u0 // 2) with a stride expressed through u0 without specializing u0 to a concrete value. Add fake tensor regression tests for rank-3 linear with an unbacked batch dimension and hinted unbacked view contiguity. Test Plan: python test/test_fake_tensor.py FakeTensorTest.test_linear_rank3_unbacked_batch_dim FakeTensorTest.test_view_unbacked_contiguous_relation_from_hints -v lintrunner --config=.lintrunner.toml aten/src/ATen/native/LinearAlgebra.cpp torch/_decomp/decompositions.py torch/_subclasses/fake_impls.py test/test_fake_tensor.py Fixes pytorch/torchtitan#3322 Pull Request resolved: pytorch#183397 Approved by: https://github.com/laithsakka
Add the scheduling layer for graph_trainer's public ep_overlap pass. The graph and eager chunking producers create correctness-preserving chunked graphs; this commit consumes their shared chunk metadata after FSDP bucketing and reorders EP dispatch/combine phases so paired chunk all-to-all launches can run before their delayed wait suffixes. The scheduling logic lives in ep_overlap_pass.py and is intentionally separate from chunking. Its input contract is an already chunked graph with exactly two chunks per selected region, chunk body nodes tagged with chunk_id and chunked_region metadata, and MoE dispatcher regions annotated with custom EP metadata for dispatch and combine. The scheduler validates the chunk metadata, uses the last all-to-all in each EP phase as the overlap boundary, annotates delayed wait suffixes with EP_wait=True, and applies a priority topological sort. It does not duplicate nodes, delete nodes, split tensors, concatenate tensors, or otherwise change tensor values. For forward dispatch, the overlap boundary is deliberately the final token-exchange all-to-all, not the earlier split-size exchange. Forward regions schedule dispatch then combine. Backward autograd sees combine gradients before dispatch gradients, so the scheduler derives the observed EP phase chunk order instead of imposing a hardcoded chunk order. Wire the public ep_overlap pipeline as two stages: chunking runs before memory/offload/remat and bucketing, while scheduling runs after downstream FSDP bucketing/reordering. This lets distributed bucketing place shared full-value waits first, then lets the EP scheduler establish the final EP launch/wait order. Add focused scheduler tests and H100 full-Inductor integration coverage for graph chunking and eager chunking across SDPA and FlexAttention debug-model variants. The distributed bitwise numerics tests introduced with graph chunking cover this composed public ep_overlap path because scheduling is value-preserving. This pass stack relies on pending PyTorch support for hinted unbacked symbolic dimensions in the tracing and distributed compiler paths: - FakeTensor folded matmul: pytorch/pytorch#183397 - ProxyTensor SDPA tracing: pytorch/pytorch#183398 - Inductor bucketing trace isolation from ambient unbacked symbols: pytorch/pytorch#183495 - Inductor collective bucketing with hinted unbacked SymInts: pytorch/pytorch#183544 - DTensor sharding padding for hinted even unbacked shards: pytorch/pytorch#183545 - HOP fake traces with discarded unbacked symbols: pytorch/pytorch#183837 - FlexAttention chunked unbacked input extents: pytorch/pytorch#183838 - FakeTensor trace metadata for hinted symbolic storage: pytorch/pytorch#183839 - Inductor symbolic stride ordering with unbacked hints: pytorch/pytorch#183840 Test Plan: - pytest -q torchtitan/experiments/graph_trainer/tests/test_passes.py - 84 passed, 1 skipped, 14 warnings, 5 subtests passed - pytest -q torchtitan/experiments/graph_trainer/tests/test_numerics.py -k ep_overlap - PYTHONPATH=$PWD python torchtitan/experiments/graph_trainer/tests/integration_tests.py /tmp/torchtitan_ep_overlap_integration_20260514_174529 --test_suite graph_trainer_h100 --test_name aot_fx_trace_deepseek_v3_sdpa_full_inductor_ep_overlap_transformer_batch --ngpu 8 - PYTHONPATH=$PWD python torchtitan/experiments/graph_trainer/tests/integration_tests.py /tmp/torchtitan_ep_overlap_integration_20260514_174529 --test_suite graph_trainer_h100 --test_name aot_fx_trace_deepseek_v3_sdpa_full_inductor_ep_overlap_moe_batch --ngpu 8 - PYTHONPATH=$PWD python torchtitan/experiments/graph_trainer/tests/integration_tests.py /tmp/torchtitan_ep_overlap_integration_20260514_174529 --test_suite graph_trainer_h100 --test_name aot_fx_trace_deepseek_v3_sdpa_full_inductor_ep_overlap_moe_seq --ngpu 8 - PYTHONPATH=$PWD python torchtitan/experiments/graph_trainer/tests/integration_tests.py /tmp/torchtitan_ep_overlap_integration_20260514_174529 --test_suite graph_trainer_h100 --test_name aot_fx_trace_deepseek_v3_flexattn_full_inductor_ep_overlap_transformer_batch --ngpu 8 - PYTHONPATH=$PWD python torchtitan/experiments/graph_trainer/tests/integration_tests.py /tmp/torchtitan_ep_overlap_integration_20260514_174529 --test_suite graph_trainer_h100 --test_name aot_fx_trace_deepseek_v3_flexattn_full_inductor_ep_overlap_moe_batch --ngpu 8 - PYTHONPATH=$PWD python torchtitan/experiments/graph_trainer/tests/integration_tests.py /tmp/torchtitan_ep_overlap_integration_20260514_174529 --test_suite graph_trainer_h100 --test_name aot_fx_trace_deepseek_v3_flexattn_full_inductor_ep_overlap_moe_seq --ngpu 8 - PYTHONPATH=$PWD python torchtitan/experiments/graph_trainer/tests/integration_tests.py /tmp/torchtitan_ep_overlap_integration_20260514_174529 --test_suite graph_trainer_h100 --test_name aot_fx_trace_deepseek_v3_sdpa_full_inductor_ep_overlap_eager_transformer_batch --ngpu 8 - PYTHONPATH=$PWD python torchtitan/experiments/graph_trainer/tests/integration_tests.py /tmp/torchtitan_ep_overlap_integration_20260514_174529 --test_suite graph_trainer_h100 --test_name aot_fx_trace_deepseek_v3_flexattn_full_inductor_ep_overlap_eager_transformer_batch --ngpu 8 - all 8 H100 integration tests passed stack-info: PR: #3328, branch: sanketpurandare/stack/14
Add the scheduling layer for graph_trainer's public ep_overlap pass. The graph and eager chunking producers create correctness-preserving chunked graphs; this commit consumes their shared chunk metadata after FSDP bucketing and reorders EP dispatch/combine phases so paired chunk all-to-all launches can run before their delayed wait suffixes. The scheduling logic lives in ep_overlap_pass.py and is intentionally separate from chunking. Its input contract is an already chunked graph with exactly two chunks per selected region, chunk body nodes tagged with chunk_id and chunked_region metadata, and MoE dispatcher regions annotated with custom EP metadata for dispatch and combine. The scheduler validates the chunk metadata, uses the last all-to-all in each EP phase as the overlap boundary, annotates delayed wait suffixes with EP_wait=True, and applies a priority topological sort. It does not duplicate nodes, delete nodes, split tensors, concatenate tensors, or otherwise change tensor values. For forward dispatch, the overlap boundary is deliberately the final token-exchange all-to-all, not the earlier split-size exchange. Forward regions schedule dispatch then combine. Backward autograd sees combine gradients before dispatch gradients, so the scheduler derives the observed EP phase chunk order instead of imposing a hardcoded chunk order. Wire the public ep_overlap pipeline as two stages: chunking runs before memory/offload/remat and bucketing, while scheduling runs after downstream FSDP bucketing/reordering. This lets distributed bucketing place shared full-value waits first, then lets the EP scheduler establish the final EP launch/wait order. Add focused scheduler tests and H100 full-Inductor integration coverage for graph chunking and eager chunking across SDPA and FlexAttention debug-model variants. The distributed bitwise numerics tests introduced with graph chunking cover this composed public ep_overlap path because scheduling is value-preserving. This pass stack relies on pending PyTorch support for hinted unbacked symbolic dimensions in the tracing and distributed compiler paths: - FakeTensor folded matmul: pytorch/pytorch#183397 - ProxyTensor SDPA tracing: pytorch/pytorch#183398 - Inductor bucketing trace isolation from ambient unbacked symbols: pytorch/pytorch#183495 - Inductor collective bucketing with hinted unbacked SymInts: pytorch/pytorch#183544 - DTensor sharding padding for hinted even unbacked shards: pytorch/pytorch#183545 - HOP fake traces with discarded unbacked symbols: pytorch/pytorch#183837 - FlexAttention chunked unbacked input extents: pytorch/pytorch#183838 - FakeTensor trace metadata for hinted symbolic storage: pytorch/pytorch#183839 - Inductor symbolic stride ordering with unbacked hints: pytorch/pytorch#183840 Test Plan: - pytest -q torchtitan/experiments/graph_trainer/tests/test_passes.py - 84 passed, 1 skipped, 14 warnings, 5 subtests passed - pytest -q torchtitan/experiments/graph_trainer/tests/test_numerics.py -k ep_overlap - PYTHONPATH=$PWD python torchtitan/experiments/graph_trainer/tests/integration_tests.py /tmp/torchtitan_ep_overlap_integration_20260514_174529 --test_suite graph_trainer_h100 --test_name aot_fx_trace_deepseek_v3_sdpa_full_inductor_ep_overlap_transformer_batch --ngpu 8 - PYTHONPATH=$PWD python torchtitan/experiments/graph_trainer/tests/integration_tests.py /tmp/torchtitan_ep_overlap_integration_20260514_174529 --test_suite graph_trainer_h100 --test_name aot_fx_trace_deepseek_v3_sdpa_full_inductor_ep_overlap_moe_batch --ngpu 8 - PYTHONPATH=$PWD python torchtitan/experiments/graph_trainer/tests/integration_tests.py /tmp/torchtitan_ep_overlap_integration_20260514_174529 --test_suite graph_trainer_h100 --test_name aot_fx_trace_deepseek_v3_sdpa_full_inductor_ep_overlap_moe_seq --ngpu 8 - PYTHONPATH=$PWD python torchtitan/experiments/graph_trainer/tests/integration_tests.py /tmp/torchtitan_ep_overlap_integration_20260514_174529 --test_suite graph_trainer_h100 --test_name aot_fx_trace_deepseek_v3_flexattn_full_inductor_ep_overlap_transformer_batch --ngpu 8 - PYTHONPATH=$PWD python torchtitan/experiments/graph_trainer/tests/integration_tests.py /tmp/torchtitan_ep_overlap_integration_20260514_174529 --test_suite graph_trainer_h100 --test_name aot_fx_trace_deepseek_v3_flexattn_full_inductor_ep_overlap_moe_batch --ngpu 8 - PYTHONPATH=$PWD python torchtitan/experiments/graph_trainer/tests/integration_tests.py /tmp/torchtitan_ep_overlap_integration_20260514_174529 --test_suite graph_trainer_h100 --test_name aot_fx_trace_deepseek_v3_flexattn_full_inductor_ep_overlap_moe_seq --ngpu 8 - PYTHONPATH=$PWD python torchtitan/experiments/graph_trainer/tests/integration_tests.py /tmp/torchtitan_ep_overlap_integration_20260514_174529 --test_suite graph_trainer_h100 --test_name aot_fx_trace_deepseek_v3_sdpa_full_inductor_ep_overlap_eager_transformer_batch --ngpu 8 - PYTHONPATH=$PWD python torchtitan/experiments/graph_trainer/tests/integration_tests.py /tmp/torchtitan_ep_overlap_integration_20260514_174529 --test_suite graph_trainer_h100 --test_name aot_fx_trace_deepseek_v3_flexattn_full_inductor_ep_overlap_eager_transformer_batch --ngpu 8 - all 8 H100 integration tests passed stack-info: PR: #3328, branch: sanketpurandare/stack/14
Add the scheduling layer for graph_trainer's public ep_overlap pass. Graph and eager chunking producers create correctness-preserving chunked graphs; this commit consumes their shared chunk metadata after FSDP bucketing and reorders EP token-exchange regions to expose communication/compute overlap without changing tensor values. The scheduling logic lives in ep_overlap_pass.py and is intentionally separate from chunking. Its input contract is an already chunked graph with exactly two chunks per selected region, chunk body nodes tagged with chunk_id and chunked_region metadata, and true EP token-exchange markers on _c10d_functional.all_to_all_single.default nodes via custom[EP_token_exchange]. Generic MoE dispatch/combine traceback annotations are sanitized and are not scheduling markers. The scheduler validates that both chunks have the same token-exchange signature, annotates each token-exchange wait with EP_token_exchange_wait, and emits a wait-gated schedule. For each token-exchange pair it emits the launch dependency closure in chunk order, then emits ready non-wait filler work that can run while the previous token exchange is outstanding, and only then allows the required wait/tail work. Forward uses chunk order 0 then 1; backward uses chunk order 1 then 0. All nodes are emitted exactly once through a global topological emitter, and the pass does not duplicate, delete, split, concatenate, or otherwise compute tensor values. Wire the public ep_overlap pipeline as graph/eager chunking, FSDP process-group isolation and bucketing, EP scheduling, chunk-symbol concretization, optional async TP fusion, and DTensor metadata cleanup. Add focused scheduler tests and H100 integration coverage for graph and eager chunking across SDPA and FlexAttention debug-model variants. The distributed bitwise numerics tests introduced with graph chunking cover this composed public ep_overlap path because scheduling is value-preserving. This pass stack relies on PyTorch support for hinted unbacked symbolic dimensions in the tracing and distributed compiler paths: - FakeTensor folded matmul: pytorch/pytorch#183397 - ProxyTensor SDPA tracing: pytorch/pytorch#183398 - Inductor bucketing trace isolation from ambient unbacked symbols: pytorch/pytorch#183495 - Inductor collective bucketing with hinted unbacked SymInts: pytorch/pytorch#183544 - DTensor sharding padding for hinted even unbacked shards: pytorch/pytorch#183545 - HOP fake traces with discarded unbacked symbols: pytorch/pytorch#183837 - FlexAttention chunked unbacked input extents: pytorch/pytorch#183838 - FakeTensor trace metadata for hinted symbolic storage: pytorch/pytorch#183839 - Inductor symbolic stride ordering with unbacked hints: pytorch/pytorch#183840 - Inductor TP slice/cat collective fusion: pytorch/pytorch#184833 Test Plan: - pytest -q torchtitan/experiments/graph_trainer/tests/test_passes.py - pytest -q torchtitan/experiments/graph_trainer/tests/test_numerics.py -k ep_overlap - PYTHONPATH=$PWD python torchtitan/experiments/graph_trainer/tests/integration_tests.py <out_dir> --test_suite graph_trainer_h100 --test_name aot_fx_trace_deepseek_v3_sdpa_full_inductor_ep_overlap_transformer_batch --ngpu 8 - PYTHONPATH=$PWD python torchtitan/experiments/graph_trainer/tests/integration_tests.py <out_dir> --test_suite graph_trainer_h100 --test_name aot_fx_trace_deepseek_v3_sdpa_full_inductor_ep_overlap_moe_batch --ngpu 8 - PYTHONPATH=$PWD python torchtitan/experiments/graph_trainer/tests/integration_tests.py <out_dir> --test_suite graph_trainer_h100 --test_name aot_fx_trace_deepseek_v3_sdpa_full_inductor_ep_overlap_moe_seq --ngpu 8 - PYTHONPATH=$PWD python torchtitan/experiments/graph_trainer/tests/integration_tests.py <out_dir> --test_suite graph_trainer_h100 --test_name aot_fx_trace_deepseek_v3_flexattn_full_inductor_ep_overlap_transformer_batch --ngpu 8 - PYTHONPATH=$PWD python torchtitan/experiments/graph_trainer/tests/integration_tests.py <out_dir> --test_suite graph_trainer_h100 --test_name aot_fx_trace_deepseek_v3_flexattn_full_inductor_ep_overlap_moe_batch --ngpu 8 - PYTHONPATH=$PWD python torchtitan/experiments/graph_trainer/tests/integration_tests.py <out_dir> --test_suite graph_trainer_h100 --test_name aot_fx_trace_deepseek_v3_flexattn_full_inductor_ep_overlap_moe_seq --ngpu 8 - PYTHONPATH=$PWD python torchtitan/experiments/graph_trainer/tests/integration_tests.py <out_dir> --test_suite graph_trainer_h100 --test_name aot_fx_trace_deepseek_v3_sdpa_full_inductor_ep_overlap_eager_transformer_batch --ngpu 8 - PYTHONPATH=$PWD python torchtitan/experiments/graph_trainer/tests/integration_tests.py <out_dir> --test_suite graph_trainer_h100 --test_name aot_fx_trace_deepseek_v3_flexattn_full_inductor_ep_overlap_eager_transformer_batch --ngpu 8 stack-info: PR: #3328, branch: sanketpurandare/stack/14
Add the scheduling layer for graph_trainer's public ep_overlap pass. Graph and eager chunking producers create correctness-preserving chunked graphs; this commit consumes their shared chunk metadata after FSDP bucketing and reorders EP token-exchange regions to expose communication/compute overlap without changing tensor values. The scheduling logic lives in ep_overlap_pass.py and is intentionally separate from chunking. Its input contract is an already chunked graph with exactly two chunks per selected region, chunk body nodes tagged with chunk_id and chunked_region metadata, and true EP token-exchange markers on _c10d_functional.all_to_all_single.default nodes via custom[EP_token_exchange]. Generic MoE dispatch/combine traceback annotations are sanitized and are not scheduling markers. The scheduler validates that both chunks have the same token-exchange signature, annotates each token-exchange wait with EP_token_exchange_wait, and emits a wait-gated schedule. For each token-exchange pair it emits the launch dependency closure in chunk order, then emits ready non-wait filler work that can run while the previous token exchange is outstanding, and only then allows the required wait/tail work. Forward uses chunk order 0 then 1; backward uses chunk order 1 then 0. All nodes are emitted exactly once through a global topological emitter, and the pass does not duplicate, delete, split, concatenate, or otherwise compute tensor values. Wire the public ep_overlap pipeline as graph/eager chunking, FSDP process-group isolation and bucketing, EP scheduling, chunk-symbol concretization, optional async TP fusion, and DTensor metadata cleanup. Add focused scheduler tests and H100 integration coverage for graph and eager chunking across SDPA and FlexAttention debug-model variants. The distributed bitwise numerics tests introduced with graph chunking cover this composed public ep_overlap path because scheduling is value-preserving. This pass stack relies on PyTorch support for hinted unbacked symbolic dimensions in the tracing and distributed compiler paths: - FakeTensor folded matmul: pytorch/pytorch#183397 - ProxyTensor SDPA tracing: pytorch/pytorch#183398 - Inductor bucketing trace isolation from ambient unbacked symbols: pytorch/pytorch#183495 - Inductor collective bucketing with hinted unbacked SymInts: pytorch/pytorch#183544 - DTensor sharding padding for hinted even unbacked shards: pytorch/pytorch#183545 - HOP fake traces with discarded unbacked symbols: pytorch/pytorch#183837 - FlexAttention chunked unbacked input extents: pytorch/pytorch#183838 - FakeTensor trace metadata for hinted symbolic storage: pytorch/pytorch#183839 - Inductor symbolic stride ordering with unbacked hints: pytorch/pytorch#183840 - Inductor TP slice/cat collective fusion: pytorch/pytorch#184833 Test Plan: - pytest -q torchtitan/experiments/graph_trainer/tests/test_passes.py - pytest -q torchtitan/experiments/graph_trainer/tests/test_numerics.py -k ep_overlap - PYTHONPATH=$PWD python torchtitan/experiments/graph_trainer/tests/integration_tests.py <out_dir> --test_suite graph_trainer_h100 --test_name aot_fx_trace_deepseek_v3_sdpa_full_inductor_ep_overlap_transformer_batch --ngpu 8 - PYTHONPATH=$PWD python torchtitan/experiments/graph_trainer/tests/integration_tests.py <out_dir> --test_suite graph_trainer_h100 --test_name aot_fx_trace_deepseek_v3_sdpa_full_inductor_ep_overlap_moe_batch --ngpu 8 - PYTHONPATH=$PWD python torchtitan/experiments/graph_trainer/tests/integration_tests.py <out_dir> --test_suite graph_trainer_h100 --test_name aot_fx_trace_deepseek_v3_sdpa_full_inductor_ep_overlap_moe_seq --ngpu 8 - PYTHONPATH=$PWD python torchtitan/experiments/graph_trainer/tests/integration_tests.py <out_dir> --test_suite graph_trainer_h100 --test_name aot_fx_trace_deepseek_v3_flexattn_full_inductor_ep_overlap_transformer_batch --ngpu 8 - PYTHONPATH=$PWD python torchtitan/experiments/graph_trainer/tests/integration_tests.py <out_dir> --test_suite graph_trainer_h100 --test_name aot_fx_trace_deepseek_v3_flexattn_full_inductor_ep_overlap_moe_batch --ngpu 8 - PYTHONPATH=$PWD python torchtitan/experiments/graph_trainer/tests/integration_tests.py <out_dir> --test_suite graph_trainer_h100 --test_name aot_fx_trace_deepseek_v3_flexattn_full_inductor_ep_overlap_moe_seq --ngpu 8 - PYTHONPATH=$PWD python torchtitan/experiments/graph_trainer/tests/integration_tests.py <out_dir> --test_suite graph_trainer_h100 --test_name aot_fx_trace_deepseek_v3_sdpa_full_inductor_ep_overlap_eager_transformer_batch --ngpu 8 - PYTHONPATH=$PWD python torchtitan/experiments/graph_trainer/tests/integration_tests.py <out_dir> --test_suite graph_trainer_h100 --test_name aot_fx_trace_deepseek_v3_flexattn_full_inductor_ep_overlap_eager_transformer_batch --ngpu 8 stack-info: PR: #3328, branch: sanketpurandare/stack/14
Add the scheduling layer for graph_trainer's public ep_overlap pass. Graph and eager chunking producers create correctness-preserving chunked graphs; this commit consumes their shared chunk metadata after FSDP bucketing and reorders EP token-exchange regions to expose communication/compute overlap without changing tensor values. The scheduling logic lives in ep_overlap_pass.py and is intentionally separate from chunking. Its input contract is an already chunked graph with exactly two chunks per selected region, chunk body nodes tagged with chunk_id and chunked_region metadata, and true EP token-exchange markers on _c10d_functional.all_to_all_single.default nodes via custom[EP_token_exchange]. Generic MoE dispatch/combine traceback annotations are sanitized and are not scheduling markers. The scheduler validates that both chunks have the same token-exchange signature, annotates each token-exchange wait with EP_token_exchange_wait, and emits a wait-gated schedule. For each token-exchange pair it emits the launch dependency closure in chunk order, then emits ready non-wait filler work that can run while the previous token exchange is outstanding, and only then allows the required wait/tail work. Forward uses chunk order 0 then 1; backward uses chunk order 1 then 0. All nodes are emitted exactly once through a global topological emitter, and the pass does not duplicate, delete, split, concatenate, or otherwise compute tensor values. Wire the public ep_overlap pipeline as graph/eager chunking, FSDP process-group isolation and bucketing, EP scheduling, chunk-symbol concretization, optional async TP fusion, and DTensor metadata cleanup. Add focused scheduler tests and H100 integration coverage for graph and eager chunking across SDPA and FlexAttention debug-model variants. The distributed bitwise numerics tests introduced with graph chunking cover this composed public ep_overlap path because scheduling is value-preserving. This pass stack relies on PyTorch support for hinted unbacked symbolic dimensions in the tracing and distributed compiler paths: - FakeTensor folded matmul: pytorch/pytorch#183397 - ProxyTensor SDPA tracing: pytorch/pytorch#183398 - Inductor bucketing trace isolation from ambient unbacked symbols: pytorch/pytorch#183495 - Inductor collective bucketing with hinted unbacked SymInts: pytorch/pytorch#183544 - DTensor sharding padding for hinted even unbacked shards: pytorch/pytorch#183545 - HOP fake traces with discarded unbacked symbols: pytorch/pytorch#183837 - FlexAttention chunked unbacked input extents: pytorch/pytorch#183838 - FakeTensor trace metadata for hinted symbolic storage: pytorch/pytorch#183839 - Inductor symbolic stride ordering with unbacked hints: pytorch/pytorch#183840 - Inductor TP slice/cat collective fusion: pytorch/pytorch#184833 Test Plan: - pytest -q torchtitan/experiments/graph_trainer/tests/test_passes.py - pytest -q torchtitan/experiments/graph_trainer/tests/test_numerics.py -k ep_overlap - PYTHONPATH=$PWD python torchtitan/experiments/graph_trainer/tests/integration_tests.py <out_dir> --test_suite graph_trainer_h100 --test_name aot_fx_trace_deepseek_v3_sdpa_full_inductor_ep_overlap_transformer_batch --ngpu 8 - PYTHONPATH=$PWD python torchtitan/experiments/graph_trainer/tests/integration_tests.py <out_dir> --test_suite graph_trainer_h100 --test_name aot_fx_trace_deepseek_v3_sdpa_full_inductor_ep_overlap_moe_batch --ngpu 8 - PYTHONPATH=$PWD python torchtitan/experiments/graph_trainer/tests/integration_tests.py <out_dir> --test_suite graph_trainer_h100 --test_name aot_fx_trace_deepseek_v3_sdpa_full_inductor_ep_overlap_moe_seq --ngpu 8 - PYTHONPATH=$PWD python torchtitan/experiments/graph_trainer/tests/integration_tests.py <out_dir> --test_suite graph_trainer_h100 --test_name aot_fx_trace_deepseek_v3_flexattn_full_inductor_ep_overlap_transformer_batch --ngpu 8 - PYTHONPATH=$PWD python torchtitan/experiments/graph_trainer/tests/integration_tests.py <out_dir> --test_suite graph_trainer_h100 --test_name aot_fx_trace_deepseek_v3_flexattn_full_inductor_ep_overlap_moe_batch --ngpu 8 - PYTHONPATH=$PWD python torchtitan/experiments/graph_trainer/tests/integration_tests.py <out_dir> --test_suite graph_trainer_h100 --test_name aot_fx_trace_deepseek_v3_flexattn_full_inductor_ep_overlap_moe_seq --ngpu 8 - PYTHONPATH=$PWD python torchtitan/experiments/graph_trainer/tests/integration_tests.py <out_dir> --test_suite graph_trainer_h100 --test_name aot_fx_trace_deepseek_v3_sdpa_full_inductor_ep_overlap_eager_transformer_batch --ngpu 8 - PYTHONPATH=$PWD python torchtitan/experiments/graph_trainer/tests/integration_tests.py <out_dir> --test_suite graph_trainer_h100 --test_name aot_fx_trace_deepseek_v3_flexattn_full_inductor_ep_overlap_eager_transformer_batch --ngpu 8 stack-info: PR: #3328, branch: sanketpurandare/stack/14
Introduce the public graph_trainer EP-overlap configuration surface and the eager chunking producer for its chunk metadata contract. The new compile options select the logical chunk dimension, the chunking strategy, and one supported module-root pattern: all transformer blocks or all MoE blocks. Sequence chunking is limited to MoE block roots because attention needs full K/V context. Keep EP overlap validation in configs.py next to the other graph_trainer compile config validation. The eager producer wraps selected module forwards during model parallelization, splits tensor inputs into two chunks, calls the original forward once per chunk, and materializes tensor outputs with cat. It emits the same chunk metadata that graph chunking will emit, so the later scheduling pass can consume either producer through one contract. Add shared MoE EP region annotations for dispatcher dispatch/combine bodies, config fingerprinting for the new options, and a generic trace-input-preparation hook in GraphTrainer. This commit does not add graph chunking or communication-overlap scheduling. This pass stack relies on pending PyTorch support for hinted unbacked symbolic dimensions in the tracing and distributed compiler paths: - FakeTensor folded matmul: pytorch/pytorch#183397 - ProxyTensor SDPA tracing: pytorch/pytorch#183398 - Inductor bucketing trace isolation from ambient unbacked symbols: pytorch/pytorch#183495 - Inductor collective bucketing with hinted unbacked SymInts: pytorch/pytorch#183544 - DTensor sharding padding for hinted even unbacked shards: pytorch/pytorch#183545 - HOP fake traces with discarded unbacked symbols: pytorch/pytorch#183837 - FlexAttention chunked unbacked input extents: pytorch/pytorch#183838 - FakeTensor trace metadata for hinted symbolic storage: pytorch/pytorch#183839 - Inductor symbolic stride ordering with unbacked hints: pytorch/pytorch#183840 Test Plan: - Covered by the full graph_trainer pass, numerics, and H100 integration test runs after the stacked graph chunking and scheduling commits. stack-info: PR: #3363, branch: sanketpurandare/stack/17
Add the graph-level chunking transform used by graph_trainer's EP overlap pipeline. The public opt-in remains --compile.passes ep_overlap, but this commit intentionally only introduces the correctness-preserving chunked dataflow. It does not implement EP communication-overlap scheduling. The chunking pass lives in ep_chunk_pass.py with shared metadata and symbolic-shape helpers in ep_pass_utils.py. It uses the unbacked SymInt introduced by the trace-input dynamic-shape preparation as the source of truth for chunk influence. The pass plans selected forward/backward module regions, splits live-ins whose fake shapes carry the selected symbol, rewrites one chunk body in place, copies the peer chunk body, and materializes escaping full values. Tensor live-outs carrying the selected dimension are concatenated. Backward parameter-gradient live-outs can be accumulated before grad communication as a performance optimization; --compile.ep_overlap_disable_early_grad_accumulation disables that optimization for strict eager-chunk bitwise comparisons. The pass runs after memory policy, CPU offload, and SAC/rematerialization, and before FSDP bucketing. It does not special-case offload or remat nodes; those interactions are represented as ordinary dataflow through live-ins and live-outs. Forward buffer mutations are preserved as chunk-local mutation chains so MoE accounting such as tokens-per-expert remains semantically visible. Chunk-derived symbolic shapes are kept through scheduling and then concretized by concretize_ep_chunk_symbolic_shapes_pass before backend codegen. The eager wrapper remains the numerical reference: selected modules are split into two chunks, the original module forward runs once per chunk, and outputs are combined back. Graph chunking is expected to be bitwise equivalent to eager chunking when early grad accumulation is disabled, including model state such as MoE expert-bias buffers. This pass stack relies on PyTorch support for hinted unbacked symbolic dimensions in the tracing and distributed compiler paths: - FakeTensor folded matmul: pytorch/pytorch#183397 - ProxyTensor SDPA tracing: pytorch/pytorch#183398 - Inductor bucketing trace isolation from ambient unbacked symbols: pytorch/pytorch#183495 - Inductor collective bucketing with hinted unbacked SymInts: pytorch/pytorch#183544 - DTensor sharding padding for hinted even unbacked shards: pytorch/pytorch#183545 - HOP fake traces with discarded unbacked symbols: pytorch/pytorch#183837 - FlexAttention chunked unbacked input extents: pytorch/pytorch#183838 - FakeTensor trace metadata for hinted symbolic storage: pytorch/pytorch#183839 - Inductor symbolic stride ordering with unbacked hints: pytorch/pytorch#183840 - Inductor TP slice/cat collective fusion: pytorch/pytorch#184833 Test Plan: - pytest -q torchtitan/experiments/graph_trainer/tests/test_passes.py - pytest -q torchtitan/experiments/graph_trainer/tests/test_numerics.py -k ep_overlap - python torchtitan/experiments/graph_trainer/tests/test_bitwise_deterministic.py TestDSv3BitwiseDeterministic.test_ep_overlap_graph_matches_eager_chunking stack-info: PR: #3325, branch: sanketpurandare/stack/12
Add the scheduling layer for graph_trainer's public ep_overlap pass. Graph and eager chunking producers create correctness-preserving chunked graphs; this commit consumes their shared chunk metadata after FSDP bucketing and reorders EP token-exchange regions to expose communication/compute overlap without changing tensor values. The scheduling logic lives in ep_overlap_pass.py and is intentionally separate from chunking. Its input contract is an already chunked graph with exactly two chunks per selected region, chunk body nodes tagged with chunk_id and chunked_region metadata, and true EP token-exchange markers on _c10d_functional.all_to_all_single.default nodes via custom[EP_token_exchange]. Generic MoE dispatch/combine traceback annotations are sanitized and are not scheduling markers. The scheduler validates that both chunks have the same token-exchange signature, annotates each token-exchange wait with EP_token_exchange_wait, and emits a wait-gated schedule. For each token-exchange pair it emits the launch dependency closure in chunk order, then emits ready non-wait filler work that can run while the previous token exchange is outstanding, and only then allows the required wait/tail work. Forward uses chunk order 0 then 1; backward uses chunk order 1 then 0. All nodes are emitted exactly once through a global topological emitter, and the pass does not duplicate, delete, split, concatenate, or otherwise compute tensor values. Wire the public ep_overlap pipeline as graph/eager chunking, FSDP process-group isolation and bucketing, EP scheduling, chunk-symbol concretization, optional async TP fusion, and DTensor metadata cleanup. Add focused scheduler tests and H100 integration coverage for graph and eager chunking across SDPA and FlexAttention debug-model variants. The distributed bitwise numerics tests introduced with graph chunking cover this composed public ep_overlap path because scheduling is value-preserving. This pass stack relies on PyTorch support for hinted unbacked symbolic dimensions in the tracing and distributed compiler paths: - FakeTensor folded matmul: pytorch/pytorch#183397 - ProxyTensor SDPA tracing: pytorch/pytorch#183398 - Inductor bucketing trace isolation from ambient unbacked symbols: pytorch/pytorch#183495 - Inductor collective bucketing with hinted unbacked SymInts: pytorch/pytorch#183544 - DTensor sharding padding for hinted even unbacked shards: pytorch/pytorch#183545 - HOP fake traces with discarded unbacked symbols: pytorch/pytorch#183837 - FlexAttention chunked unbacked input extents: pytorch/pytorch#183838 - FakeTensor trace metadata for hinted symbolic storage: pytorch/pytorch#183839 - Inductor symbolic stride ordering with unbacked hints: pytorch/pytorch#183840 - Inductor TP slice/cat collective fusion: pytorch/pytorch#184833 Test Plan: - pytest -q torchtitan/experiments/graph_trainer/tests/test_passes.py - pytest -q torchtitan/experiments/graph_trainer/tests/test_numerics.py -k ep_overlap - PYTHONPATH=$PWD python torchtitan/experiments/graph_trainer/tests/integration_tests.py <out_dir> --test_suite graph_trainer_h100 --test_name aot_fx_trace_deepseek_v3_sdpa_full_inductor_ep_overlap_transformer_batch --ngpu 8 - PYTHONPATH=$PWD python torchtitan/experiments/graph_trainer/tests/integration_tests.py <out_dir> --test_suite graph_trainer_h100 --test_name aot_fx_trace_deepseek_v3_sdpa_full_inductor_ep_overlap_moe_batch --ngpu 8 - PYTHONPATH=$PWD python torchtitan/experiments/graph_trainer/tests/integration_tests.py <out_dir> --test_suite graph_trainer_h100 --test_name aot_fx_trace_deepseek_v3_sdpa_full_inductor_ep_overlap_moe_seq --ngpu 8 - PYTHONPATH=$PWD python torchtitan/experiments/graph_trainer/tests/integration_tests.py <out_dir> --test_suite graph_trainer_h100 --test_name aot_fx_trace_deepseek_v3_flexattn_full_inductor_ep_overlap_transformer_batch --ngpu 8 - PYTHONPATH=$PWD python torchtitan/experiments/graph_trainer/tests/integration_tests.py <out_dir> --test_suite graph_trainer_h100 --test_name aot_fx_trace_deepseek_v3_flexattn_full_inductor_ep_overlap_moe_batch --ngpu 8 - PYTHONPATH=$PWD python torchtitan/experiments/graph_trainer/tests/integration_tests.py <out_dir> --test_suite graph_trainer_h100 --test_name aot_fx_trace_deepseek_v3_flexattn_full_inductor_ep_overlap_moe_seq --ngpu 8 - PYTHONPATH=$PWD python torchtitan/experiments/graph_trainer/tests/integration_tests.py <out_dir> --test_suite graph_trainer_h100 --test_name aot_fx_trace_deepseek_v3_sdpa_full_inductor_ep_overlap_eager_transformer_batch --ngpu 8 - PYTHONPATH=$PWD python torchtitan/experiments/graph_trainer/tests/integration_tests.py <out_dir> --test_suite graph_trainer_h100 --test_name aot_fx_trace_deepseek_v3_flexattn_full_inductor_ep_overlap_eager_transformer_batch --ngpu 8 stack-info: PR: #3328, branch: sanketpurandare/stack/14
Add the scheduling layer for graph_trainer's public ep_overlap pass. Graph and eager chunking producers create correctness-preserving chunked graphs; this commit consumes their shared chunk metadata after FSDP bucketing and reorders EP token-exchange regions to expose communication/compute overlap without changing tensor values. The scheduling logic lives in ep_overlap_pass.py and is intentionally separate from chunking. Its input contract is an already chunked graph with exactly two chunks per selected region, chunk body nodes tagged with chunk_id and chunked_region metadata, and true EP token-exchange markers on _c10d_functional.all_to_all_single.default nodes via custom[EP_token_exchange]. Generic MoE dispatch/combine traceback annotations are sanitized and are not scheduling markers. The scheduler validates that both chunks have the same token-exchange signature, annotates each token-exchange wait with EP_token_exchange_wait, and emits a wait-gated schedule. For each token-exchange pair it emits the launch dependency closure in chunk order, then emits ready non-wait filler work that can run while the previous token exchange is outstanding, and only then allows the required wait/tail work. Forward uses chunk order 0 then 1; backward uses chunk order 1 then 0. All nodes are emitted exactly once through a global topological emitter, and the pass does not duplicate, delete, split, concatenate, or otherwise compute tensor values. Wire the public ep_overlap pipeline as graph/eager chunking, FSDP process-group isolation and bucketing, EP scheduling, chunk-symbol concretization, optional async TP fusion, and DTensor metadata cleanup. Add focused scheduler tests and H100 integration coverage for graph and eager chunking across SDPA and FlexAttention debug-model variants. The distributed bitwise numerics tests introduced with graph chunking cover this composed public ep_overlap path because scheduling is value-preserving. This pass stack relies on PyTorch support for hinted unbacked symbolic dimensions in the tracing and distributed compiler paths: - FakeTensor folded matmul: pytorch/pytorch#183397 - ProxyTensor SDPA tracing: pytorch/pytorch#183398 - Inductor bucketing trace isolation from ambient unbacked symbols: pytorch/pytorch#183495 - Inductor collective bucketing with hinted unbacked SymInts: pytorch/pytorch#183544 - DTensor sharding padding for hinted even unbacked shards: pytorch/pytorch#183545 - HOP fake traces with discarded unbacked symbols: pytorch/pytorch#183837 - FlexAttention chunked unbacked input extents: pytorch/pytorch#183838 - FakeTensor trace metadata for hinted symbolic storage: pytorch/pytorch#183839 - Inductor symbolic stride ordering with unbacked hints: pytorch/pytorch#183840 - Inductor TP slice/cat collective fusion: pytorch/pytorch#184833 Test Plan: - pytest -q torchtitan/experiments/graph_trainer/tests/test_passes.py - pytest -q torchtitan/experiments/graph_trainer/tests/test_numerics.py -k ep_overlap - PYTHONPATH=$PWD python torchtitan/experiments/graph_trainer/tests/integration_tests.py <out_dir> --test_suite graph_trainer_h100 --test_name aot_fx_trace_deepseek_v3_sdpa_full_inductor_ep_overlap_transformer_batch --ngpu 8 - PYTHONPATH=$PWD python torchtitan/experiments/graph_trainer/tests/integration_tests.py <out_dir> --test_suite graph_trainer_h100 --test_name aot_fx_trace_deepseek_v3_sdpa_full_inductor_ep_overlap_moe_batch --ngpu 8 - PYTHONPATH=$PWD python torchtitan/experiments/graph_trainer/tests/integration_tests.py <out_dir> --test_suite graph_trainer_h100 --test_name aot_fx_trace_deepseek_v3_sdpa_full_inductor_ep_overlap_moe_seq --ngpu 8 - PYTHONPATH=$PWD python torchtitan/experiments/graph_trainer/tests/integration_tests.py <out_dir> --test_suite graph_trainer_h100 --test_name aot_fx_trace_deepseek_v3_flexattn_full_inductor_ep_overlap_transformer_batch --ngpu 8 - PYTHONPATH=$PWD python torchtitan/experiments/graph_trainer/tests/integration_tests.py <out_dir> --test_suite graph_trainer_h100 --test_name aot_fx_trace_deepseek_v3_flexattn_full_inductor_ep_overlap_moe_batch --ngpu 8 - PYTHONPATH=$PWD python torchtitan/experiments/graph_trainer/tests/integration_tests.py <out_dir> --test_suite graph_trainer_h100 --test_name aot_fx_trace_deepseek_v3_flexattn_full_inductor_ep_overlap_moe_seq --ngpu 8 - PYTHONPATH=$PWD python torchtitan/experiments/graph_trainer/tests/integration_tests.py <out_dir> --test_suite graph_trainer_h100 --test_name aot_fx_trace_deepseek_v3_sdpa_full_inductor_ep_overlap_eager_transformer_batch --ngpu 8 - PYTHONPATH=$PWD python torchtitan/experiments/graph_trainer/tests/integration_tests.py <out_dir> --test_suite graph_trainer_h100 --test_name aot_fx_trace_deepseek_v3_flexattn_full_inductor_ep_overlap_eager_transformer_batch --ngpu 8 stack-info: PR: #3328, branch: sanketpurandare/stack/14
Add the scheduling layer for graph_trainer's public ep_overlap pass. Graph and eager chunking producers create correctness-preserving chunked graphs; this commit consumes their shared chunk metadata after FSDP bucketing and reorders EP token-exchange regions to expose communication/compute overlap without changing tensor values. The scheduling logic lives in ep_overlap_pass.py and is intentionally separate from chunking. Its input contract is an already chunked graph with exactly two chunks per selected region, chunk body nodes tagged with chunk_id and chunked_region metadata, and true EP token-exchange markers on _c10d_functional.all_to_all_single.default nodes via custom[EP_token_exchange]. Generic MoE dispatch/combine traceback annotations are sanitized and are not scheduling markers. The scheduler validates that both chunks have the same token-exchange signature, annotates each token-exchange wait with EP_token_exchange_wait, and emits a wait-gated schedule. For each token-exchange pair it emits the launch dependency closure in chunk order, then emits ready non-wait filler work that can run while the previous token exchange is outstanding, and only then allows the required wait/tail work. Forward uses chunk order 0 then 1; backward uses chunk order 1 then 0. All nodes are emitted exactly once through a global topological emitter, and the pass does not duplicate, delete, split, concatenate, or otherwise compute tensor values. Wire the public ep_overlap pipeline as graph/eager chunking, FSDP process-group isolation and bucketing, EP scheduling, chunk-symbol concretization, optional async TP fusion, and DTensor metadata cleanup. Add focused scheduler tests and H100 integration coverage for graph and eager chunking across SDPA and FlexAttention debug-model variants. The distributed bitwise numerics tests introduced with graph chunking cover this composed public ep_overlap path because scheduling is value-preserving. This pass stack relies on PyTorch support for hinted unbacked symbolic dimensions in the tracing and distributed compiler paths: - FakeTensor folded matmul: pytorch/pytorch#183397 - ProxyTensor SDPA tracing: pytorch/pytorch#183398 - Inductor bucketing trace isolation from ambient unbacked symbols: pytorch/pytorch#183495 - Inductor collective bucketing with hinted unbacked SymInts: pytorch/pytorch#183544 - DTensor sharding padding for hinted even unbacked shards: pytorch/pytorch#183545 - HOP fake traces with discarded unbacked symbols: pytorch/pytorch#183837 - FlexAttention chunked unbacked input extents: pytorch/pytorch#183838 - FakeTensor trace metadata for hinted symbolic storage: pytorch/pytorch#183839 - Inductor symbolic stride ordering with unbacked hints: pytorch/pytorch#183840 - Inductor TP slice/cat collective fusion: pytorch/pytorch#184833 Test Plan: - pytest -q torchtitan/experiments/graph_trainer/tests/test_passes.py - pytest -q torchtitan/experiments/graph_trainer/tests/test_numerics.py -k ep_overlap - PYTHONPATH=$PWD python torchtitan/experiments/graph_trainer/tests/integration_tests.py <out_dir> --test_suite graph_trainer_h100 --test_name aot_fx_trace_deepseek_v3_sdpa_full_inductor_ep_overlap_transformer_batch --ngpu 8 - PYTHONPATH=$PWD python torchtitan/experiments/graph_trainer/tests/integration_tests.py <out_dir> --test_suite graph_trainer_h100 --test_name aot_fx_trace_deepseek_v3_sdpa_full_inductor_ep_overlap_moe_batch --ngpu 8 - PYTHONPATH=$PWD python torchtitan/experiments/graph_trainer/tests/integration_tests.py <out_dir> --test_suite graph_trainer_h100 --test_name aot_fx_trace_deepseek_v3_sdpa_full_inductor_ep_overlap_moe_seq --ngpu 8 - PYTHONPATH=$PWD python torchtitan/experiments/graph_trainer/tests/integration_tests.py <out_dir> --test_suite graph_trainer_h100 --test_name aot_fx_trace_deepseek_v3_flexattn_full_inductor_ep_overlap_transformer_batch --ngpu 8 - PYTHONPATH=$PWD python torchtitan/experiments/graph_trainer/tests/integration_tests.py <out_dir> --test_suite graph_trainer_h100 --test_name aot_fx_trace_deepseek_v3_flexattn_full_inductor_ep_overlap_moe_batch --ngpu 8 - PYTHONPATH=$PWD python torchtitan/experiments/graph_trainer/tests/integration_tests.py <out_dir> --test_suite graph_trainer_h100 --test_name aot_fx_trace_deepseek_v3_flexattn_full_inductor_ep_overlap_moe_seq --ngpu 8 - PYTHONPATH=$PWD python torchtitan/experiments/graph_trainer/tests/integration_tests.py <out_dir> --test_suite graph_trainer_h100 --test_name aot_fx_trace_deepseek_v3_sdpa_full_inductor_ep_overlap_eager_transformer_batch --ngpu 8 - PYTHONPATH=$PWD python torchtitan/experiments/graph_trainer/tests/integration_tests.py <out_dir> --test_suite graph_trainer_h100 --test_name aot_fx_trace_deepseek_v3_flexattn_full_inductor_ep_overlap_eager_transformer_batch --ngpu 8 stack-info: PR: #3328, branch: sanketpurandare/stack/14
) Stacked PRs: * pytorch#183545 * pytorch#183544 * pytorch#183495 * pytorch#183398 * __->__#183397 --- --- --- ### [ATen][FakeTensor] Handle unbacked dims in folded matmul The folded matmul path used for ND @ 1D/2D tensors was still forcing concrete sizes in two places: the empty-tensor check used numel(), and the fold/view path built concrete DimVector shapes from sizes(). With unbacked input dimensions, both paths can require specializing a data-dependent symbol even though the operation can be represented symbolically. Keep the folded path symbolic by using sym_numel(), sym_sizes(), sym_strides(), reshape_symint(), _unsafe_view_symint(), and symbolic output resize. The contiguity predicate now uses symbolic equality guarded through TORCH_GUARD_OR_FALSE instead of forcing concrete stride/shape integers. Also let fake view metadata recover from hinted unbacked contiguity relations by emitting symbolic equality checks for stride relations that are true at the traced hint. This handles shapes such as 2 * (u0 // 2) with a stride expressed through u0 without specializing u0 to a concrete value. Add fake tensor regression tests for rank-3 linear with an unbacked batch dimension and hinted unbacked view contiguity. Test Plan: python test/test_fake_tensor.py FakeTensorTest.test_linear_rank3_unbacked_batch_dim FakeTensorTest.test_view_unbacked_contiguous_relation_from_hints -v lintrunner --config=.lintrunner.toml aten/src/ATen/native/LinearAlgebra.cpp torch/_decomp/decompositions.py torch/_subclasses/fake_impls.py test/test_fake_tensor.py Fixes pytorch/torchtitan#3322 Pull Request resolved: pytorch#183397 Approved by: https://github.com/laithsakka
…orch#183398) Stacked PRs: * pytorch#183545 * pytorch#183544 * pytorch#183495 * __->__#183398 --- --- --- ### [ATen][ProxyTensor] Preserve unbacked batch dims in SDPA tracing The general batched matmul path still converted broadcast batch dimensions to concrete int64_t sizes before expanding, reshaping, and viewing through bmm. That breaks tracing for rank-4 inputs with an unbacked batch symbol, including the math scaled-dot-product-attention path, because SDPA lowers through batched matmul. Carry symbolic sizes through the broadcasted bmm path by replacing sizes() and IntArrayRef/DimVector shape plumbing with sym_sizes(), SymDimVector, infer_size_symdimvector(), expand_symint(), reshape_symint(), _unsafe_view_symint(), and symbolic output resize. Keep the existing gradient broadcast shortcut but evaluate its symbolic predicates with guard helpers. Also preserve symbolic size queries during proxy tracing. aten.size.default has a non-symbolic int[] schema, so executing it on a fake tensor with unbacked sizes forces the symbol and can raise GuardOnDataDependentSymNode. When torch-function metadata tracing sees aten.size.default on a tensor with symbolic sizes, redirect it to aten.sym_size.default so downstream users receive symbolic size proxies instead of forcing concrete integers. This covers cuDNN SDPA fake outputs whose batch dimension remains symbolic. Add fake tensor regressions for rank-4 matmul, math SDPA, symbolic aten.size.default tracing, and cuDNN SDPA fake output sizes with an unbacked batch dimension. Test Plan: python test/test_fake_tensor.py FakeTensorTest.test_linear_rank3_unbacked_batch_dim FakeTensorTest.test_matmul_rank4_unbacked_batch_dim FakeTensorTest.test_sdpa_math_unbacked_batch_dim FakeTensorTest.test_size_default_unbacked_batch_dim FakeTensorTest.test_cudnn_sdpa_unbacked_batch_dim pytest test/test_fake_tensor.py -k 'linear_rank3_unbacked_batch_dim or matmul_rank4_unbacked_batch_dim or sdpa_math_unbacked_batch_dim or size_default_unbacked_batch_dim or cudnn_sdpa_unbacked_batch_dim' -q lintrunner --config=.lintrunner.toml aten/src/ATen/native/LinearAlgebra.cpp torch/_decomp/decompositions.py torch/fx/experimental/proxy_tensor.py test/test_fake_tensor.py Fixes pytorch/torchtitan#3324 Pull Request resolved: pytorch#183398 Approved by: https://github.com/laithsakka
) Stacked PRs: * pytorch#183545 * pytorch#183544 * pytorch#183495 * pytorch#183398 * __->__#183397 --- --- --- ### [ATen][FakeTensor] Handle unbacked dims in folded matmul The folded matmul path used for ND @ 1D/2D tensors was still forcing concrete sizes in two places: the empty-tensor check used numel(), and the fold/view path built concrete DimVector shapes from sizes(). With unbacked input dimensions, both paths can require specializing a data-dependent symbol even though the operation can be represented symbolically. Keep the folded path symbolic by using sym_numel(), sym_sizes(), sym_strides(), reshape_symint(), _unsafe_view_symint(), and symbolic output resize. The contiguity predicate now uses symbolic equality guarded through TORCH_GUARD_OR_FALSE instead of forcing concrete stride/shape integers. Also let fake view metadata recover from hinted unbacked contiguity relations by emitting symbolic equality checks for stride relations that are true at the traced hint. This handles shapes such as 2 * (u0 // 2) with a stride expressed through u0 without specializing u0 to a concrete value. Add fake tensor regression tests for rank-3 linear with an unbacked batch dimension and hinted unbacked view contiguity. Test Plan: python test/test_fake_tensor.py FakeTensorTest.test_linear_rank3_unbacked_batch_dim FakeTensorTest.test_view_unbacked_contiguous_relation_from_hints -v lintrunner --config=.lintrunner.toml aten/src/ATen/native/LinearAlgebra.cpp torch/_decomp/decompositions.py torch/_subclasses/fake_impls.py test/test_fake_tensor.py Fixes pytorch/torchtitan#3322 Pull Request resolved: pytorch#183397 Approved by: https://github.com/laithsakka
…orch#183398) Stacked PRs: * pytorch#183545 * pytorch#183544 * pytorch#183495 * __->__#183398 --- --- --- ### [ATen][ProxyTensor] Preserve unbacked batch dims in SDPA tracing The general batched matmul path still converted broadcast batch dimensions to concrete int64_t sizes before expanding, reshaping, and viewing through bmm. That breaks tracing for rank-4 inputs with an unbacked batch symbol, including the math scaled-dot-product-attention path, because SDPA lowers through batched matmul. Carry symbolic sizes through the broadcasted bmm path by replacing sizes() and IntArrayRef/DimVector shape plumbing with sym_sizes(), SymDimVector, infer_size_symdimvector(), expand_symint(), reshape_symint(), _unsafe_view_symint(), and symbolic output resize. Keep the existing gradient broadcast shortcut but evaluate its symbolic predicates with guard helpers. Also preserve symbolic size queries during proxy tracing. aten.size.default has a non-symbolic int[] schema, so executing it on a fake tensor with unbacked sizes forces the symbol and can raise GuardOnDataDependentSymNode. When torch-function metadata tracing sees aten.size.default on a tensor with symbolic sizes, redirect it to aten.sym_size.default so downstream users receive symbolic size proxies instead of forcing concrete integers. This covers cuDNN SDPA fake outputs whose batch dimension remains symbolic. Add fake tensor regressions for rank-4 matmul, math SDPA, symbolic aten.size.default tracing, and cuDNN SDPA fake output sizes with an unbacked batch dimension. Test Plan: python test/test_fake_tensor.py FakeTensorTest.test_linear_rank3_unbacked_batch_dim FakeTensorTest.test_matmul_rank4_unbacked_batch_dim FakeTensorTest.test_sdpa_math_unbacked_batch_dim FakeTensorTest.test_size_default_unbacked_batch_dim FakeTensorTest.test_cudnn_sdpa_unbacked_batch_dim pytest test/test_fake_tensor.py -k 'linear_rank3_unbacked_batch_dim or matmul_rank4_unbacked_batch_dim or sdpa_math_unbacked_batch_dim or size_default_unbacked_batch_dim or cudnn_sdpa_unbacked_batch_dim' -q lintrunner --config=.lintrunner.toml aten/src/ATen/native/LinearAlgebra.cpp torch/_decomp/decompositions.py torch/fx/experimental/proxy_tensor.py test/test_fake_tensor.py Fixes pytorch/torchtitan#3324 Pull Request resolved: pytorch#183398 Approved by: https://github.com/laithsakka
Stacked PRs:
[ATen][ProxyTensor] Preserve unbacked batch dims in SDPA tracing
The general batched matmul path still converted broadcast batch dimensions to concrete int64_t sizes before expanding, reshaping, and viewing through bmm. That breaks tracing for rank-4 inputs with an unbacked batch symbol, including the math scaled-dot-product-attention path, because SDPA lowers through batched matmul.
Carry symbolic sizes through the broadcasted bmm path by replacing sizes() and IntArrayRef/DimVector shape plumbing with sym_sizes(), SymDimVector, infer_size_symdimvector(), expand_symint(), reshape_symint(), _unsafe_view_symint(), and symbolic output resize. Keep the existing gradient broadcast shortcut but evaluate its symbolic predicates with guard helpers.
Also preserve symbolic size queries during proxy tracing. aten.size.default has a non-symbolic int[] schema, so executing it on a fake tensor with unbacked sizes forces the symbol and can raise GuardOnDataDependentSymNode. When torch-function metadata tracing sees aten.size.default on a tensor with symbolic sizes, redirect it to aten.sym_size.default so downstream users receive symbolic size proxies instead of forcing concrete integers. This covers cuDNN SDPA fake outputs whose batch dimension remains symbolic.
Add fake tensor regressions for rank-4 matmul, math SDPA, symbolic aten.size.default tracing, and cuDNN SDPA fake output sizes with an unbacked batch dimension.
Test Plan:
python test/test_fake_tensor.py FakeTensorTest.test_linear_rank3_unbacked_batch_dim FakeTensorTest.test_matmul_rank4_unbacked_batch_dim FakeTensorTest.test_sdpa_math_unbacked_batch_dim FakeTensorTest.test_size_default_unbacked_batch_dim FakeTensorTest.test_cudnn_sdpa_unbacked_batch_dim
pytest test/test_fake_tensor.py -k 'linear_rank3_unbacked_batch_dim or matmul_rank4_unbacked_batch_dim or sdpa_math_unbacked_batch_dim or size_default_unbacked_batch_dim or cudnn_sdpa_unbacked_batch_dim' -q
lintrunner --config=.lintrunner.toml aten/src/ATen/native/LinearAlgebra.cpp torch/_decomp/decompositions.py torch/fx/experimental/proxy_tensor.py test/test_fake_tensor.py
Fixes pytorch/torchtitan#3324