Repository navigation
[Perf] deepseek-v4.1: Score a request's verify rows as one request in the full-scan indexer - #45251
Merged
Merged
Conversation
… the full-scan indexer Under DSpark target verify the ratio-1 and ratio-2 indexers called DeepGEMM's paged logits kernel with every draft row as its own request, so each row streamed its request's whole index-K cache. With the static block the rows are request-major, so the metadata and both scan paths (full top-k and the candidate-source publish) now take them as [requests, block, heads, 64] with 2D lengths and one page-table row per request, which the kernel scores in blocks of 128 / heads rows. At 128K contexts and 32 index heads that reads the cache twice per request instead of six times. Ragged verify keeps one row per request. Co-Authored-By: Claude Fable 5.1 <[email protected]>
kpham-sgl
requested review from
Fridge003,
HaiShaw,
Qiaolin-Yu,
hebiao064,
ispobock and
merrymercy
as code owners
October 19, 2026 23:40
Collaborator
Author
|
/rerun-test test/registered/unit/layers/test_dsv4_nonpaged_indexer.py test/registered/attention/unittests/dsv4/test_deepseek_v4.py test/registered/e2e/models/test_deepseek_v41_flash_gb300_dp4ep4.py |
Contributor
|
🚀 🚀 🚀 🚀 |
copy_metadata asserts that the field lists cover every dataclass field, so the new field failed every in-place copy of an indexer metadata: CUDA graph replay of a full DSV4Metadata and the breakable prefill graph's refresh of the c1 and c2 metadata. The grouping is fixed per capture, so it is an equality check. Co-Authored-By: Claude Fable 5.1 <[email protected]>
Co-Authored-By: Claude Fable 5.1 <[email protected]>
…row layout Co-Authored-By: Claude Fable 5.1 <[email protected]>
Collaborator
Author
|
/rerun-test test/registered/unit/layers/test_dsv4_nonpaged_indexer.py |
Contributor
|
🚀 |
This comment has been minimized.
This comment has been minimized.
Co-Authored-By: Claude Fable 5.1 <[email protected]>
4 of 5 tasks
4 of 5 tasks
zcnrex
added a commit
to zcnrex/sglang
that referenced
this pull request
Oct 23, 2026
Resolve conflicts with bf16 V4.1 index logits (sgl-project#44051, sgl-project#45880), grouped verify rows (sgl-project#45251), the two-level-only prefill graph (sgl-project#45783) and KV-shard index-K writes (sgl-project#44280): the adapter takes a logits_dtype and maps [batch, next_n] paged queries and schedules to grouped varlen rows on SM100. Co-Authored-By: Claude Opus 5.5 <[email protected]>
akhilg-nv
added a commit
to akhilg-nv/sglang
that referenced
this pull request
Oct 23, 2026
…he C4 indexer In a static MTP verify the C4 indexer called DeepGEMM's paged logits kernel with every draft row as its own request, so each row streamed its request's whole index-K cache. The C4 PagedIndexerMetadata now takes rows_per_request (sgl-project#45251's grouped DeepGEMM schedule), and group_verify_rows views q, the per-row lengths and the page table as one next_n query per request. Only the SM100 DeepGEMM path groups, from 16 requests on: below that, at short context, the grouped launch is up to 1.2x slower than per row. B200, cold L2, FP8, next_n 4: 32 requests x 64K 37.1 -> 28.4 us, 32 x 128K 73.2 -> 51.3 us, 128 x 64K 181.8 -> 87.0 us; never slower from 16 requests on. Grouped logits equal per-row logits bit for bit (FP8 and FP4). Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 task done
Open
5 tasks
chaohu2000
added a commit
to flytiger-eco/sglang-for-sail
that referenced
this pull request
Oct 27, 2026
… the full-scan indexer (sgl-project#45251) Co-authored-by: Claude Fable 5.1 <[email protected]> (cherry picked from commit 54b99da72ea89f27fb13d512d691054be21676fb)
Juhyun-Kim-Memphis
added a commit
to vessl-ai/sglang
that referenced
this pull request
Oct 28, 2026
…he torch prefill indexer (adapted from sgl-project#45794) Adaptation of upstream sgl-project#45794 (65f19fc) to this branch, which lacks the later index-plan refactors (sgl-project#45251, sgl-project#45577, sgl-project#45938), so the upstream patch does not apply as is. - Under prefill CP the caller passes req_rows=None with rank-local rows; rebuild the row-to-request map from req_pool_indices and rows_per_request instead of asserting. Without this, prefill CP on SM90 (torch indexer) dies at the first prefill. - Pad the dequantized index K to a multiple of 64 rows when it is BF16 on CUDA and lc >= 1024, size query chunks on the padded width, and slice scores back to lc before masking and top-k. Here index_k comes from req_to_token slots instead of upstream's k_slots. The padding is on the key axis only, so the #88 row shard (which splits query rows) and its max-merge are unchanged.
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
Under DSpark target verify the ratio-1 and ratio-2 DeepSeek-V4.1 indexers call DeepGEMM's paged logits kernel with every draft row as its own request, so each row streams its request's whole index-K cache: six times per request with block 5. On a DEP16 decode at 64 requests per rank and 128K contexts the four full scans take 1.27 ms of a 22.6 ms DSpark cycle.
Modifications
PagedIndexerMetadata.rows_per_request: the draft block for static verify, 1 for ragged verify and everywhere else. The DeepGEMM schedule is planned over the lengths viewed[requests, block](the JIT planner flattens them, so grouped rows use DeepGEMM's).DeepGEMMDecodeData.paged_logits_argsviewsqas[requests, block, heads, 64], the lengths as[requests, block], and takes one page-table row per request. Both full-scan callers use it:FullTopK._deep_gemm_decodeand the candidate-sourcepublish_decode.fp8_fp4_paged_mqa_logitsalready schedulesnext_nrows per request in blocks of128 / heads, so six rows read the cache twice instead of six times.Validation
DeepSeek-V4.1-Flash, one DEP16 worker on 4x4 GB300 (DP attention 16, EP16, MegaMoE,
flashmla_mega, DSpark block 5, static ragged verify, bf16 index logits, decode graphs at batch 64), 1,024 random-id prompts of 128K tokens held at 64 per rank, golden acceptance 3.51, main49766a74f9against this branch, one run each. Step time from the scheduler'sDecode batchlines over the steady window; kernel times from a torch trace of 20 steps.Other kernels unchanged within 1%. GSM8K at native acceptance on one DEP2 node (5 shots, 1,314 examples, temperature 0): 97.56% main, 97.11% this branch, inside the run-to-run spread, as the check below shows.
Kernel-level check on one GB300 (DeepGEMM v0.2.2, bf16 logits): the same
fp8_fp4_paged_mqa_logitscall on identical random inputs, per row (next_n1) and grouped six per request (next_n6), on three batches: 64 x 6 rows at 128K slots with two seeds, and 16 x 6 at 64K. Every logit a row scores inside its own length is bit-equal (78M values, max abs diff 0), so the per-row top-k is identical on all three. The fp32-logits output type was not run.CI States
Latest PR Test (Base): ❌ Run #39350404495
Latest PR Test (Extra): ❌ Run #39350404499
Latest PR Test (AMD ROCm 10): ❌ Run #39350404651