Skip to content

[graph_trainer] Coalesce lm_head chunked-loss collectives + Run 7 (bitwise vs eager) - #3637

Closed
SherlockNoMad wants to merge 1 commit into
gh/SherlockNoMad/56/basefrom
gh/SherlockNoMad/56/head
Closed

SherlockNoMad wants to merge 1 commit into
gh/SherlockNoMad/56/basefrom
gh/SherlockNoMad/56/head

Conversation

@SherlockNoMad

@SherlockNoMad SherlockNoMad commented Jun 11, 2026 •

Copy link
Copy Markdown
Contributor

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.

  • 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 [graph_trainer] Coalesce lm_head chunked-loss collectives to match eager (bitwise) #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-poisoned]
@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Jun 11, 2026
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
@tianyu-l tianyu-l closed this Oct 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ciflow/8gpu CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants