Repository navigation
[Spec] Fix wrong tokens from compact-verify CUDA graphs when a token tier is captured more than once - #42709
Conversation
…UDA graphs A token tier can be captured several times (attention graph variants, PD-mux streams), but every capture allocated a new RaggedVerifyLayout and replaced the registered one. Replay stages the live verify_lens / qo_indptr into the registered layout only, so graphs from earlier captures read stale synthetic (or freed) offsets.
4bc70e9 to
d4a2117
Compare
|
We confirm this bug and this fix on AMD MI355X (gfx950). We found it while we evaluated DSpark compact verify on DeepSeek-V4.1-Flash (TP4, 4x MI355X, DSpark block size 5, verify width 6, compact verify, with #40567 applied). Compact verify sampled from a flatter distribution than the target. What we saw without the fix
A/B on one tree, with and without the change in this PR Target logits at each verify step, compared with a target-only prefill of the same prefix and draft tokens (greedy, 6 prompts of about 1.1k tokens):
Static is the baseline. The generation servers run Sampling at temperature 1.0 and top_p 1.0 (384 prompts at concurrency 64, up to 1024 tokens), scored by a target-only server:
Our local fix was the same change as this PR (one layout per token tier). Our CPU test of #40567 makes the DSv4.1 verify graph read |
|
/rerun-test test_basic_sanity_dspark.py test_decode_cuda_graph_runner.py |
|
🚀 🚀 |
Motivation
With compact ragged verify (
SGLANG_RAGGED_VERIFY_MODE=compact),DecodeCudaGraphRunnercaptures a token tier more than once when there are several attention graph variants (for example the DSv4.1 candidate graphscandidate_unfiltered/candidate_filtered) or several PD-mux streams. Each capture calls_capture_ragged_verify_layout, which allocated a newRaggedVerifyLayoutand replaced_captured_ragged_layouts[num_tokens]. At replay,_stage_ragged_verify_layoutcopies the liveverify_lens/qo_indptronly into that registered layout, which belongs to the last capture. Graphs from the earlier captures still read the layout they were captured with. That layout holds synthetic capture offsets, and replay no longer refreshes it.A graph that reads an earlier capture's layout tensors directly computes with the wrong offsets whenever the live layout differs from the capture-time one. On current main, PD-mux with the TRT-LLM MLA backend is exposed: its ragged verify path pads and unpads queries with the captured
verify_lens/qo_indptrinside the graph. For DSv4.1 target verify on current main the defect is latent, because its backend copies the live layout into its own buffers outside the graph. The ragged Engram hashing andtoken_req_indicesin #40567 readqo_indptrinside the DSv4.1 verify graph; with them, thecandidate_unfilteredgraphs map tokens to the wrong requests.I measured an A/B on DeepSeek-V4.1-Flash (TP4, 4x RTX PRO 6000 Blackwell, SM120, DSpark gamma 5, compact verify, #40567 applied) with an earlier revision of this fix, which copied the live layout into each capture instead of sharing one layout per tier. I compared the log-prob of each generated token with a plain prefill of the same text:
Eager verify was correct in both builds.
Modifications
_capture_ragged_verify_layoutcreates the layout once per token tier and returns the same object for later captures of that tier. Every graph of the tier now captures the tensors that replay refreshes.Accuracy Tests
TestRaggedVerifyLayoutPerTier(CPU,test/registered/unit/model_executor/runner/test_decode_cuda_graph_runner.py) calls the capture-layout helper twice for tier 24 with two variant labels, stages a live layout, and checks both returned layouts'qo_indptr_device/verify_lensagainst the live padded layout. On main the first layout keeps its synthetic offsets (7 of 9qo_indptrentries differ).Speed Tests and Profiling
Not benchmarked. The replay staging code is unchanged; capture reuses one registered layout per token tier across attention variants and PD-mux streams.
Checklist
Developed with AI assistance.
CI States
Latest PR Test (Base): ❌ Run #37864565786
Latest PR Test (Extra): ❌ Run #37864565460
Latest PR Test (AMD ROCm 10): ❌ Run #37864565822