feat(sm120_dsa_indexer): DeepSeek-V4.1 candidate blocks and mixed-length scheduling for ragged prefill #10072
All Vouch review confidence checks passed
Residual risk 0.21 = Change Risk (0.52) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.52 · 650 lines diff across 8 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.388
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #10072"
general
weight: 0.35
lucifer1004
📌 Description
This PR extends the experimental SM120 DSA indexer (
dsa_indexer_det_topk(..., backend="sm120"), ragged form) in three ways:Every decision that depends on row lengths is made on the device, so the launch sequence depends only on the shapes and the call is CUDA-graph safe. Results don't depend on the route or the schedule: they are bitwise identical across schedules, and the tests check this.
Candidate blocks (DeepSeek-V4.1)
candidate_outandcandidate_block_size(8 or 16). The RESIDENT and SCAN epilogues write each row's block maxima. A per-row selection then writes the row's candidate blocks intocandidate_out, in no particular order.candidate_blocks. Each row is masked to its listed blocks: a key in an unlisted block scores −inf, and the sample threshold counts only listed keys.- A split consumer row too long for one selection CTA's registers, but with top-k to that many listed keys, is selected over its listed keys only.
split_select_kernelmoves them to the front of the row, guided by the row's block bitmap, and maps the selected positions back to keys.Both run in separate kernel instantiations (
kSeg,kMask), so calls without candidates run the same code as before.Scheduling of the resident route
Rows short enough for the resident route run as query blocks, one block per CTA, in length classes. Before this PR, a call whose blocks didn't fill whole waves left most SMs idle in its last partial wave. A class with few long blocks took one SM's latency per block, whatever the other SMs were doing.
rows_kerneldecides this on the device from a cost rule: the leftover's longest row, its block count, top-k and the SM count (split_min_keys,rest_min_keys). Leaving blocks are split over every SM (stream-K over their tiles), and their rows are selected bysplit_select_kernel, one CTA per row.split_plan_kernelruns afterrows_kerneland splits any class with fewer blocks than SMs, by the same rule. All classes' remaining whole blocks run in one launch whose CTAs claim blocks from the plan's list, longest first. That list is in block order within 1024-key length buckets.- The queue and the split classes run on per-thread side streams beside the scan. They do so only when the launch stream has the whole device, so never on a green context or partition.
- With whole waves, the waves let the split launch start early only when the leftover blocks leave. An early release otherwise slowed the waves' own last blocks.
- With no whole wave, the split launch starts at once and waits for the waves' end.
Scan operands in registers
The prefill SCAN kernel keeps operands that are fixed for a query block in registers for the whole block, instead of reloading them for every 128-key tile:
Scores are bit-identical. Only the four SCAN instantiations change.
What stays the same
main(compared per kernel, with parameter offsets normalized). Each new choice is a template parameter or lives in a separate instantiation.main. Split rows use their own selection kernel (SplitSelParams), so the decodeselect_kerneland its parameters are as onmain.Fix: decode-scan stage refills
The decode logits scan reads its Q and K stages with
ldmatrix/ld.shared, then arrives on the empty barrier. The arrive doesn't order the generic-proxy reads against the TMA refill. The producer now issues a proxy fence after its empty-barrier wait, before each refill: one fence per refill rather than one per consumer warp.Performance
Setup: RTX PRO 6000 Blackwell Server Edition (188 SMs). CUPTI kernel spans, cold L2, CUDA-graph replay, median µs.
Prefill grid, indices only. T query rows over C cached keys, causal; 76 cells per format (32 and 64 heads, top-k 512 and 2048):
| format | vs main, geomean | vs main, range | vs best other, geomean | vs best other, lowest |
|---|---|---|---|---|
| FP8 | 1.04× | 0.99–1.14× | 1.15× | 0.98× |
| MXFP4 | 1.05× | 0.97–1.14× | 1.26× | 1.02× |
FP8, 32 heads, top-k 2048:
| cell | PR (µs) | vs main | vs best other |
|---|---|---|---|
| fresh T=2K | 44.5 | 1.01× | 1.25× (vLLM) |
| fresh T=16K | 1993.4 | 1.00× | 1.16× (SGLang) |
| append T=2K, C=32K | 1177.8 | 0.99× | 1.01× (GVR) |
| append T=2K, C=254K | 6485.3 | 1.12× | 1.38× (GVR) |
| append T=8K, C=128K | 14531.1 | 1.12× | 1.23× (GVR) |
| append T=16K, C=240K | 51991.1 | 1.11× | 1.30× (GVR) |
| mixed 4×2K, C=0/16K/64K/200K | 8283.7 | 1.12× | 1.21× (GVR) |
| mixed 8×1K, C=0..248K | 9550.7 | 1.14× | 1.27× (GVR) |
MXFP4, 64 heads, top-k 512:
| cell | PR (µs) | vs main | vs best other |
|---|---|---|---|
| fresh T=2K | 57.8 | 1.00× | 1.14× (vLLM) |
| fresh T=16K | 2058.6 | 1.00× | 1.22× (SGLang) |
| append T=2K, C=32K | 1230.2 | 0.98× | 1.10× (GVR) |
| append T=2K, C=254K | 6880.2 | 1.09× | 1.47× (GVR) |
| append T=8K, C=32K | 4696.1 | 0.98× | 1.16× (GVR) |
| append T=16K, C=240K | 55037.6 | 1.08× | 1.38× (GVR) |
| mixed 4×2K, C=0/16K/64K/200K | 8503.2 | 1.08× | 1.31× (GVR) |
| mixed 8×1K, C=0..248K | 10092.7 | 1.08× | 1.29× (GVR) |
Where the gains come from:
Known regression against
main: MXFP4 64-head appends with C ≈ 32K run at 0.97–0.98×, from the queue launch's code generation. Every other cell is at 0.99× or above.Loss bar: one cell trails the best other pipeline: FP8 32-head top-k 512 append T=2K C=32K, at 0.98× against GVR (0.93× on
main). Every MXFP4 cell is ahead.DeepSeek-V4.1 layers (32 heads, FP8, top-k 512, 2048 candidate blocks of 8). Dense layers take an 8K-token chunk; candidate layers replay the chunk's last 128 rows per request. The baseline is DeepGEMM logits plus vLLM's candidate helpers and top-k (
mainhas no candidate support). Cells are the speedup over the baseline, with this PR's time in µs:| step | dense | source (replay) | consumer (replay) |
|---|---|---|---|
| one chunk at 0K | 1.15× (302.3) | 1.87× (35.6) | 1.03× (36.4) |
| one chunk at 32K | 1.14× (2336.0) | 1.40× (133.9) | 1.09× (118.4) |
| one chunk at 128K | 1.44× (7834.4) | 1.23× (347.4) | 1.20× (325.0) |
| one chunk at 512K | 2.07× (25295.9) | 1.66× (1075.7) | 1.57× (1056.2) |
| 8 requests, mixed contexts | 1.68× (2353.6) | 5.06× (677.7) | 5.71× (632.6) |
| 16 requests, mixed contexts | 2.03× (6016.7) | 3.27× (2961.6) | 3.50× (2801.3) |
Decode: unchanged; the kernels' SASS is
main's.🔍 Related Issues
🚀 Pull Request Checklist
✅ Pre-commit Checks
pre-commitby runningpip install pre-commit(or used your preferred method).pre-commit install.pre-commit run --all-filesand fixed any reported issues.🧪 Tests
unittest, etc.).tests/experimental/test_sm120_dsa_indexer.py: 328 passed on two RTX PRO 6000 machines. One of them runs an RTX PRO 5500 vBIOS with 170 SMs. New and extended cases:🔬 Experimental Track
flashinfer/experimental/and/or an@flashinfer_experimental_api. Tracking issue: #7084- [x] The tracking issue names an owner, the reason for the experimental path, and a graduation plan with a target release.
- [x] Core changes are limited to a thin entry point (signature, shared validation, feature-gate check, backend selection, handoff).
- [x] Tests live in
tests/experimental/and were validated on the intended hardware; a runnable example is included.- [x] Nothing is registered in
flashinfer/aot.py, and no experimental backend is reachable frombackend="auto"withoutFLASHINFER_ALLOW_EXPERIMENTAL_AUTO_BACKENDS=1. (Calling an@flashinfer_experimental_apior naming a backend explicitly is itself the opt-in and needs no environment variable.)- [x] Test scope declared below. The experimental CI lane runs exactly these targets, so keep them as narrow as the change allows.
``
experimental-tests
`tests/experimental/test_sm120_dsa_indexer.py
---
This PR was developed with AI assistance (Claude Code). Every change was reviewed, tested on SM120 hardware and benchmarked by the author.
🤖 Generated with Claude Code
<!-- This is an auto-generated comment: release notes by coderabbit.ai -->
<!-- coderabbit-ai-generated:v1 -->
Summary by CodeRabbit
New Features
Ragged inputs now support candidate-block selection, including selecting source candidates and restricting results to listed candidates. Unlisted visible keys are ranked at negative infinity.
Candidate outputs are supported for ragged inputs, including calls with no keys, which return -1` entries.
Improvements
Selection scheduling better handles varied workloads, including long rows and mixed segments, by distributing work across available processing resources.
Documentation
* Clarified candidate-block behavior and limitations for paged and ragged inputs.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->