Repository navigation
[graph_trainer] Coalesce lm_head chunked-loss collectives + Run 7 (bitwise vs eager) - #3637
Closed
SherlockNoMad wants to merge 1 commit into
Closed
SherlockNoMad wants to merge 1 commit into
SherlockNoMad wants to merge 1 commit into
Conversation
This was referenced Jun 11, 2026
Closed
ydwu4
pushed a commit
to ydwu4/torchtitan
that referenced
this pull request
Jun 12, 2026
Port the graph trainer ChunkedCELossWithParamGrads rewrite from pytorch#3637. The graph trainer simple_fsdp path does not use FSDP2 gradient sync coalescing, so the base chunked CE loop can trigger per-chunk lm_head collectives. Override the loop to all-gather once, accumulate unsharded lm_head grads across chunks, reduce-scatter once, and expose those grads as explicit autograd outputs for graph capture.
ydwu4
pushed a commit
to ydwu4/torchtitan
that referenced
this pull request
Jun 12, 2026
Port the graph trainer ChunkedCELossWithParamGrads rewrite from pytorch#3637. The graph trainer simple_fsdp path does not use FSDP2 gradient sync coalescing, so the base chunked CE loop can trigger per-chunk lm_head collectives. Override the loop to all-gather once, accumulate unsharded lm_head grads across chunks, reduce-scatter once, and expose those grads as explicit autograd outputs for graph capture.
IvanKobzarev
pushed a commit
to IvanKobzarev/torchtitan
that referenced
this pull request
Jun 17, 2026
…twise vs eager) Make graph_trainer (simple_fsdp) bitwise-identical to the eager Trainer (FSDP2) for the chunked-loss path, and record the verification + benchmark as Run 7. - chunked_loss.py: ChunkedCELossWithParamGrads reads the all-gathered lm_head weight once, runs the per-chunk forward+backward against a detached leaf (no per-chunk collective; chunking/memory preserved), accumulates the per-chunk grads unsharded in fp32, and does a single Partial->Shard reduce-scatter -- reproducing eager's chunks-then-ranks summation order. Previously simple_fsdp reduce-scattered once per chunk (ranks-then-chunks), an f32-ulp drift that compounded (loss diverged from eager ~step 7 at 16B). Upstream: PR pytorch#3636. - run_graph_trainer_dsv3.sh: switch the benchmark to non-MinimalAsyncEP (graph_trainer_deepseek_v3_16b) + cudagraph disabled -- the eager-comparable path the fix makes exact. - dsv3_numerics_verification.md: root-cause, ablations (tying / NCCL / fused-vs-decomposed CE / num_chunks=1), and fix writeup. - dsv3_scaling_experiment_results.md: Run 7 -- bitwise verification (loss + grad_norm 0/20 at 16B over 20 steps) + benchmark + artifacts; resolves the UNVERIFIED caveat on Runs 2-6 for the chunked-loss path. ghstack-source-id: 1b11892 Pull-Request: pytorch#3637
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.
Stack from ghstack (oldest at bottom):
Make graph_trainer (simple_fsdp) bitwise-identical to the eager Trainer (FSDP2)
for the chunked-loss path, and record the verification + benchmark as Run 7.
weight once, runs the per-chunk forward+backward against a detached leaf (no
per-chunk collective; chunking/memory preserved), accumulates the per-chunk
grads unsharded in fp32, and does a single Partial->Shard reduce-scatter --
reproducing eager's chunks-then-ranks summation order. Previously simple_fsdp
reduce-scattered once per chunk (ranks-then-chunks), an f32-ulp drift that
compounded (loss diverged from eager ~step 7 at 16B). Upstream: PR [graph_trainer] Coalesce lm_head chunked-loss collectives to match eager (bitwise) #3636.
(graph_trainer_deepseek_v3_16b) + cudagraph disabled -- the eager-comparable
path the fix makes exact.
fused-vs-decomposed CE / num_chunks=1), and fix writeup.
grad_norm 0/20 at 16B over 20 steps) + benchmark + artifacts; resolves the
UNVERIFIED caveat on Runs 2-6 for the chunked-loss path.