Skip to content

[DSv4.1] Run the candidate indexer on SM12x through the paged decode path - #42371

Closed
juliankang4 wants to merge 1 commit into
sgl-project:mainfrom
juliankang4:dsv41-sm12x-paged-decode
Closed

juliankang4 wants to merge 1 commit into
sgl-project:mainfrom
juliankang4:dsv41-sm12x-paged-decode

Conversation

@juliankang4

@juliankang4 juliankang4 commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #42364.

Motivation

DeepSeek-V4.1 does not start on SM12x. make_candidate_indexer sends every GPU with compute capability >= 10 down the SM100 branch, and that branch requires DeepGEMM's paged sparse MQA logits. Those are SM100-only (DEEPGEMM_PAGED_SPARSE_MQA_LOGITS needs DEEPGEMM_BLACKWELL), so on SM120/SM121 the attention backend raises at init. The traceback is in #42364. I hit it on four DGX Spark (GB10, SM121) nodes running TP4.

Hopper already has what SM12x needs. It gets the dense-blocks scheme for prefill and decode, and since #41251 its decode scores the index-K pool with the Triton fp4_index_logits_paged kernel, builds the candidate mask once at the source layer and selects with the JIT top-k v2. None of that is Hopper-specific. SM12x also already uses the same 64-slot index-K pages, because dsv41_index_page_size() returns 64 whenever the sparse API is missing.

SM12x is one more backend for #40574; it was not on that list.

Modifications

  • dsv4/v41_indexer/__init__.py: when DeepGEMM's paged sparse MQA logits are missing and the platform is SM12x, make_candidate_indexer returns the dense-blocks backend for prefill and decode instead of raising. SM100 without the sparse API still raises as before.
  • dsv4/v41_indexer/scoring.py: decode_scores takes the paged path on SM12x as well as on SM90.

The second line matters for speed. Without it SM12x starts, but every candidate layer scores all compressed positions up to the CUDA-graph capacity on each decode step. The numbers are under Speed Tests.

Prefill does not change. SM12x already ran prefill through the dense-blocks scheme with DeepGEMM's flattened-K logits (_use_deep_gemm_prefill() is true there).

Tests:

  • test/registered/unit/layers/test_dsv41_candidate_blocks.py, new TestCandidateIndexerGating (CPU): SM12x without the sparse logits gets the dense-blocks backend, and SM100 without them still raises. The SM12x case fails on main with the RuntimeError from [Bug] DeepSeek-V4.1 fails at attention backend init on SM12x (GB10): the candidate indexer requires DeepGEMM paged sparse MQA logits, which are SM100-only #42364.
  • test/registered/kernels/ops/attention/test_fp4_indexer.py: test_hopper_indexer_backends_replay is renamed to test_paged_indexer_backends_replay and now also runs on SM12x. It captures the full top-k, source and consumer decode in one CUDA graph, checks that all three go through the paged scorer, and compares pages and raw indices against a torch reference while lengths and mappings change between replays.

Accuracy Tests

Hardware: four DGX Spark (GB10, SM121), TP4 over a QSFP ring, driver 595.84, CUDA 13.0. The GPU clocks are locked to 300-2000 MHz on all four nodes (nvidia-smi -lgc 300,2000; GB10 can boost to 3003 MHz), so absolute tok/s will be lower than on a stock box. Both arms below ran at the same clocks. Image: lmsysorg/sglang:nightly-dev-cu13-20261003-65f75914 with the python tree replaced by this branch.

Kernel tests on one GB10, plain SGLang:

tree test_paged_indexer_backends_replay TestCandidateIndexerGating
main (00bcc25) fails (ratio 1 and 2) fails (RuntimeError)
this PR passes passes
this PR, scoring.py line reverted fails (ratio 1 and 2) passes

All of test_fp4_indexer.py with this PR on GB10: 99 passed, 36 skipped (the SM100-only vectorized prefill cases), 0 failed.

End to end, DeepSeek-V4.1-Flash, TP4 on the four GB10s. One thing about this stack: the model does not fit four GB10s on plain SGLang (it needs NVMe-offloaded Engram tables, among other things), so it runs through a local serving recipe, MiaAI's DGX Spark TP4 recipe. Its adapters patch weight loading, the MoE path (b12x) and DSpark verify. I turned off every adapter that pins engine sources. The kernel tests above do not go through the recipe.

Speed Tests and Profiling

Decode on the same stack and the same prompts: code text with a fresh first line for every request, 512 output tokens, greedy, thinking off. "Non-paged" is this PR with the scoring.py line reverted, so SM12x runs the dense-blocks scheme on the non-paged dense scores.

Single request, server freshly started for each arm, two runs per length. Decode is the mean of the two runs, TTFT the second run.

input decode tok/s, this PR decode tok/s, non-paged TTFT s, this PR TTFT s, non-paged
16K 66.1 46.1 (+43%) 4.4 4.1
64K 65.8 48.1 (+37%) 16.4 16.2
128K 57.9 44.6 (+30%) 34.9 36.0

TTFT is the same in both arms, as expected: the change does not touch prefill.

Note on #42368

With the FlashInfer version main pins (0.7.0.post1), DeepSeek-V4.1-Flash on SM12x with attention TP > 1 also fails at decode CUDA graph capture, for an unrelated reason: #42367, fixed in #42368. The end-to-end runs above include that fix. The kernel tests do not need it.

Checklist

Review and Merge Process

  1. Ping Merge Oncalls to start the process. See the PR Merge Process.
  2. Get approvals from CODEOWNERS and other reviewers.
  3. Trigger CI tests with comments or contact authorized users to do so.
    • Common commands include /tag-and-rerun-ci, /tag-run-ci-label, /rerun-failed-ci
  4. After green CI and required approvals, ask Merge Oncalls or people with Write permission to merge the PR.

…path

DeepGEMM's paged sparse MQA logits are SM100-only, so make_candidate_indexer
raised at backend init on SM12x (RTX Blackwell, GB10). Give SM12x the
dense-blocks scheme and let its decode use the Triton paged scores, as Hopper
does.
@BorisTyshkevich

Copy link
Copy Markdown

Tested the v41_indexer/__init__.py hunk of this PR, backported alone to v0.5.21, on an RTX PRO 6000 Blackwell (SM120). It fixes the init failure from #42364 on that GPU. The SM12x dense-blocks CUDA-graph decode test goes from 0/2 to 2/2. A reduced-config DeepSeek-V4.1 server (dummy weights, TP1) starts and serves prompts up to 20K tokens. Details are in #42364. Real-weights and TP4 validation are still pending.

@moria97

moria97 commented Oct 20, 2026

Copy link
Copy Markdown
Contributor

Tested this on 8x RTX PRO 5000 72GB (SM120) with DeepSeek-V4.1-Flash, DP8 attention + EP8. Tree: upstream a90e9c5d + this PR.

With this PR alone, the c1/c2 low-ratio indexers still crash on the first forward:

deep_gemm.fp8_fp4_paged_mqa_logits -> Assertion error (layout.hpp:45): t.is_cuda()

The cause is a split_kv mismatch between the SM120 FP4 kernel (128) and the JIT metadata planner (256). #45261 fixes it.

With this PR + #45261 (+ #45262 / #45263 / #45264):

  • GSM8K 0.905
  • 32K/1K: 0.807 req/s
  • 3K/100: 9.59 req/s
  • bs1 TPOT: 17.4 ms

LGTM from the SM120 side.

detain added a commit to detain/sglang that referenced this pull request Oct 20, 2026
…indexer) + stack_want decisions

- stack.txt: entries 1-2 (local) + Group A boot-critical indexer chain sgl-project#42371/sgl-project#42861/sgl-project#45261/sgl-project#42294/sgl-project#43008 (fe7be85..0dbd8c5).
- stack_want.txt: consolidated decision set from 8 parallel evaluators + dsv41(422)/SM120(254) sweeps + sybil/qwen harvests.
  Records E verdict (merge only sgl-project#43376) and D verdict (merge only sgl-project#42368; sgl-project#33407/sgl-project#34717 dead on flashinfer 0.7.2).
detain added a commit to detain/sglang that referenced this pull request Oct 20, 2026
…e dense fallback (port of sgl-project#39914)

Partial port of upstream sgl-project#39914 (be0439f). Kept: _split_kv_pages_to_64 extra-KV re-tile on both the SM120 prefill and FlashInfer decode paths (buf_key_suffix=":extra" so main/extra buffers never alias) + its adapter test. Dropped: dsv4/candidate_indexer.py (moved to v41_indexer/ by sgl-project#41125) and dsv4/candidate_torch.py (imports symbols absent from our v41_indexer/). The candidate dense fallback for SM120 (return dense_blocks, dense_blocks instead of raising) already landed in base via sgl-project#42371, so the boot fix needs no further edit.

(cherry picked from commit be0439f) [partial]
zooeyQAQ pushed a commit to zooeyQAQ/sglang that referenced this pull request Oct 27, 2026
Record L2/L8/L14 (ratio-2) and L20 (ratio-1 candidate source) on
decode-graph replay: raw indices, physical page indices, score bytes,
layer input, and sparse_out. Hashes are SHA-256 of packed int32 pairs
(order vs sorted set). Enabled only when SGLANG_C1_ORDER_PROBE_DIR is
set. CUDA graph path D2D-copies into a preallocated ring; D2H happens
after each 15-step request on DP5. No sort fix, no attention-kernel
change, no EXP-0027 canonicalize.

Tree remains SGLang v0.5.22 + upstream PR sgl-project#42371.
zooeyQAQ pushed a commit to zooeyQAQ/sglang that referenced this pull request Oct 27, 2026
Single-rank harvest used to require attn_dp_rank==5, so a TP8 DP1
serve wrote nothing. Keep the DP5 path for the old config; dump
tp_rank==0 when attn_dp_size==1. Record actual dp/tp in the request
summary. No sort fix, no attention-kernel change.

Tree remains SGLang v0.5.22 + upstream PR sgl-project#42371.

Copy link
Copy Markdown

Additional independent reproduction on 8× RTX PRO 6000 Blackwell (SM120, 96 GB, PCIe), TP8/EP8, using the official DeepSeek-V4.1-Flash-1017 HF weights:

We initially worked around this by restricting the shared FP4-indexer hardware gate to SM10x. That got our stack past initialization, but after comparing the implementations, the narrower routing in this PR is the preferable upstream direction: sparse candidate-kernel support should not be conflated with support for ordinary FP4 prefill/paged logits. Our installed DeepGEMM includes SM120 implementations of those ordinary kernels. The separate paged-scoring change is also important; the main snapshot we inspected (b146a857) still selects that scorer only on SM90.

Validation boundary: we have not applied and benchmarked this PR's full head (2f2173c1). Our running baseline uses our conservative fallback, with SGLANG_FP8_PAGED_MQA_LOGITS_TORCH=1 and SGLANG_DSV41_TORCH_PREFILL_INDEXER=1. It has completed a real-weight generation smoke test and is answering AIME26 requests, but this is not a quality or performance validation of this PR. The metadata/split-KV issue in #45261 remains relevant when preserving the DeepGEMM path.

We also hit the separate extra-KV-page blocker from #39914 after initialization:

Unsupported sparse-MLA prefill configuration:
model=DSV4 num_heads=8 topk=128 page_block_size=64
 topk_extra=512 extra_page_block_size=128

On FlashInfer 0.6.18, repacking the extra prefill footer pages from 128 to 64, with an independent output buffer, fixes this. Our small-shape regression tests verify exact equality of dequantized values, bit-identical attention outputs against an independent repacking reference, and CUDA-graph replay. Existing 2/64-token extra pages must remain untouched. This version's decode kernel accepts pbs_extra at runtime, so adding a decode copy should be justified separately rather than assumed necessary.

I would favor building on this PR, with explicit capability/metadata coverage and the extra-page fix tracked separately, rather than submitting a competing broad hardware-gate change.

@Jiminator

Copy link
Copy Markdown
Collaborator

Closed as the helper path is unreachable now, added the sm120 check to #42371 . TY for the contribution!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

5 participants