Repository navigation
[Fix] [NVIDIA] deepseek_v4: Start DeepSeek-V4.1 on SM12x with TP8/EP8 defaults - #45261
Conversation
|
@Fridge003 @ispobock Could you take a look and |
…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).
…atio indexers on SM120 The c1/c2 full top-k decode of DeepSeek-V4.1 calls DeepGEMM's FP4 paged MQA logits kernel on SM120. There the model hook turns on SGLANG_FP8_PAGED_MQA_LOGITS_TORCH, so PagedIndexerMetadata leaves the c1/c2 schedule as None unless force_deep_gemm_metadata is set. FullTopKIndexer._deep_gemm_decode then hands None to deep_gemm.fp8_fp4_paged_mqa_logits, and the first decode fails with "layout.hpp: t.is_cuda()". Force DeepGEMM's metadata for the c1/c2 indexers on SM120, as is already done for the FP4 c4 indexer. The c4 path and other platforms are unchanged.
…n SM12x On SM12x, decode_scores takes the dense-slot branch for the DeepSeek-V4.1 dense-blocks candidate sources and consumers: it gathers an int64 [bs, lmax] slot map from req_to_token and fp32 scores at CUDA-graph capacity, where lmax is the context length over the compress ratio. That peaks at about 21 bytes per element, against 4 for the paged branch; at the default 1M context a ratio-1 call at batch 248 peaks at 5.48 GB instead of 1.04 GB. Once the low-ratio DeepGEMM metadata is fixed (sgl-project#45261), starting with --tp 8 --ep-size 8 on 8x RTX PRO 6000 runs out of memory in decode CUDA graph capture, in dense_blocks.publish_decode -> scoring.decode_scores. Take the paged branch on SM12x, as SM90 already does: the Triton fp4_index_logits_paged kernel scores the visible positions straight from the request table, the source layer builds the candidate mask once, and selection runs through the paged top-k.
a11fc47 to
04f5947
Compare
|
/tag-and-rerun-ci |
|
/rerun-test registered/unit/layers/test_dsv4_nonpaged_indexer.py registered/unit/layers/test_dsv41_indexer_arch_gates.py registered/unit/layers/test_dsv41_candidate_blocks.py registered/kernels/ops/attention/test_fp4_indexer.py registered/attention/unittests/dsv4/test_deepseek_v4.py registered/e2e/models/test_deepseek_v41_flash_gb300_tp2ep2.py |
|
🚀 🚀 🚀 🚀 |
Re-run bench.sh on lmsysorg/sglang:nightly-dev-20261119-6b374a55 (first image with sgl-project/sglang#45261) with the DeepSeek-V4.1-Flash-1017 checkpoint. Add launch-nightly.sh (the RTX PRO 6000 cookbook recipe, DSPARK=1 optional), the raw results, the 1K/1K comparison, and a note that launch.sh needs dev-dsv41. bench.sh picks the benchmark module the image ships.
Refs #42364. This PR now also carries the decode-scoring change from #42371, which it supersedes.
Motivation
At TP8/EP8 with other inference settings at defaults (
--tp 8 --ep-size 8), DeepSeek-V4.1-Flash does not start on SM120. It fails twice in sequence; each commit in this PR fixes one failure.Failure 1: the c1/c2 DeepGEMM schedule is
NoneEvery rank fails at startup with:
How it happens:
FullTopKIndexer._deep_gemm_decode).DeepseekV4ForCausalLMon SM120, the model hook turns onSGLANG_FP8_PAGED_MQA_LOGITS_TORCH.PagedIndexerMetadata.__post_init__then leavesdeep_gemm_metadata = Noneunlessforce_deep_gemm_metadatais set.--enable-deepseek-v4-fp4-indexer). In that case it already forces the metadata for c1/c2 as well. With that flag off, which is the default, the c1/c2 kernel receivesNoneas its schedule.Measured on base
0893ad02:force=Falseand the torch env var on, and_deep_gemm_decodereceivesschedule=None.deep_gemm.fp8_fp4_paged_mqa_logitsdirectly with aNoneschedule raises exactly this assertion.Failure 2: decode CUDA-graph capture runs out of memory
Once the schedule is fixed, decode CUDA graph capture runs out of memory (
Tried to allocate 994.00 MiB; in two runs, 4 and 3 of the 8 ranks reported it before the server exited). The stack is decode CUDA graph capture ->DeepseekV4AttnBackend._low_ratio_index_topk->DenseBlocksBackend.publish_decode->decode_scores, in the dense-slot gather.On SM12x,
decode_scoresscores the dense-blocks candidate sources and consumers through the dense-slot branch. That branch gathers an int64[bs, lmax]slot map fromreq_to_tokenand fp32 scores at CUDA-graph capacity, wherelmaxis the context length over the compress ratio. At the default 1M context, a one-GPU probe measures this peak allocation for onedecode_scorescall at CUDA-graph capacity:That is 21.0-21.1 bytes per element dense against 4.0 paged. In the same one-GPU probe, capturing candidate publication and consumption at ratio 1 used 5.57-13.46 GB of graph pool on the dense path and 1.44-2.98 GB on the paged path.
Related
[DSv4.1] Run the candidate indexer on SM12x through the paged decode path #42371: this PR supersedes it. Its scoring change is the second commit here. Its original factory change and test changes are not included; see Modifications.
[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: the startup failure reported there (
make_candidate_indexerraising on SM12x) is already fixed on main.[Fix] [NVIDIA] deepseek_v4: Build the DeepGEMM schedule for the low-ratio prefill-graph indexer on SM12x #45381: it targets
_low_ratio_prefill_indexer_metadata, which is no longer on main. On main, every CUDA c1/c2 paged-indexer metadata is built ininit_forward_metadata_indexer, the function the first commit changes.Env-var workaround: setting
SGLANG_FP8_PAGED_MQA_LOGITS_TORCH=0by hand also avoids failure 1, because the c1/c2 schedule then comes from the generic JIT planner. With the scoring change at TP8/EP8 defaults, that configuration served:This PR fixes the default instead of requiring the env var.
Modifications
Two commits, each keeping its original author:
1. Metadata change (original author moria97, from #45261):
layers/attention/deepseek_v4_backend.py,init_forward_metadata_indexer, lines 1678-1682.force_deep_gemm_metadatais now also true forcompress_ratio in (1, 2)on SM120, so the c1/c2 indexers get DeepGEMM's own paged-MQA schedule.init_forward_metadata_indexercovers SM120 or not, FP4 c4 flag on or off, and ratio 1, 2 or 4. The flag changes only for SM120 with the FP4 flag off, at ratios 1 and 2.SGLANG_FP8_PAGED_MQA_LOGITS_TORCH, which SM120 turns on, drops its schedule.Split widths. They do differ, as the existing comment says: DeepGEMM's SM120 planner uses split_kv=128 and the generic JIT planner uses 256.
test_paged_mqa_metadata.py::test_matches_deep_gemm) fails 12 cases and skips 4 on SM120 on unmodified base. That is expected, since the planners use different split widths, while the logits still match.Noneschedule, not the split width.2. Scoring change (original author juliankang4, from #42371):
layers/attention/dsv4/v41_indexer/scoring.py:577,decode_scores, nowpaged = get_platform().is_sm90 or get_platform().is_sm120. SM12x takes the paged branch that SM90 already uses:fp4_index_logits_pagedkernel scores visible positions straight from the request table;plan_topk_v2,topk_transform_paged_v2,finish_paged_indexer_topk).On SM12x, top-k v2 compiles its cluster variants out (
SUPPORT_CLUSTERis900 <= arch < 1100), so this path uses the non-cluster kernels. The SM120 hook'sSGLANG_OPT_USE_TOPK_V2=0governs the DSA top-k backend, not this path. SM90, SM100, HIP and XPU take the same branch as before.Not carried over from #42371:
make_candidate_indexerchange. It returned the dense-blocks backend on SM12x instead of raising. On current main that branch cannot be reached: [Refactor] env: Dispatch on the GPU architecture instead of env vars that restate it #48399 made the candidate-indexer gate strict to SM100, and [Fix] [NVIDIA] dsv4: Restore SM120/SM121 to the DeepGEMM indexer gates #49182 kept it so. Main already returns dense blocks on SM12x before that code, andtest_candidate_indexer_keeps_sm120_on_dense_blockscovers it.test_hopper_indexer_backends_replayintest_fp4_indexer.py.TestCandidateIndexerGatingintest_dsv41_candidate_blocks.py.test_candidate_indexer_keeps_sm120_on_dense_blocks.is_sm100_or_newer, which no longer gates that path, so by inspection it would fail on current main.Scope. Both changes gate on
get_platform().is_sm120, which is true for any compute capability 12.x with CUDA >= 12.8. That covers SM121 (GB10 / DGX Spark) and RTX 50-series as well as SM120. They were validated only on RTX PRO 6000 Blackwell Server Edition (SM120). No SM12x CI lane runs these paths.Accuracy Tests
Setup:
lmsysorg/sglang:nightly-dev-20261118-ecd3d75awith thepython/sglangtree of each candidate (base0893ad02) mounted over the image's copy. Versions read from the image: sgl-deep-gemm 0.2.8, torch 2.14.1+cu130, flashinfer-python 0.7.4.--tp 8 --ep-size 8with other inference settings at defaults.--tp 8alone) failed at load on the two trees tested, base and both changes: the MXFP4 FlashInfer CUTLASS MoE method needs the per-partition intermediate size to be a multiple of 128, and it is 288.Startup at TP8/EP8 defaults:
t.is_cuda()on all 8 rankst.is_cuda()gone; decode CUDA graph capture OOM (failure 2)t.is_cuda()on all 8 ranksforce=Trueand a DeepGEMM schedule tensor;decode_scoresreturns paged scores on all 8 ranksSelections (one GPU, synthetic, scoring change).
decode_scores-based full top-k) is the exact top-k score multiset of the dense-slot scores; ties may land on different positions. Published blocks and the decode mask match the block maxima. Maximum visible score difference: 0.0.Every row width below passed for ratios 1 and 2, eager and graph:
Tests:
test_fp4_indexer.py: 66 passed, 16 skipped on both base and the scoring change.test_dsv41_indexer_arch_gates.py(CPU): 7 passed.test_dsv41_candidate_blocks.py: 5 passed.test_dsv4_nonpaged_indexer.py: 32 passed with the metadata change.Serving with both changes, TP8/EP8 defaults:
Serving under the recipe settings in the Speed section (one server per arm for each eval):
Speed Tests and Profiling
What the recipe benchmark covers. It compares base with both changes, but neither change is on its timed path:
--enable-deepseek-v4-fp4-indexer, soforce_deep_gemm_metadatawas already true on base; instrumented base runs showforce=True.Recipe settings. Server flags:
Environment variables:
Workload:
python3 -m sglang.benchmark.serving --backend sglang --dataset-name random --random-input-len 1024 --random-output-len 1024 --random-range-ratio 1.0 --num-prompts 3*C --max-concurrency C --seed 20261020 --flush-cache.Pass rule. It was fixed in advance: the both-changes median must be at least the base median minus the base range for throughput, and at most the base median plus the base range for TPOT. Pooled medians over the instrumented servers (base runs 2-11, n=10; both runs 1-11, n=11):
candidate_filteredonly in the minute each server finished starting up. Every later minute of every timed 1K/1K window shows onlycandidate_unfiltered, on both trees.Single-request decode (512 output tokens, recipe settings, tok/s). These prompts, at 20K-120K tokens, are past the 16,384-token window, so they run the candidate-filtered path that the scoring change affects.
Single-request decode varies widely between repeats. The medians are higher with both changes at all three lengths, but the ranges overlap at 60K and 120K.
TP8/EP8 defaults: with both changes, single-request decode runs at 33.8-35.4 tok/s at 20K-120K. There is no baseline because base does not start.
Metadata cost: on SM120 with the c4 FP4 flag off, the metadata change builds one DeepGEMM schedule per present ratio (c1, c2) per forward, or one per row chunk when the batch is chunked. That replaces the
Noneschedule.Checklist
CI States
Latest PR Test (Base): ⏳ Run #44401964001
Latest PR Test (Extra): ⊘ Skipped -- add the
run-ci-nv-extralabel to opt in.Latest PR Test (AMD ROCm 10): ⏳ Run #44401963709
Tip
Base CI only covers the core cases, and its workload may not exercise your change. Use
/rerun-testto run the tests your change touches, or copy this prompt for an agent: