Repository navigation
[DSv4.1] Run the candidate indexer on SM12x through the paged decode path - #42371
juliankang4 wants to merge 1 commit into
Conversation
…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.
|
Tested the |
|
Tested this on 8x RTX PRO 5000 72GB (SM120) with DeepSeek-V4.1-Flash, DP8 attention + EP8. Tree: upstream With this PR alone, the c1/c2 low-ratio indexers still crash on the first forward:
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):
LGTM from the SM120 side. |
…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).
…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]
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.
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.
|
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 ( Validation boundary: we have not applied and benchmarked this PR's full head ( We also hit the separate extra-KV-page blocker from #39914 after initialization: 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 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. |
|
Closed as the helper path is unreachable now, added the sm120 check to #42371 . TY for the contribution! |
Fixes #42364.
Motivation
DeepSeek-V4.1 does not start on SM12x.
make_candidate_indexersends 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_LOGITSneedsDEEPGEMM_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_pagedkernel, 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, becausedsv41_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_indexerreturns 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_scorestakes 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, newTestCandidateIndexerGating(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_replayis renamed totest_paged_indexer_backends_replayand 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-65f75914with the python tree replaced by this branch.Kernel tests on one GB10, plain SGLang:
test_paged_indexer_backends_replayTestCandidateIndexerGatingscoring.pyline revertedAll of
test_fp4_indexer.pywith 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.
sgl-eval 0.1.2 run gsm8k --no-thinking --temperature 0 --seed 42 --max-tokens 2048 --num-threads 16): 1276/1319 (0.9674), 1 truncated, 0 errors. [Perf] Optimize DeepSeek V4.1 Flash Hopper paths and Blackwell prefill selection #41251 reports 1276 to 1278 on H200 and 1277 to 1279 on GB300 at the same cap.--ruler2-seq-len 65536 --ruler2-dataset-size 10 --no-thinking --temperature 0 --seed 42, all 12 subtasks): 91.11, 0 errors, 0 truncated (average input 62,426 tokens). At 64K the context is longer than the 16,384 compressed positions (2048 blocks x 8) the candidates cover, so the consumers really select inside the candidate blocks.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.pyline 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.
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
/tag-and-rerun-ci,/tag-run-ci-label,/rerun-failed-ci