Skip to content

[Fix] deepseek-v4.1: Exchange late-layer DP row counts before the forward - #44948

Merged
hnyls2002 merged 2 commits into
mainfrom
lsyin/dsv41-late-layer-dp-counts
Oct 18, 2026
Merged

hnyls2002 merged 2 commits into
mainfrom
lsyin/dsv41-late-layer-dp-counts

Conversation

@hnyls2002

@hnyls2002 hnyls2002 commented Oct 18, 2026 •

Copy link
Copy Markdown
Collaborator
  • With DP attention and MegaMoE, one rank can replay the breakable prefill graph while an idle peer runs the step eagerly. Decoder SWA bounded replay gathered the late-layer row counts on the CPU group inside the model forward, which a graph replay never reaches: the idle rank blocked in the gather and the prefilling rank in MegaMoE (DeepGEMM grid sync timeout). Every step with one prefilling and one idle rank hung, including the multimodal startup warmup.
  • ForwardBatch.prepare_mlp_sync_batch now exchanges each rank's late-layer rows into global_late_layer_num_tokens_cpu. Every rank reaches it after its batch is padded and before it picks the prefill graph or eager.
  • late_layer_dp_counts reads the exchanged rows and asserts this rank's own entry; a step without an extend keeps the in-forward gather, which every rank then takes.
  • AttentionBackend.late_layer_num_tokens returns None; the DeepSeek-V4 CUDA and ROCm backends count an extend's tail rows with late_layer_tail_lens, as the tail metadata does, and every row otherwise.
  • Add a test: the rows are exchanged before the forward and no rank gathers inside it. It fails on main. The mocked runner in test_mlp_sync_hybrid_target_verify.py now states that its backend has no late-layer rows.
  • Checked on GB300 with DP attention 2 / EP 2 and MegaMoE, DeepSeek-V4.1-Flash, decoder SWA bounded replay on (the default):
    • With --cuda-graph-backend-prefill breakable: the server starts (it hung at the multimodal warmup before), four single requests each replay the graph next to an idle rank, and GSM8K on all 1,319 questions scores 96.97%.
    • With the prefill graph disabled: GSM8K 97.12%.

No behavior change without decoder SWA bounded replay and DP attention. With them, a prefill-graph step adds one CPU all-gather of one int per rank, and an eager step runs that gather before the forward instead of inside it.


CI States

Latest PR Test (Base): 🚫 Run #39096858005
Latest PR Test (Extra): ❌ Run #39096857974
Latest PR Test (AMD ROCm 10): ⏳ Run #39096858010

@hnyls2002

Copy link
Copy Markdown
Collaborator Author

/rerun-test test_dsv41_late_layer_tail_readers.py test_mlp_sync_hybrid_target_verify.py test_encoder_swa_replay.py test_mlp_sync_pad_unpad.py registered/unit/spec/test_dp_spec_prefill_coordination.py test_deepseek_v41_flash_gb300_dp4ep4.py test_deepseek_v4.py

@hnyls2002

Copy link
Copy Markdown
Collaborator Author

/tag-and-rerun-ci

@github-actions

github-actions Bot commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor

🚀 ubuntu-latest (5 tests): ✅ View workflow run

cd test/ && python3 registered/unit/layers/test_dsv41_late_layer_tail_readers.py
cd test/ && python3 registered/unit/model_executor/test_mlp_sync_hybrid_target_verify.py
cd test/ && python3 registered/unit/model_executor/test_encoder_swa_replay.py
cd test/ && python3 registered/unit/model_executor/test_mlp_sync_pad_unpad.py
cd test/ && python3 registered/unit/spec/test_dp_spec_prefill_coordination.py

🚀 4-gpu-gb300 (1 test): ✅ View workflow run

cd test/ && python3 registered/e2e/models/test_deepseek_v41_flash_gb300_dp4ep4.py

🚀 4-gpu-b200 (1 test): ✅ View workflow run

cd test/ && python3 registered/attention/unittests/dsv4/test_deepseek_v4.py

🚀 1-gpu-h100 (1 test): ✅ View workflow run

cd test/ && python3 registered/attention/unittests/dsv4/test_deepseek_v4.py

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

deepseek run-ci CI: run the baseline test suite on this PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant