Repository navigation
[graph_trainer] Match Eager FSDP bucket order - #3590
Merged
IvanKobzarev merged 1 commit intoJun 11, 2026
Merged
Conversation
IvanKobzarev
requested review from
SherlockNoMad,
aditvenk,
sanketpurandare,
tianyu-l and
xmfan
as code owners
June 9, 2026 16:59
IvanKobzarev
marked this pull request as draft
June 9, 2026 16:59
IvanKobzarev
force-pushed
the
orderfix-fsdp-rs-bucket-order
branch
2 times, most recently
from
June 9, 2026 17:39
6906967 to
98bcf11
Compare
IvanKobzarev
marked this pull request as ready for review
June 9, 2026 17:43
IvanKobzarev
force-pushed
the
orderfix-fsdp-rs-bucket-order
branch
3 times, most recently
from
June 9, 2026 17:56
6906967 to
bd56b38
Compare
| sub_placements.append( | ||
| # pyrefly: ignore [bad-argument-type, unexpected-positional-argument] | ||
| _StridedShard(placement.dim, placement.split_factor) | ||
| _StridedShard(placement.dim, split_factor=placement.split_factor) |
Contributor
There was a problem hiding this comment.
rebase over main, this is likely already fixed in main
SherlockNoMad
approved these changes
Jun 11, 2026
GT Regional was packing FSDP collective buckets in graph execution order.
Eager FSDP2 packs bucket payloads in managed parameter registration order.
For reduce-scatter, changing the payload order changes byte offsets inside
NCCL buckets; on multinode FSDP groups NCCL may use different ring orders per
channel, so moving parameter elements between offsets can produce different
bf16 accumulation order.
Derive module order from traced state FQNs, which preserve FSDP2's first-seen
parameter order, and use it to order every FSDP bucket group before delegating
to the upstream manual overlap bucketer. This keeps the Torchtitan-specific
logic limited to choosing bucket payload order; upstream still owns merging,
insertion, wait remapping, and bucketed-node tagging.
This also updates the existing _StridedShard call in models/utils.py to pass
split_factor by keyword. CI pyrefly removes the stale suppression there and
then reports the second positional argument, while this form matches the typed
usage elsewhere in GraphTrainer.
Authored by Codex.
Test Plan:
```bash
python -m py_compile \
torchtitan/experiments/graph_trainer/fsdp_passes.py \
torchtitan/experiments/graph_trainer/passes.py \
torchtitan/models/utils.py
```
```bash
git diff --check origin/main...HEAD -- \
torchtitan/experiments/graph_trainer/fsdp_passes.py \
torchtitan/experiments/graph_trainer/passes.py \
torchtitan/models/utils.py
```
```bash
black --check \
torchtitan/experiments/graph_trainer/fsdp_passes.py \
torchtitan/experiments/graph_trainer/passes.py \
torchtitan/models/utils.py
```
```bash
flake8 --config=.flake8 \
torchtitan/experiments/graph_trainer/fsdp_passes.py \
torchtitan/experiments/graph_trainer/passes.py \
torchtitan/models/utils.py
```
```bash
PYTHONPATH=/data/users/ivankobzarev/f/torchtitan-orderfix-main \
python torchtitan/experiments/graph_trainer/tests/test_passes.py \
-k TestBucketingPrefetchOrder
```
```bash
lintrunner -a
```
This failed because Torchtitan has no `.lintrunner.toml` in this checkout.
`pre-commit`, `ufmt`, and `pyrefly` are also not installed in the local Python
environment.
MAST 64-GPU TP=1/BS=1 weight-hash validation matched Eager for all 25 steps:
```text
ORDERFIX_GT8B_TP1_BS1_WHASH_Eager_8b-64gpu-64-ivankobzarev-lhpsfjn4
ORDERFIX_GT8B_TP1_BS1_WHASH_GT_Reg_NoCG_8b-64gpu-64-ivankob-t06vk4kk
```
MAST 128-GPU TP=1/BS=1 weight-hash validation matched Eager for all 25 steps:
```text
ORDERFIX_GT8B_TP1_BS1_WHASH_Eager_8b-128gpu-128-ivankobzare-dvg55jz4
ORDERFIX_GT8B_TP1_BS1_WHASH_GT_Reg_NoCG_8b-128gpu-128-ivank-qtz1q3fk
```
MAST 256-GPU TP=1/BS=1 weight-hash validation matched Eager for all 25 steps:
```text
ORDERFIX_GT8B_TP1_BS1_WHASH_Eager_8b-256gpu-256-ivankobzare-jtmfxc4z
ORDERFIX_GT8B_TP1_BS1_WHASH_GT_Reg_NoCG_8b-256gpu-256-ivank-dhm7t4th
```
IvanKobzarev
force-pushed
the
orderfix-fsdp-rs-bucket-order
branch
from
June 11, 2026 17:23
bd56b38 to
ebb67be
Compare
IvanKobzarev
pushed a commit
to IvanKobzarev/torchtitan
that referenced
this pull request
Jun 17, 2026
…esults Set --training.local_batch_size 16 in the dsv3 run script and record Run 6: batch-size scaling (B=4/8/16) for MinimalAsyncEP + forced cudagraph + pytorch#3590. MFU 16.7%->20.6%, tps ~9k->~11.3k, memory ~36->~61 GiB / 95 GiB (no OOM). Numerics still unverified (needs eager loss_compare). ghstack-source-id: 0c9db28 Pull-Request: pytorch#3618
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.
Summary
Align GraphTrainer FSDP bucket packing order with Eager FSDP2.
Eager FSDP2 packs bucket payloads in managed parameter registration order, while GraphTrainer was packing FSDP collective buckets in FX graph execution order. For reduce-scatter, this changes byte offsets inside NCCL buckets. On multinode
FSDP groups, NCCL may use different channel ring orders per offset, so the same parameter elements can be reduced through a different bf16 accumulation order and lose bitwise parity.
This change derives the FSDP2 module order from traced state FQNs and sorts each FSDP bucket group by that order before delegating to the upstream manual overlap bucketer. The Torchtitan-specific logic is limited to choosing bucket payload
order; upstream still owns merging, insertion, wait remapping, and bucketed-node tagging.
Verified on 64,128,256 TP=1,8 llama3 8b