[Perf][DSA] Use DeepSelect for eligible sparse-indexer prefill chunks - #57206
Draft
WoosukKwon wants to merge 2 commits into
Draft
WoosukKwon wants to merge 2 commits into
WoosukKwon wants to merge 2 commits into
Conversation
Reuse the explicit DeepSelect backend for single-request prefill chunks without context parallelism. Keep the existing kernel for unsupported input or output alignment and multi-request chunks. GB200 validation: 26 existing GPU test cases pass, including bounded preallocated-output graph replay. Three full-model probes match reference outputs, including a mixed-chunk case exercising both dispatch paths. Q4K model latency improves about 8%, with profiled top-k time reduced from 7.52 ms to 1.19 ms. Co-authored-by: Codex <noreply@openai.com> Signed-off-by: Woosuk Kwon <woosuk@inferact.ai>
WoosukKwon
requested review from
AndreasKaratzas,
ProExpertProg,
houseroad,
mgoin,
robertgshaw2-redhat,
tlrmchlsmth,
yewentao256,
youkaichao and
zyongye
as code owners
September 16, 2026 16:39
Collaborator
Author
|
/ci run |
|
❌ This PR is 5 commits behind upstream |
Collaborator
Author
|
/ci run |
|
✅ Triggered Buildkite CI #89392 for commit |
WoosukKwon
marked this pull request as draft
September 17, 2026 06:09
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.
Purpose
Extend the existing opt-in
deep_selectsparse-indexer backend to supported prefill chunks. Today the option accelerates decode, while prefill still callstop_k_per_row_prefill. For eligible chunks, reuse DeepSelect with the causal per-row end bounds and the existing preallocated output buffer.The fast path requires a single request in the indexer chunk, SM100-family hardware, no PCP or DCP, and supported input/output alignment. A single request's gathered KV starts at column zero, so DeepSelect's
endargument represents the original causal interval. Multi-request chunks, context parallelism, and unsupported layouts retain the existing kernel. A multi-request batch can still benefit when the chunk planner places each request in its own chunk.Enable with
--kernel-config '{"sparse_indexer_topk_backend":"deep_select"}'. Defaults and decode dispatch are unchanged. No new kernels or dependency changes.Duplicate-work check
Follow-up to merged #56464, which integrated DeepSelect for decode. Checked #56217 and its comments, open PRs referring to that issue, and DeepSelect/prefill-top-k searches.
None implements this DeepSelect prefill path.
Test Plan
Extend the existing preallocated-output test to cover bounded selection and CUDA graph replay after updating row ends. Includes empty/short rows, lengths around top-k, full-length rows, strided output, untouched padding, and
-1tails. Compare selected scores against PyTorch.Test Result
Standalone commit
3e850c278d, based on42919b49c5: 26 GPU tests passed on GB200 (250 deselected). Applicable pre-commit hooks, including mypy 3.10, and explicit mypy 3.12 passed. The three changed files exactly match the previously validated patch.Earlier validation of the same patch included three full-model parity probes: 4K prefill/~100K KV, eight 1K prefills/~100K KV, and a mixed-chunk case exercising both DeepSelect and the nonzero-start fallback. All observed output errors were zero.
Performance evidence and limitations
The earlier approximately 6.3x top-k speedup is a dummy-model benchmark result, not a demonstrated real-weight serving speedup. Those profiles used
v41_benchmark_dummyweights and generated KV history. The 4K-query/~100K-KV profile measured 7.52 ms versus 1.19 ms summed over ten prefill top-k launches per forward; both arms had matching launch counts and row counts. It was not a 6.3x full-model speedup. The previously quoted exploratory 8.0%/10.8% full-forward gains also predate the benchmark metadata-reset correction and should not be treated as validated production gains.Captured real-model logits
We repeated kernel timing on logits captured from actual
deepseek-ai/DeepSeek-V4.1-Flashweights (revisiondba1be0a40aa45a94ad051997016db3960a90277), TP4/EP4, MegaMoE, FlashInfer FP8 KV and the MXFP4 NEW sparse indexer. Prompts contained repository documentation, with actual context lengths of 8,192, 51,200 and 102,400 tokens. We captured the first eligible matrix at each column width; these samples do not cover every layer or prompt distribution.Here “native” means vLLM's existing CUDA
top_k_per_row_prefill, not PyTorch or FlashInfer. Both selectors used identical captured FP32 logits, causal bounds, top-k 512 and preallocated outputs. Measurements used a GB200 ongb200-rack1-04, CUPTI CUDA-graph timing with cold L2, 25 warmup calls and four alternating timing rounds. Selected-score equality, valid/unique indices and short-row tails passed for every case before timing. Matched normal-random controls produced similar trends.The original dummy-input result overstated the benefit for these sampled real-model workloads. DeepSelect regressed on the captured 4K–50K-column matrices and improved the 100K-column matrix by about 1.29x, not 6–7x. These are isolated selector timings, not end-to-end serving gains. In particular, 100K actual context also includes compressed 50K-column selections where DeepSelect was slower.
Synthetic controls
Fresh single-GB200 kernel measurements show that both shape and score distribution matter. With normal-random FP32 logits, top-k 512, 4K query rows, causal row bounds, uncompressed KV, preallocated outputs, CUPTI CUDA-graph timing and cold L2:
A controlled distribution ablation at the same 8K-query/8K-KV shape demonstrates why random logits cannot stand in for every indexer workload:
All cases passed selected-score correctness checks. The native selector initially bins scores through FP16 conversion; concentrated values increase histogram contention and can require further selection work. DeepSelect is much less affected in this ablation. This demonstrates input-dependent performance, but does not by itself establish the cause of the exact 6.3x historical model-profile result.
For the tested DSV4.1 checkpoint, 102,400 actual context tokens produce 51,200-entry KV in layers 2–19 and 102,400-entry KV in layers 20–39. With the NEW sparse indexer, dense prefill top-k runs at index sources 2/8/14 over the compressed context and source 20 over the uncompressed context; later indexers use selected candidate blocks. A single nominal KV-length threshold does not describe all of these selections.
No universal 6–7x speedup or real-weight end-to-end gain is claimed by this PR. The captured real-model measurements argue against using DeepSelect unconditionally for prefill. Any automatic dispatch should depend on the actual logits width and be validated with corrected model-level measurements; the random-logit sweep alone is insufficient to establish a production cutoff.
Real-weight evaluation previously completed with this patch in the combined optimized model configuration:
deepseek-ai/DeepSeek-V4.1-Flash, revisiondba1be0a40aa45a94ad051997016db3960a90277, TP4/EP4, native MegaMoE/shared fusion, FlashInfer sparse attention. Full GSM8K, lm-eval 0.4.12, five-shot multi-turn chat, thinking disabled, greedy generation, 1024 output tokens, seed 123:These combined evaluations include separate attention and MoE changes; they do not isolate DeepSelect's quality effect. Selection tests check score correctness, not identical membership among tied scores.
AI assistance
Codex assisted with implementation, validation, and this description. Woosuk Kwon requested upstreaming this change after reviewing its scope and reported results.