Repository navigation
[Perf] [NVIDIA] dsv4: Route padded decode replays through the metadata glue graph - #47676
Merged
Merged
Conversation
Root cause: _init_replay_attn_metadata glues the attention-metadata prep only when raw_bs == bs. The DSpark draft runner (dp-local, exempt from the DP-max gather) replays at the capture bucket of its own raw bs, so every rank whose batch is not exactly a capture size runs the eager init_forward_metadata_out_graph op soup (DEP16 c2884 nsys: G.attn_meta 0.56-0.62 ms vs 0.06 ms glued, on the post-agreement host tail); the same holds for target verify replays padded to the DP max. Fix: SGLANG_OPT_DSV41_PADDED_METADATA_GLUE (defaults to SGLANG_ENABLE_NV_MEGA_RUNTIME_OPTIMIZATION) allows the glue route for 0 < raw_bs < bs when the backend declared the DSV4 draft or target-verify glue (non-ragged). The glue view always reads the padded out_cache_loc slot, whose tail fill_from already zeroed, so the prep for key bs is the same op sequence as an unpadded replay; seq_lens / req_pool_indices tails are the registry pad values the eager padded prep already reads. IDLE replays stay eager. The glue graph's contract comment is updated accordingly. Validation (GB300, DSV4.1-Flash, on a 2026-10-30 nightly): - In-server bitwise check: 640 padded draft replays (16 ranks, raw_bs 2-13 on bs=14), every metadata tensor equal to the eager padded prep. - DEP16 nsys: draft G.attn_meta median 170 -> 58 us, worst rank 620 -> 64 us. - Combined with the other two host changes (same runs; numbers are for all three together): DEP32 c5768 decode step p50 15.2 -> 13.9 ms; steady-window per-GPU throughput (mean of minutes 8-20 of the aiperf run, x0.96, both arms) 660.6k vs 664.4k tok/s/GPU at p90 interactivity 219.8 vs 200.8 tok/s/user (vLLM-frontier gap -26.3% -> -20.8%); DEP16 c2884 720.1k vs 719.0k tok/s/GPU (same normalisation; no regression); GSM8K 1P1D with real acceptance 96.82% vs 96.89%, accept 3.50; TP4 c1 agg T=1 GSM8K 97.33% vs 97.33%, long-context needle retrieval at 20K-160K tokens 48/48 vs 48/48, decode step neutral (3.514 vs 3.501 ms).
weireweire
requested review from
Fridge003,
hnyls2002 and
ispobock
as code owners
October 31, 2026 19:05
3 tasks done
Drop SGLANG_OPT_DSV41_PADDED_METADATA_GLUE. The padded route now engages wherever the DSpark draft or target-verify metadata glue serves the runner and the runner is not in ragged verify mode. The draft glue is on by default, so padded draft replays take the glue graph without any flag.
This was referenced Nov 2, 2026
Root cause: the PR widens _init_replay_attn_metadata's glue route to padded replays (0 < raw_bs < bs) when a DSV4 draft or target-verify glue is declared, but no test covered that route. Narrowing the condition back to raw_bs == bs, or dropping the raw_bs > 0 guard so IDLE replays reach the glue graph, would pass every remaining test. Fix: TestReplayAttnMetadataWiring.test_replay_routes now also replays with the padded glue on: a padded replay of a captured key replays the glue graph without a view, and an IDLE replay (raw_bs 0) still runs the eager prep. Validation: pre-commit clean on the changed file; the test runs on the cluster with the rest of test_decode_cuda_graph_runner.py.
Qiaolin-Yu
approved these changes
Nov 4, 2026
Collaborator
|
[by Claude Code] I've started babysitting the NVIDIA CI of this PR. I'll check it every 30 minutes until all NV pipelines pass. If a relevant job fails, I may rerun it, merge the latest Anyone can stop me at any time: just post a comment asking me to stop (for example, |
Collaborator
|
/rerun-failed-ci |
Collaborator
|
[by Claude Code] All NV pipelines have passed. |
This was referenced Nov 5, 2026
Yuxingwang-intel
pushed a commit
to Yuxingwang-intel/sglang
that referenced
this pull request
Nov 6, 2026
…a glue graph (sgl-project#47676) Co-authored-by: weireweire <20922698+weireweire@users.noreply.github.com> Co-authored-by: Qiaolin Yu <liin1211@outlook.com>
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.
Motivation
DecodeCudaGraphRunner._init_replay_attn_metadataonly routes the attention-metadata prep through the metadata glue graph whenraw_bs == bs. Every other replay runs the eagerinit_forward_metadata_out_graphpath, which is dozens of small host-dispatched ops. Two common cases hit that path:On DSV4.1-Flash GB300 disagg DEP16 (c2884, 40 running per rank), the draft
G.attn_metacosts 0.56-0.62 ms on padded ranks vs 0.06 ms glued. That cost sits on the host path between the DP agreement and the draft graph launch.Related PRs
One of four DSV4.1 attn-DP decode host-path changes that cut the host work between the DP agreement and the draft graph launch. They are independent in code and were measured together: #47676 (padded metadata glue), #47677 (persistent DP-MoE counts), #47678 (bulk decode-prep fill) and #47685 (KV page top-up, measured on top of the other three).
Modifications
The glue route now also takes padded replays (
0 < raw_bs < bs). There is no separate switch: it engages wherever the backend declared the DSV4 draft or target-verify glue (the audited host-free prep) and the runner is not in ragged verify mode, and falls back to the eager prep otherwise. Non-DSV4 backends, the genericSGLANG_ENABLE_METADATA_GLUE_GRAPHglue, TBO and LoRA keep the padding-free route.Behavior change: the DSpark draft glue is on by default (static ragged verify mode), so padded draft replays now take the glue graph without any flag. The target-verify glue still follows
SGLANG_OPT_DSV41_TARGET_VERIFY_METADATA_GLUE. The DEP16 / DEP32 validation below ran withoutSGLANG_ENABLE_NV_MEGA_RUNTIME_OPTIMIZATIONon decode, i.e. in exactly this default configuration; the TP4 c1 runs had it on.Why the padded prep is the same as the eager padded prep: both read the same
req_pool_indices/seq_lensslots, whose tailsfill_fromresets to the registry pad values (0 andseq_len_fill_value). The glue view reads the paddedout_cache_locslot (num_tokensis passed for every glued replay).fill_fromzeroed that slot's tail, and the eager prep zero-pads the raw tensor to the same length. The declared prep reads nothing else that depends onraw_bs, so the captured prep for keybsserves padded and unpadded replays alike. IDLE replays stay eager. The contract comment inmetadata_glue_graph.pyis updated to cover the padded route.All runs: GB300, DSV4.1-Flash, on a 2026-10-30 nightly.
Accuracy Tests
SGLANG_OPT_DSV41_TARGET_VERIFY_METADATA_GLUE, which was off in the DEP runs, and TP4 c1 never pads.Speed Tests and Profiling
G.attn_meta, median over ranksG.attn_meta, worst rankThe following numbers are combined with the two sibling host changes (#47677 DSpark persistent DP-MoE counts, #47678 DFlash bulk decode prep). Same cluster and recipe, but the two arms ran on different days:
A MegaMoE NVLink barrier timeout after the benchmark abort also happens without these changes, so it is not caused by them. Serving-phase results are unaffected.
Checklist
num_tokensargument, a padded-slot case, and the padded / IDLE routing cases)CI States
Latest PR Test (Base): ✅ Run #41787902058
Latest PR Test (Extra): ❌ Run #41787902112
Latest PR Test (AMD ROCm 10): ❌ Run #41787902029
Tip
Base CI only covers the core cases, and its workload may not exercise your change. Use
/rerun-testto run the tests your change touches, or copy this prompt for an agent: