Skip to content

[DSV4.1] Reduce mHC, metadata and small-batch router overhead - #39704

Merged
BBuf merged 4 commits into
sgl-project:mainfrom
BBuf:bbuf/dsv41-medium-batch-throughput-publish
Sep 19, 2026
Merged

BBuf merged 4 commits into
sgl-project:mainfrom
BBuf:bbuf/dsv41-medium-batch-throughput-publish

Conversation

@BBuf

@BBuf BBuf commented Sep 16, 2026 •

Copy link
Copy Markdown
Collaborator

Retargeted to main at a6cf05817f11d22023fd951a76255ef50fb09f49, after #38798 and #40039 landed. The diff contains only this PR's optimizations (15 files), including the router PDL change previously consolidated from #39941.

Conflict resolution preserves main's post_experts_all_reduce topology handling and the DSPARK fused-argmax opt-in, while retaining the mHC overlap/fusion changes. Local validation: all pre-commit checks on the changed files passed, including Python syntax, Ruff, formatting, C++ formatting, and CI test registration. GPU correctness/performance measurements below are historical; they have not been rerun on this new main-based revision. CI is being triggered on the updated head.

Motivation

DeepSeek-V4.1 DSpark verify batches at concurrency 32/64 contain up to 192/384 rows. This reduces mHC boundary, communication, indexer quantization and speculative metadata overhead for those workloads without changing the deployment command.

Modifications

  • Extend deferred MoE finalize/all-reduce to 384 rows using a separate communicator with 4 MiB push slots and 512 row counters. Fuse mHC post and next-input combine while preserving BF16 intermediates; medium batches retain the original standalone RMSNorm.
  • Fuse supported prefill post/combine/RMSNorm and schedule mHC statistics on the existing model-wide stream immediately before sublayer all-reduce. Invalidate cross-layer inputs at Engram and row-selection boundaries.
  • Batch FP4 indexer quantization by eight rows per CTA and reduce each 32-element scale group directly, retaining exact FP4 codes and UE8 scales.
  • Extend integer metadata kernels to 384 rows and use a vocabulary-split argmax for medium speculative logits, preserving NaN/Inf and first-index tie behavior.

This builds on #39370. Compensated mHC and existing small-row paths are retained. There are no new environment variables or CLI flags, and no attention arithmetic changes. The experimental medium RMSNorm/MXFP8 fusion is excluded from this PR.

Accuracy Tests

Unset both SGLANG_SIMULATE_ACC_* variables before launching each evaluation server; their absence is also verified in the serving process environment. All other deployment settings remain identical. Frozen prompts/datasets/clients are shared between arms. GSM8K: 1,314 held-out test problems after excluding five few-shot examples, temperature 0, seed 0, max output 4,096. AIME 2026: all 30 problems. GPQA Diamond: all 198 problems. AIME/GPQA: thinking enabled, reasoning effort max, temperature 0, seed 0, top_p 0.95, max output 65,536. Client concurrency is 64 (AIME has only 30 distinct requests). Two independent starts per arm, with all scores, truncations, request errors and per-question transitions retained.

Correct answers from both fresh-server runs (a / b):

Suite Base Candidate Mean accuracy: base → candidate Difference
GSM8K, 1,314 problems 1278 / 1278 1278 / 1277 97.260% → 97.222% −0.038 pp
AIME 2026, 30 problems 28 / 28 29 / 27 93.333% → 93.333% 0 pp
GPQA Diamond, 198 problems 174 / 165 166 / 171 85.606% → 85.101% −0.505 pp

All evaluation requests completed without errors. Output-limit truncations (a / b):

Suite Base Candidate
GSM8K 2 / 1 0 / 0
AIME 2026 2 / 2 1 / 3
GPQA Diamond 15 / 18 19 / 17

The GPQA paired difference reverses from −8 to +6 questions; its two-run mean is one question lower, while the baseline itself varies by nine questions. This does not establish accuracy equivalence. Per-question inspection found 11 losses / 3 gains in pair a and 1 loss / 7 gains in pair b. GPQA question 8 was lost in both pairs with candidate truncation; two nontruncated wrong choices in pair a (85 and 127) are correct in candidate run b. All counts, including truncations, remain in the reported scores. All 198 GPQA problems are included in each run.

Additional real-acceptance control: submit the same frozen 4,096-token input IDs in one native /generate batch, temperature 0 / sampling seed 0, flush between two 1,024-token replays. Exact full-sequence matches:

Batch Base repeat 0 vs 1 Candidate repeat 0 vs 1 Base vs candidate, replay 0 / 1
32 25/32 25/32 25/32; 25/32
64 45/64 46/64 46/64; 46/64

The cross-version mismatch count is comparable to within-version variation in this control. Among sequences that are identical across both replays within each arm (25 at BS32 and 42 at BS64), none differ between arms. Grouped input reduces arrival differences but does not force identical physical batches at every decoding step; this is a token-sequence diagnostic on a frozen corpus, not an additional accuracy benchmark or proof of equivalence.

The earlier rebased head c797adea1e passed all 397 retained GPU test cases and a fresh-server real-acceptance check: BS32 and BS64, two grouped 1,024-token replays each, all requested prompts/output lengths verified and full-batch decode observed. Conflict-file pre-commit, syntax and CI registry checks also passed. The frozen A/B scores above are not relabeled as measurements of this rebased commit.

Speed Tests and Profiling

Output throughput, tokens/s; both measurements are retained:

Concurrency Base runs a / b Candidate runs a / b Base median Candidate median Gain
32 6111.52 / 6113.84 6436.61 / 6418.06 6112.68 6427.33 5.15%
64 7817.12 / 7833.92 8283.62 / 8263.03 7825.52 8273.32 5.72%

Every run completed all 1,024 requests and generated 1,048,576 output tokens. Even the slowest candidate exceeds the fastest baseline by 4.98% at C32 and 5.48% at C64.

Original CPU+GPU profiler traces were checked on all four ranks using launch correlation and 80 mHC sinkhorn anchors to identify a complete target graph. Kernel counts per target launch fall from 1,835 to 1,581 at C32 and from 1,834 to 1,580 at C64. Active CUDA streams stay 5 → 5 on every rank. The two profiled MoE BMM kernel names and their 40 calls each also match between arms. Profiled graph wall time is not used as serving latency.

Performance protocol and command

TP4/EP4/DP1, unchanged static DSpark block size 5, simulated acceptance length 5.4. 1,024 measured requests, each 4,096 input / 1,024 output tokens, concurrency 32 or 64, matching warmup count, all output tokens required. Two fresh starts per arm/batch with reversed order on the repeat; retain every measurement. These throughput results use simulated acceptance and are separate from the real-acceptance accuracy evaluations.

Server (both arms):

export MODEL_PATH=/path/to/DeepSeek-V4.1-Flash
export CUDA_VISIBLE_DEVICES=0,1,2,3
export MAX_JOBS=16
export PYTHONPATH="$PWD/python"
export SGLANG_SPEC_TP_SYNC=rng
export SGLANG_RAGGED_VERIFY_MODE=static
export SGLANG_SIMULATE_ACC_LEN=5.4
export SGLANG_SIMULATE_ACC_METHOD=match-expected
python3 -m sglang.launch_server \
  --trust-remote-code --model-path "$MODEL_PATH" \
  --served-model-name deepseek-ai/DeepSeek-V4.1-Flash \
  --tp 4 --ep-size 4 --mem-fraction-static 0.8 \
  --speculative-algorithm DSPARK --speculative-dspark-block-size 5 \
  --cuda-graph-max-bs-decode 64 --reasoning-parser auto --tool-call-parser auto \
  --host 127.0.0.1 --port 30021

The measured runs use a frozen token-ID corpus (SHA256 1f8e67cba16f9fa16573286775db9a2353fc4c42006695ba63c3515c7b2401f3) and a pinned official client with only dataset loading and timing recording replaced. A comparable standard random benchmark uses:

BS=64 # repeat with 32
python3 -m sglang.bench_serving \
  --backend sglang-oai --host 127.0.0.1 --port 30021 \
  --model "$MODEL_PATH" --tokenizer "$MODEL_PATH" \
  --served-model-name deepseek-ai/DeepSeek-V4.1-Flash \
  --dataset-name random --random-input-len 4096 --random-output-len 1024 \
  --random-range-ratio 1 --num-prompts 1024 --max-concurrency "$BS" \
  --request-rate inf --warmup-requests "$BS" --flush-cache --seed 42 \
  --extra-request-body '{"temperature":0,"ignore_eos":true}'

Validation Environment and Commit Provenance

Full A/B validation: base 6cf7203cab34831740f560e32b2413b7b70e95d2, candidate e289b1ebec43150de9530bf46d5c907013d3964d.

Current PR head: 74b97e796d10aca41ac76274259a82bdf99f7ea5, rebased onto dsv4.1 commit d71c438fdd0673185ae58fb2fc11263d7bd689f3.

This conflict resolution retains upstream's row_argmax(x) API and MoeFinalizeAllReduceParams / RowClusterTrait names. PR-specific prefill-stats, medium-page-table and combine/all-reduce tests now live in dedicated modules; upstream-deleted generic tests are not restored. The multi-GPU test's precompile hook now calls the existing JIT entry point because upstream removed the old helper. Across all 13 production files, the patch's added/removed lines match the previous PR after accounting for upstream symbol/module renames; all five argmax kernel function ASTs are unchanged. Upstream import consolidation, padding metadata and prefill-autotune changes are preserved.

Conflict-repair validation on 4×GB300: 202 targeted GPU test cases passed: 26 medium-argmax, 42 medium-page-table, 69 small-metadata, 3 post/combine test methods, 6 prefill-statistics and 48 FP4-indexer cases, plus 8 graph-replay combine/all-reduce cases across all four ranks. The first six groups ran on 6e7793c2736c383c62e1cd96e2da25da987185b1; the final head differs only in the communication test's precompile hook, and its four-rank group passed on 74b97e796d. Changed-file pre-commit checks passed. The initial communication test attempt stopped before kernel execution because of the removed precompile helper; it passed after that test-only adaptation.

The throughput and full accuracy tables retain their frozen A/B commit provenance above; full serving throughput, benchmark-suite accuracy and the real-acceptance serving control were not rerun as part of this conflict repair.

Hardware: 4×GB300, SM103, 2070 MHz / 1400 W. Same checkpoint revision dba1be0a40aa45a94ad051997016db3960a90277, torch 2.13.0+cu130, Triton 3.7.1, FlashInfer 0.6.18, sglang-kernel 0.4.7, sgl-deep-gemm 0.2.0. Each arm uses a clean checkout and fresh server, with all eight target/draft autotune cache files restored before each run. GPU jobs are serial.

All 415 targeted GPU test cases passed on the frozen candidate commit: 5 mHC boundary/normalization methods, 57 compensated-mHC cases, 128 finalize/all-reduce cases on each of four ranks, 135 metadata cases, 42 argmax cases and 48 FP4 indexer cases. Changed-file pre-commit passed.

The added tests cover BF16 representation equality at post/combine boundaries, comparison with the actual prefill model path, changed-input CUDA Graph replays, delayed ranks and interleaved communicator counters, existing compensated mHC, metadata tails, argmax ties/NaNs/Infs and exact FP4 codes/scales.

Checklist

  • Changed-file pre-commit checks passed.
  • Added targeted kernel and graph replay tests; all 202 targeted GPU cases passed during this conflict repair (commit provenance above).
  • Included deployment commands, scope and validation limits in this description; no new user-facing options.
  • Provided all accuracy and speed measurements, including lower scores and truncations.
  • Followed existing SGLang dispatch, fallback and shared-stream conventions.

CI States

Latest PR Test (Base): 🚫 Run #35437055512
Latest PR Test (Extra): ✅ Run #35442191059
Latest PR Test (AMD ROCm 10): 🚫 Run #35437055355

@BBuf BBuf added the run-ci-extra CI: also run the extra suite (requires run-ci) label Sep 18, 2026
@BBuf

BBuf commented Sep 18, 2026

Copy link
Copy Markdown
Collaborator Author

/rerun-test test/registered/e2e/models/test_gpt_oss_sm120.py

@github-actions

github-actions Bot commented Sep 18, 2026 •

Copy link
Copy Markdown
Contributor

Results for /rerun-test test/registered/e2e/models/test_gpt_oss_sm120.py:

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

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

@BBuf

BBuf commented Sep 19, 2026

Copy link
Copy Markdown
Collaborator Author

/rerun-test test/registered/moe/test_fused_moe.py

@github-actions

github-actions Bot commented Sep 19, 2026 •

Copy link
Copy Markdown
Contributor

Results for /rerun-test test/registered/moe/test_fused_moe.py:

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

cd test/ && python3 registered/moe/test_fused_moe.py

@BBuf

BBuf commented Sep 19, 2026

Copy link
Copy Markdown
Collaborator Author

/rerun-test test/registered/moe/test_fused_moe.py

@github-actions

github-actions Bot commented Sep 19, 2026 •

Copy link
Copy Markdown
Contributor

Results for /rerun-test test/registered/moe/test_fused_moe.py:

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

cd test/ && python3 registered/moe/test_fused_moe.py

@BBuf BBuf added the mergeable label Sep 19, 2026
@BBuf

BBuf commented Sep 19, 2026

Copy link
Copy Markdown
Collaborator Author

/rerun-test test/registered/kernels/ops/attention/test_fp4_indexer.py test/registered/kernels/ops/layernorm/test_mhc_kernels.py test/registered/kernels/ops/moe/test_moe_fused_gate.py test/registered/kernels/ops/communication/test_custom_all_reduce.py test/registered/spec/dspark/test_dspark_kernel_parity.py test/registered/unit/model_executor/test_compensated_mhc_update_guard.py test/registered/unit/models/test_deepseek_v4_shared_expert_fusion.py test/registered/unit/models/test_deepseek_v4_mxfp4_shared_expert_requant.py

@github-actions

github-actions Bot commented Sep 19, 2026 •

Copy link
Copy Markdown
Contributor

Results for /rerun-test test/registered/kernels/ops/attention/test_fp4_indexer.py test/registered/kernels/ops/layernorm/test_mhc_kernels.py test/registered/kernels/ops/moe/test_moe_fused_gate.py test/registered/kernels/ops/communication/test_custom_all_reduce.py test/registered/spec/dspark/test_dspark_kernel_parity.py test/registered/unit/model_executor/test_compensated_mhc_update_guard.py test/registered/unit/models/test_deepseek_v4_shared_expert_fusion.py test/registered/unit/models/test_deepseek_v4_mxfp4_shared_expert_requant.py:

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

cd test/ && python3 registered/kernels/ops/attention/test_fp4_indexer.py
cd test/ && python3 registered/kernels/ops/layernorm/test_mhc_kernels.py
cd test/ && python3 registered/kernels/ops/moe/test_moe_fused_gate.py

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

cd test/ && python3 registered/kernels/ops/communication/test_custom_all_reduce.py

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

cd test/ && python3 registered/spec/dspark/test_dspark_kernel_parity.py

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

cd test/ && python3 registered/unit/model_executor/test_compensated_mhc_update_guard.py
cd test/ && python3 registered/unit/models/test_deepseek_v4_shared_expert_fusion.py
cd test/ && python3 registered/unit/models/test_deepseek_v4_mxfp4_shared_expert_requant.py

@BBuf

BBuf commented Sep 19, 2026

Copy link
Copy Markdown
Collaborator Author

/rerun-test test/registered/moe/test_fused_moe.py

@github-actions

github-actions Bot commented Sep 19, 2026 •

Copy link
Copy Markdown
Contributor

Results for /rerun-test test/registered/moe/test_fused_moe.py:

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

cd test/ && python3 registered/moe/test_fused_moe.py

@BBuf

BBuf commented Sep 19, 2026

Copy link
Copy Markdown
Collaborator Author

/rerun-test test/registered/unit/layers/test_layer_communicator_fusion_gate.py

@github-actions

github-actions Bot commented Sep 19, 2026 •

Copy link
Copy Markdown
Contributor

Results for /rerun-test test/registered/unit/layers/test_layer_communicator_fusion_gate.py:

🚀 ubuntu-latest (1 test): ✅ View workflow run

cd test/ && python3 registered/unit/layers/test_layer_communicator_fusion_gate.py

@BBuf

BBuf commented Sep 19, 2026

Copy link
Copy Markdown
Collaborator Author

/rerun-test test/registered/kernels/ops/attention/test_fp4_indexer.py test/registered/kernels/ops/layernorm/test_mhc_kernels.py test/registered/kernels/ops/moe/test_moe_fused_gate.py test/registered/kernels/ops/communication/test_custom_all_reduce.py test/registered/spec/dspark/test_dspark_kernel_parity.py test/registered/unit/model_executor/test_compensated_mhc_update_guard.py test/registered/unit/models/test_deepseek_v4_shared_expert_fusion.py test/registered/unit/models/test_deepseek_v4_mxfp4_shared_expert_requant.py test/registered/unit/managers/test_disagg_idle_step_counters.py

@github-actions

github-actions Bot commented Sep 19, 2026 •

Copy link
Copy Markdown
Contributor

Results for /rerun-test test/registered/kernels/ops/attention/test_fp4_indexer.py test/registered/kernels/ops/layernorm/test_mhc_kernels.py test/registered/kernels/ops/moe/test_moe_fused_gate.py test/registered/kernels/ops/communication/test_custom_all_reduce.py test/registered/spec/dspark/test_dspark_kernel_parity.py test/registered/unit/model_executor/test_compensated_mhc_update_guard.py test/registered/unit/models/test_deepseek_v4_shared_expert_fusion.py test/registered/unit/models/test_deepseek_v4_mxfp4_shared_expert_requant.py test/registered/unit/managers/test_disagg_idle_step_counters.py:

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

cd test/ && python3 registered/kernels/ops/attention/test_fp4_indexer.py
cd test/ && python3 registered/kernels/ops/layernorm/test_mhc_kernels.py
cd test/ && python3 registered/kernels/ops/moe/test_moe_fused_gate.py

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

cd test/ && python3 registered/kernels/ops/communication/test_custom_all_reduce.py

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

cd test/ && python3 registered/spec/dspark/test_dspark_kernel_parity.py

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

cd test/ && python3 registered/unit/model_executor/test_compensated_mhc_update_guard.py
cd test/ && python3 registered/unit/models/test_deepseek_v4_shared_expert_fusion.py
cd test/ && python3 registered/unit/models/test_deepseek_v4_mxfp4_shared_expert_requant.py
cd test/ && python3 registered/unit/managers/test_disagg_idle_step_counters.py

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

Labels

deepseek jit-kernel mergeable run-ci CI: run the baseline test suite on this PR run-ci-extra CI: also run the extra suite (requires run-ci)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants