Repository navigation
[Fix] dsv41: Run DSpark compact verify by mapping packed verify tokens to their requests - #42718
Merged
Merged
Conversation
ormandj
requested review from
BBuf,
Edwardf0t1,
Fridge003,
HaiShaw,
Qiaolin-Yu,
Ying1123,
ch-wan,
hebiao064,
hnyls2002,
ispobock and
merrymercy
as code owners
October 6, 2026 04:55
3 of 5 tasks
ormandj
force-pushed
the
dsv41-ragged-verify-engram
branch
from
October 7, 2026 05:42
7aa4a2f to
0876748
Compare
17 of 56 tasks
ormandj
force-pushed
the
dsv41-ragged-verify-engram
branch
from
October 19, 2026 17:33
0876748 to
e238d2f
Compare
detain
added a commit
to detain/sglang
that referenced
this pull request
Oct 20, 2026
… correctness) - core batch [10-15]: sgl-project#43376 long-ctx indexer OOM bound, sgl-project#42368 FlashInfer-0.7 decode dispatch, sgl-project#39914 extra-KV 64-token page split + candidate fallback, sgl-project#42714 graph-safe page-split buffers, sgl-project#32464 SM120 sparse-prefill test gate, sgl-project#34027 int32->int64 page-split overflow guard. - Group C [16-23]: sgl-project#42717 TP-rank verify-budget, sgl-project#43225/sgl-project#43374 compact-verify seq_lens + padding renorm, sgl-project#42718 packed-verify token->request map, sgl-project#42713 forced-uniform capture metadata, sgl-project#45301 padded-query graph lifetime, sgl-project#44141 bounded-replay guard, sgl-project#45185 V4.1-Flash-1017 FP8 QDQ (env-gated, default OFF). sgl-project#42710 skipped (superseded upstream: step_logits already fp32).
2 of 4 tasks
…ens to their requests With SGLANG_RAGGED_VERIFY_MODE=compact, target verify packs a variable number of tokens per request. EngramHasher asserted equal blocks per request and token_req_indices repeated each request draft_token_num times, so DeepSeek-V4.1 failed at CUDA graph capture (sgl-project#39173). Add ragged_verify_token_rows, a fixed-size token-to-row lookup over the layout's qo_indptr. Engram hashes packed verify through its existing extend path; token_req_indices maps graph padding to pool slot 0. Uniform verify is unchanged.
DeepSeek-V4.1 captures each verify token tier for two attention variants. Capture both through the runner, stage live unequal lengths, and check that token_req_indices and EngramHasher read them from either variant's layout.
ormandj
force-pushed
the
dsv41-ragged-verify-engram
branch
from
October 29, 2026 21:42
e238d2f to
dc39f02
Compare
…token_req_indices by positions
Qiaolin-Yu
requested review from
DarkSharpness,
HydraQYH,
celve and
yuan-luo
as code owners
November 4, 2026 22:53
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Collaborator
|
/rerun-test registered/kernels/ops/attention/dsv4/test_dsv41_compact_verify.py registered/spec/dspark/test_ragged_verify_backend_capability.py registered/unit/speculative/test_dspark_engram_commit_in_graph.py registered/core/test_basic_sanity_dspark.py registered/e2e/models/test_deepseek_v41_flash_gb300_tp2ep2.py registered/e2e/models/test_deepseek_v41_flash_gb300_dp2ep2.py |
Contributor
|
🚀 🚀 🚀 |
Qiaolin-Yu
approved these changes
Nov 5, 2026
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
Fixes #39173.
With
SGLANG_RAGGED_VERIFY_MODE=compact, DSpark target verify can pack unequal numbers of tokens per request. A compact CUDA graph tier can also hold more requests than full verify windows: for example, 42 tokens over 8 slots captures as[6, 6, 5, 5, 5, 5, 5, 5]. Two DeepSeek-V4.1 components still assumedraft_token_numtokens per request:EngramHasher.forwardassertsnum_tokens == bs * draft_token_num. Capture fails withengram target-verify expects one equal block per request, got 42 tokens for 8 requests of 6.token_req_indicescallsrepeat_interleave(req, draft_token_num, output_size=num_tokens), which fails, or maps tokens to the wrong request, once the layout is not uniform.As a result, DeepSeek-V4.1 compact verify fails on these layouts.
#40567 by @lidekang160122 identified both call sites and fixes them as part of a larger PD change. This PR fixes only the crash. It derives the token-to-request mapping in one shared helper and reuses Engram's existing extend kernel path, so it needs no kernel changes.
Depends on the shared-layout fix from #42709, now in main: both components read the verify layout inside the CUDA graph, and without it the DeepSeek-V4.1 graph variants captured first for a token tier would read a layout that replay does not refresh.
Modifications
ragged_verify.py: addragged_verify_token_rows(layout, num_tokens). It is a fixed-sizesearchsortedover the layout'sqo_indptr, so it is safe under CUDA graph capture. Empty rows own no tokens, and the graph-padding tail maps to rowbs.EngramHasher.forward: with a ragged layout, target verify uses the existingMODE_EXTENDpath withrow = ragged_verify_token_rows(layout, num_tokens).clamp_max(bs - 1)andstarts = layout.qo_indptr_device[:-1]. As before, verify commits no history. Graph-padding tokens are hashed with the row the staged layout assigns them (a padding row, or the last row for the tail) and then discarded.token_req_indices: with a ragged layout, each token gets its request's pool index. The tail past the last request gets pool slot 0, like the padded rows of a dense verify graph; padding the staged layout assigns to a row gets that row's slot.min(num_tokens, max_bs)slots are valid once these components accept unequal rows.Accuracy Tests
test/registered/kernels/ops/attention/dsv4/test_dsv41_compact_verify.py(CPU tests and a CUDA graph replay test; all pass on an RTX PRO 6000 Blackwell):token_req_indicesmaps empty rows and the padding tail correctly.TestCapturedVariantsReadStagedLayout(CPU, same file) callsDecodeCudaGraphRunner's layout-capture helper twice for a 12-token tier, as the two DeepSeek-V4.1 attention variants do, stages live lengths [6, 1] for request slots 7 and 9, and checks thattoken_req_indicesandEngramHasherread the live boundaries from either variant's layout. Without the shared layout from [Spec] Fix wrong tokens from compact-verify CUDA graphs when a token tier is captured more than once #42709, the first variant maps the real tokens to [7, 7, 9, 9, 0, 0, 0]. All six tests in the file, including the CUDA graph replay test, pass on an RTX PRO 6000 Blackwell.test/registered/spec/dspark/test_ragged_verify.py: unit test ofragged_verify_token_rows.Speed Tests and Profiling
The change itself adds one
searchsortedper Engram call and per low-ratio request lookup in compact verify. Static verify is unchanged. Not benchmarked separately.Checklist
Review and Merge Process
/tag-and-rerun-ci,/tag-run-ci-label,/rerun-failed-ciDeveloped with AI assistance.
CI States
Latest PR Test (Base): ❌ Run #41943891256
Latest PR Test (Extra): ❌ Run #41943891193
Latest PR Test (AMD ROCm 10): ✅ Run #41943891412
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: