Repository navigation
[SM120] DeepSeek-V4: DeepGEMM paged-MQA indexer +FP4 MoE+ page-split - #29927
Conversation
…LA prefill On SM120, DeepSeek-V4 forced the sparse-MLA indexer to compute paged-MQA logits in eager torch ops (SGLANG_FP8_PAGED_MQA_LOGITS_TORCH=True), which scales with batch x context and dominates decode. Route to the DeepGEMM paged-MQA-logits CUDA kernel instead: - server_args: on SM120 stop forcing the torch fallback; also default SGLANG_OPT_FLASHMLA_SPARSE_PREFILL=False so sparse-MLA prefill uses the FlashInfer SM120 path (the unified sgl_kernel flash_mla_sparse_fwd prefill is SM90a/SM100f-only and errors on SM120). - metadata: on SM120 always use the DeepGEMM metadata kernel, never the JIT one (its dynamic-smem request exceeds SM120 limits, incl. large prefill). Requires DeepGEMM with SM120 support (deepseek-ai/DeepGEMM#324). Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
The FlashInfer SM120 sparse-MLA decode needs page_block_size=64, but the SWA KV pool uses page_size=256, so _split_kv_pages_to_64 re-lays-out the KV every decode step. It split the ENTIRE pool (~105MB/layer/step) even though sparse MLA only reads the top-k pages. Mark the pages referenced by this step's sparse indices in a fixed-size mask and have the split kernel early-return for the rest; the persistent dst buffer keeps stale contents for skipped pages (never read -> bit-identical). Static shapes -> CUDA-graph safe. Measured RTX PRO 6000, DSv4-Flash, marlin MoE, TP4, ISL=8K, CUDA graph: decode TPOT BS1/8/16 25.2/26.8/29.1 -> 13.3/14.6/17.4 ms; GSM8K unchanged. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Enable the DeepGEMM grouped-GEMM FP4 MoE runner on SM120 (--moe-runner-backend deep_gemm); marlin stays the SM120 default (faster decode), this is opt-in for prefill throughput / FP4 experts. Requires DeepGEMM with SM120 support (deepseek-ai/DeepGEMM#324): - configurer: enable JIT DeepGEMM on SM120 when the SM120 grouped-GEMM symbol is present; enable UE8M0 block scales on SM120. - moe_runner/deep_gemm + ep_moe/kernels: SM120 handling (pow2 UE8M0 FP8 quant, TMA-aligned e8m0 scales, JIT-EP-activation fallback for TP>=2, in-place swiglu_limit clamp on the Triton fallback path). - fp8/fp8_utils: contiguous scale for the layout transform; keep dense w8a8 fp8 linear off DeepGEMM on SM120. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
There was a problem hiding this comment.
Code Review
This pull request introduces compatibility and performance optimizations for SM120 (Blackwell) architectures, including page-split kernel optimizations to avoid redundant KV pool copies, custom power-of-2 FP8 quantization, TMA alignment for scales, and in-place SwiGLU clamping to reduce overhead. The review feedback highlights several critical issues, including an undefined variable _is_sm120_supported causing a NameError, potential undefined values in Triton's masked loads, compilation failures if Triton block sizes are not powers of two, and potential RuntimeErrors from calling .view() on non-contiguous tensors.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
…dexer chunking) - deepseek_v4_backend: gate SM120 off the SM90a/SM100f-only flash_mla_sparse_fwd so sparse-MLA prefill routes to the SM120 FlashInfer path instead of crashing. - flash_mla_sm120: add _flash_mla_sm120_prefill using FlashInfer _sparse_mla_sm120_paged_attention for prefill (num_tokens>64); decode path unchanged. - dsv4 indexer/metadata: chunk get_paged_mqa_logits_metadata + fp8_paged_mqa_logits by query rows (<=16384) so the DeepGEMM metadata kernel fits SM120 shared-memory cap on large batched prefill. Validated on RTX PRO 6000 (SM120), TP4 marlin: GSM8K 10q=100%, batched prefill bs1-64 works (previously crashed at bs>=4); bs1 ISL8K TTFT ~0.9s. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Two decode/prefill wins on SM120 (RTX PRO 6000), found by profiling a bs1 decode step: the triton _w8a8_block_fp8_matmul was 49% of decode time (6.5ms of 13.3ms TPOT), not NCCL (9%). 1. fp8_utils: default the SM120 FP8 GEMM backend to CUTLASS instead of (untuned) Triton. Graph-replay of the 43-layer x 7 DSv4-Flash fp8 GEMM sequence: 24-28% faster at M=1/8/64, ~24% at M=16384. 2. deepseek_v4/server_args: enable SGLANG_OPT_DEEPGEMM_HC_PRENORM on SM120, gated to M >= 1024 tokens so prefill takes the deepgemm tf32 gemm while decode keeps the (faster at small M) torch impl. This removes the previous prefill-vs-decode tradeoff of this env. TP4 marlin, ISL8K (validated on two nodes): - TTFT bs1/4/8: 1.12/3.78/6.77 -> 0.90/3.21/5.25 s - pure batched-decode TPOT (unique prompts, all-decode window, distinct KV): bs1/8/32/64 = 10.9/16.3/25.4/32.4 ms (bs64 needs --swa-full-tokens-ratio 0.2; SWA pool is the binding constraint at high concurrency since DSA topk keeps full-seq KV) - bench_serving ISL8000/OSL1000 c1: TTFT ~875ms / TPOT 10.9ms (vLLM PR#43477 TP2 reference: 718ms / 10.65ms); c32 with --mem-fraction-static 0.85: TTFT 15.1s, 591 tok/s output - GSM8K 50q accuracy 0.96, invalid 0. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
The hc_pre tail computed y = (pre.unsqueeze(-1) * x_flat.view(M, hc, H)) .sum(dim=1) in eager torch, materializing an [M, hc, H] fp32 intermediate on the prefill critical path (~7.5% of prefill kernel time as fp32 broadcast-mul + reduce). Add a fused triton kernel hc_combine (fp32 accumulate, bf16/fp32 input, direct store) in sglang/srt/layers/mhc.py and call it from deepseek_v4.hc_pre. CUDA-graph capture safe (fixed shapes per capture). TP2 marlin ISL8K A/B: TTFT bs1/4/8 = 0.920/3.308/5.406 -> 0.837/2.990/4.892 s (-9.5%); decode TPOT unchanged; GSM8K 10q 1.000. Post-fusion profile: kernel is 2.0% of prefill (was ~7.5% unfused). Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
The deep_gemm runner's masked layout allocates [num_local_experts, capacity, k] transients that scale with expert capacity and OOM at prefill chunk sizes. Add a contiguous grouped GEMM path (ep_scatter to 128-aligned expert slots + m_grouped contiguous kernels) taken when dispatched tokens >= 1024, mirroring vLLM PR#43477's DeepGEMM MXFP4 MoE prefill route. TP2 chunk8192 honest-median TTFT vs marlin: 4K 432/440, 8K 791/886, 16K 1570/1798, 32K 3191/3581, 64K 6744/7616, 128K 14537/16138 ms (-10~13%); GSM8K 50q 0.980. Decode via masked path remains slow (33.9ms bs1 vs marlin 11.5) -- use marlin for decode-heavy serving until an M-gated dual route lands. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Prefill AllReduce messages at chunk 8192 are 64MB (8192 tokens x 4096 hidden bf16), far above the 8MB _MAX_CAR_SIZE cap, so every prefill AR fell back to the NCCL ring. At world_size 2 the one-shot kernel is a single p2p hop and stays faster well past 8MB. TP2 deep_gemm 8K honest-median TTFT: 791 -> 773-781 ms; profile confirms cross_device_reduce_1stage replaces ncclDevKernel_AllReduce (160 -> 143 ms per 8K prefill). GSM8K 10q 1.000. Gated to world_size == 2 so TP4/TP8 (where one-shot traffic scales with N-1) keep the 8MB default. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
SGLANG_OPT_FIX_MEGA_MOE_MEMORY enabled use_swizzle unconditionally, but the DeepGEMM#324 SM120 contiguous grouped GEMM consumes standard-layout activations; the swizzled output of silu_and_mul_contig_post_quant reads as garbage (unit diff: fp8 byte-match 0.6% swizzled vs 96.7% standard; GSM8K 10q 0.40 -> 1.00 after fix). This was the root cause of the historic "deepgemm+fused-swiglu GSM8K 5%" regression. With the fused kernel now correct, TP2 chunk8192 honest-median 8K TTFT: 773 -> 741-744 ms (fuses the 21ms swiglu clamp + 14ms silu_mul + 9ms fp8 quant into one kernel); GSM8K 50q 0.980. vLLM PR#43477 same-node reference: 723 ms (gap 1.025x). Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Pad slots carry m_indices == -1 and are skipped by the DeepGEMM contiguous grouped GEMM; their row contents are never read (output_index only maps real rows), so the [all_tokens, K] fp8 buffer does not need a zero fill (8.4ms FillFunctor per 8K prefill). TP2 chunk8192 honest-median 8K TTFT: 741-744 -> 736-740 ms; GSM8K 10q 1.000. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
The flag cleared is_hybrid_swa, but the DSv4 KV pool always carries per-layer SWA buffers, so pool init crashed on the unset swa_max_total_num_tokens. A truly unified pool is economically identical to equal-size pools (every token pays both pools' bytes), so implement the flag as swa_full_tokens_ratio=1.0 with a log line. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
>1 is meaningful for models whose full-attention KV lives mostly in separate compressed pools (DSv4: c4/c128), leaving the SWA pool as the per-request-dominant consumer. Measured on DSv4 TP2: ratio 2.0 gives the best 8K BS8 serving cell (TTFT 3748->3471ms, TPOT 17.1->13.4ms), though it shrinks the full pool enough to hurt 16K BS8 - workload-dependent. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
|
Tested selected commits on SGLang main
I also screened the current cross-layer fused-MHC path with
In the 128 MiB trace, custom AR takes 2.992 s, 23.27% of extend wall, and each With released
The grouped-FP4 symbol does not establish SM120 support for the Final selected stack, excluding the 128 MiB custom-AR change and DeepGEMM
|
Drop benchmark numbers and restated-code comments flagged in review of the sibling PR; reword the SM120 DeepGEMM probe comment now that DeepGEMM#324 is merged (installed builds may still predate it). Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
The contiguous grouped-GEMM prefill path is only viable with the fused swiglu+quant kernel (the unfused fallback keeps a bf16 [all_tokens, N] transient alive across the FC2 GEMM); with the swizzle fix it is also the accurate path. Respect an explicit user setting. Validated without the env: TP2 8K TTFT 741ms (fused-path speed), GSM8K 10q 1.000. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Covers ue8m0 x swiglu_limit x M against the unfused reference (fp8 byte agreement; accuracy parity where fp32 scale storage conventions differ), and pins the standard output layout as the contract: the swizzled layout is not consumed by the SM120 DeepGEMM contiguous grouped GEMM and regressed GSM8K 1.00 -> 0.40 before the use_swizzle fix. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Review findings on the PR branch, all one theme — changes needed for SM120 were left unconditional: - contiguous MoE path: only take it when all experts are local (the standard dispatcher maps non-local experts to -1 under EP, which bincount/scatter cannot handle); count expert slots with a masked index_add_ instead of bincount, which also removes a per-layer GPU->CPU sync; preserve the activation dtype in the gather instead of hardcoding bf16; drop a duplicated use_jit_ep_activation guard - use_swizzle: keep the swizzled activation layout everywhere except SM120 (the SM100 masked GEMM consumes swizzled) - custom allreduce 128MB max_size: PCIe-only 2-GPU groups; NVLink TP2 keeps the 8MB default (avoids ~360MB/rank of extra buffers) - should_deepgemm_weight_requant_ue8m0: False on SM120 — dense block-FP8 GEMMs route to CUTLASS/Triton there, which expect fp32 scales; clarify the DeepEPMoE assert for the unsupported FP8-experts + standard-dispatch combination TP2 regression after the batch: config P GSM8K 20q 0.950 / 8K TTFT 725-731ms; config D GSM8K 20q 1.000 / c1 TPOT 6.41ms accept 2.75. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
- SGLANG_OPT_DEEPGEMM_HC_PRENORM is now set from a configurer probe of deep_gemm.tf32_hc_prenorm_gemm (same idiom as the SM120 grouped-GEMM probe) instead of unconditionally, so older DeepGEMM builds fall back to the torch impl instead of failing on the first large prefill - chunked indexer metadata is identical for every layer in a forward pass; compute the per-chunk list once in PagedIndexerMetadata instead of per layer (~61x) in the indexer, and drop the sentinel - pow2 quant kernel: remove the dead bounds check (launch grid is exactly (M, num_groups)) and the now-unused M parameter Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Notable resolutions against the refactored main: - page-split buffers migrated to the new ctx.resources registry (main already carries the whole-pool split; our dirty-mask ref-mask moved to a shared _build_ref_page_mask helper on the same registry) - chunked SM120 indexer re-integrated into the NonPagedIndexerPlan dispatch (per-chunk metadata list computed once in PagedIndexerMetadata; sentinel removed) - DSv4 arg defaults moved to the overrides registry (disable_hybrid_swa_memory conversion + swa ratio); env writes stay in the residual hook per its policy (MEGA_MOE default for deep_gemm) - swa-full-tokens-ratio validation merged with main's _resolved() semantics, limit raised to 4.0 - _per_token_group_quant_fp8_pow2 deleted: superseded by main's fused per_token_quant_fp8_ue8m0_scatter (use_mxfp8) path - masked-path swiglu handling follows main (gemm1_alpha/clamp native in silu_and_mul_masked_post_quant_fwd); pre-commit formatting reapplied Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
…per index `_page_mark_kernel` launched one program per index and each program did a single load plus a single store; the `BLOCK` parameter was passed but unused (the call site said as much: "BLOCK (unused, kept for JIT signature)"). At ISL 8K the grid is tens of thousands of near-empty blocks. Process BLOCK indices per program with a masked load/store, dropping the grid by three orders of magnitude. The mask `valid & (idx >= 0)` reproduces the two early returns exactly. Measured on 4x RTX 6000D (SM120), TP4, deepseek-ai/DeepSeek-V4-Flash-0731, --moe-runner-backend flashinfer_mxfp4, ISL 8K / OSL 256 / BS1, median of 3: before TTFT 914.61 ms TPOT 11.12 ms GSM8K-50 0.960 after TTFT 882.00 ms TPOT 11.12 ms GSM8K-50 0.960 TTFT -32.6 ms (-3.6%); TPOT unchanged, as expected -- page-split runs in prefill. In a torch profile of that workload the kernel was 35.8 ms over 2795 launches (2.1% of GPU kernel time). Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
SM120 forced the TileLang MHC pre kernel off, so hc_pre fell back to the torch
path. That path does
x_flat = x.flatten(1).float()
which materialises [tokens, hc_mult * hidden] in fp32 -- 8192 x 16384 x 4B =
512 MB at ISL 8K -- once per layer, and its fp32 F.linear then dispatches to
cutlass_80_simt_sgemm, i.e. no Tensor Core. In a torch profile of ISL 8K on
4x RTX 6000D that fallback accounted for ~208 ms of GPU kernel time across four
kernels (43 layers x 2 launches each):
unrolled_elementwise (the .float() copy) 57.0 ms / 151
vectorized_elementwise 70.4 ms / 86
cutlass_80_simt_sgemm (fp32 F.linear) 40.7 ms / 86
reduce_kernel (.square().mean(-1)) 39.6 ms / 86
With the TileLang kernel the first, third and fourth disappear entirely and GPU
kernel time drops 1695.6 -> 1458.6 ms.
The kernel itself already works here -- the warp-specialization workaround in
this PR is what makes it compile on SM120 -- so the off default was leaving that
work unused.
Measured on 4x RTX 6000D (SM120), TP4, deepseek-ai/DeepSeek-V4-Flash-0731,
--moe-runner-backend flashinfer_mxfp4, BS1, median of 3:
ISL TTFT off -> on TPOT off -> on
8K 882.91 -> 670.39 ms -24.1% 11.08 -> 10.38 ms -6.3%
32K 3644.07 -> 2810.75 ms -22.9% 11.59 -> 10.90 ms -6.0%
128K 16864.04 -> 13546.18 ms -19.7% 12.98 -> 12.27 ms -5.5%
GSM8K-50 0.960 in both cases. Still env-overridable, as the surrounding knobs are.
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
This reverts commit 5072b0c.
Context for the revert in 383b9d7. Upstream landed 1af761a ("[SM12x] Default the fused MHC post+pre path on", sgl-project#34019), which defaults SGLANG_OPT_FUSE_MHC_POST_PRE on for SM12x. That path already covers SM120 -- the gate reads FUSE_MHC_POST_PRE and USE_TILELANG_MHC_POST and (USE_TILELANG_MHC_PRE or is_sm120_supported()) so the standalone pre flag is not needed once the fused path is on. Measured on 4x RTX 6000D, TP4, DeepSeek-V4-Flash-0731, flashinfer_mxfp4, BS1: config TTFT 8K TTFT 32K TPOT GSM8K-100 both off (the stale baseline) 881.17 3639.09 10.85 0.950 FUSE_MHC_POST_PRE=1 (upstream) 673.06 2826.30 9.86 0.950 USE_TILELANG_MHC_PRE=1 (mine) 673.37 2816.43 10.15 0.950 both 673.72 2823.01 9.87 0.970 Same TTFT, and upstream's fused path is 2.9% better on TPOT. Enabling both adds nothing over upstream alone, so the reverted commit was redundant and slightly worse. The -24% figure in the reverted commit message was measured against a baseline that no longer exists upstream: this branch predates sgl-project#34019, so its "off" state fell through to the torch fp32 fallback. The fallback analysis itself still holds -- x.flatten(1).float() materialises [tokens, hc_mult*hidden] in fp32 and its F.linear lands on a SIMT GEMM -- upstream just fixes it by a different route. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Four conflicts, resolved as follows. deep_gemm.py -- upstream sgl-project#34926 replaced the SGLANG_OPT_FIX_MEGA_MOE_MEMORY env gate on use_swizzle with `get_moe_a2a_backend().is_megamoe()`. Our SM120 hook hangs off the same assignment but answers a different question (SM120's contiguous GEMM takes standard-layout activations only), so the two are ANDed: self.use_swizzle = ( get_moe_a2a_backend().is_megamoe() and deep_gemm_sm120.use_swizzle() ) server_args.py -- both sides changed the SM120 block for different reasons. Upstream sgl-project#34019 added the SGLANG_OPT_FUSE_MHC_POST_PRE default; this branch had made the surrounding knobs env-overridable. Kept both. indexer.py -- upstream sgl-project#34926 dropped SGLANG_TOPK_TRANSFORM_512_TORCH. Kept this branch's chunked run_topk_transform refactor and removed the deleted env from its condition. paged_mqa_metadata.cuh -- took upstream wholesale. Upstream sgl-project#25855 rewrote the kernel into tiny/small/multi-block paths; the single smxx_paged_mqa_logits_metadata kernel this branch clamped shared memory for no longer exists, and the new paths do not request over-limit dynamic smem at all (no cudaFuncSetAttribute in the file). The clamp had nothing left to clamp. Symbol audit after resolution -- envs deleted upstream have no remaining references (SGLANG_OPT_FIX_MEGA_MOE_MEMORY, SGLANG_OPT_USE_DEEPGEMM_MEGA_MOE, SGLANG_TOPK_TRANSFORM_512_TORCH, SGLANG_OPT_USE_OLD_COMPRESSOR, SGLANG_OPT_DPSK_V4_RADIX: 0 each), and this PR's symbols are intact (deep_gemm_sm120 6, allows_masked_standard_layout 2, _SM120_INDEXER_M_CHUNK 7, _page_mark_kernel 2). Not yet re-validated on hardware; that is the next step. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Two lint failures introduced by merging current main: - ruff now rejects the quoted forward references in deep_gemm_sm120.py; both names are already imported, so the quotes were never needed. - check-registered-tests rejects the legacy `suite="nightly-kernel-1-gpu"` registration. Per its own diagnostic that name "matches no suite the PR-test workflows invoke, so the test silently never runs", so this line was dead; the base-b-kernel-unit registration above already runs the test in PR CI. Dropped rather than converted to `stage="nightly"`, which would add a nightly run that never previously happened. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
|
@Fridge003 Thanks for the review — replied to each inline thread. Accuracy results below. Accuracy on sm100/sm103 + sm120 with
|
| metric | value |
|---|---|
| AIME25 pass@1, mean of 16 repeats | 98.96% (475/480) |
| per-repeat spread | min 93.3%, max 100%, stdev 2.01% |
| problems solved in all 16 repeats | 25 / 30 |
truncated generations (finish_reason != stop) |
0 |
| wall clock / output throughput | 31.6 min / 2072 tok/s |
Hardest items, each missed once in 16: aime25-6, -13, -14, -22, -23 (93.75% each).
Two notes on how to read this number:
--thinkingdid not take effect.chat_template_kwargs.thinking=trueis recorded
in the run metrics and was accepted by the server, butnum_reasoning_tokensis 0 for
every one of the 480 samples andreasoning_contentcomes backnull. The answers are
genuinely produced (mean 8078 generated tokens, allfinish_reason=stop), so the
accuracy stands on its own — but this is presumably not the thinking-mode path you
intended to measure. Happy to re-run if there is a different flag or chat template for
it on this checkpoint.- The
deepseek-ai/DeepSeek-V4-Flash-0731config declaresquant_method: fp8
(fmt: e4m3,scale_fmt: ue8m0), and the server auto-detects
is_fp4_experts=Truefor the routed experts.--moe-runner-backend flashinfer_mxfp4
was accepted without complaint.
sm103 — cannot run
No B300/GB300 available here.
sm120 — done, but not on your command as written
4x RTX 6000D (SM120), TP4:
| metric | sm100 (B200) | sm120 (RTX 6000D) |
|---|---|---|
| AIME25 pass@1, mean of 16 | 98.96% (475/480) | 98.33% (472/480) |
| per-repeat spread | 93.3–100%, stdev 2.01% | 86.7–100%, stdev 3.65% |
| truncated | 0 | 0 |
| wall clock / throughput | 31.6 min / 2072 tok/s | 85 min / 798 tok/s |
Accuracy is on par. Two changes were required to get sm120 to run at all, and both are
worth your attention:
1. DSPARK does not start on sm120 with this PR as it stands. Graph capture aborts:
Check failed: (ok) is false: Unsupported sparse-MLA prefill configuration:
model=DSV4 num_heads=16 topk=192 page_block_size=64
FlashInfer's sparse_mla_sm120_prefill.cu only instantiates topk ∈ {128, 512, 1024,
2048}, while DSPARK's swa_window + block_size aligns to 192. num_heads=16 itself is
fine. The number above came from a local patch that widens an uninstantiated index width
to the next instantiated one (192 -> 512, tail is -1 and masked per row via
topk_length, so it only costs padding). That patch is not in this PR. Happy to add
it here, or send it separately — your call on scope, given you just asked me to make this
PR smaller.
2. --mem-fraction-static 0.90 does not fit an 85 GB card. 0.90 OOMs during graph
capture; 0.85 boots but dies mid-run in hc_pre_torch_impl with 0.11 GiB free. The
numbers above use 0.80 plus --num-threads 32 on the client. So the sm120 column is
not the identical configuration as sm100 — flagging rather than presenting them as one
run.
thinking mode — did not engage on either arch
Same on both: num_reasoning_tokens is 0 for all 960 samples and no generation contains
a <think> block; the models reason inline in content instead (mean ~8.1k / ~8.5k
generated tokens, every sample finish_reason=stop).
Root cause: this checkpoint ships no Jinja chat template — the model card says so
explicitly and points at the encoding/ folder with encode_messages(..., thinking_mode="thinking", reasoning_effort=...). The server logs
No chat template found, defaulting to 'string' content format, and reasoning_parser
is unset. sglang does have a dsv4 encoder path (serving_chat.py ->
chat_encoding.resolve_chat_encoding_spec returns "dsv4" for DeepseekV4*
architectures), so the plumbing exists — but with the command as given, thinking is not
what got measured.
Both numbers are still valid as accuracy measurements; they are just not thinking-mode
measurements. If you want the thinking path specifically, please advise which flags you
use (--reasoning-parser? a chat_template_kwargs variant?) and I will re-run both.
CI: lint now passes on b19fd53b92. The remaining checks are all the 4–7s admission gates waiting on a run-ci label — could you add it so the real test suites can run? This PR has never had them execute.
|
/rerun-test test/registered/models_e2e/test_deepseek_v4_flash_fp4_b200.py test/registered/models_e2e/test_deepseek_v4_flash_fp4_megamoe_b200.py |
|
Results for 🚀 |
…gl-project#29927) Co-authored-by: Baizhou Zhang <[email protected]>
Motivation: a 4x RTX PRO 6000 Blackwell (SM120) box can hold DeepSeek-V4-Flash, but on
current main the only configuration that starts there is the slow torch fallback — this PR
makes the DeepGEMM and FlashInfer paths work on SM120, cutting decode latency up to 3.4x.
It routes the sparse-MLA indexer to DeepGEMM's paged-MQA-logits kernel, enables batched
sparse-MLA prefill through FlashInfer, and unblocks the DeepGEMM FP4 MoE backend.
Split out of this PR
Following @Fridge003's review, the changes here that were not SM120 enablement now have
their own PRs:
This PR now depends on #35116: without it the page-split buffer is allocated under
inference mode during autotune and CUDA graph capture cannot write to it. Will rebase once
it lands.
The E2E tables below were measured with #35118 still in this tree. Measured separately on
the same box with only that kernel toggled (ISL 8K, BS1, TP4, deep_gemm MoE), it accounts
for 3.2% of the TPOT gain (12.81 -> 12.40 ms, two repeats each, run-to-run spread
0.01 ms) and roughly 2% of TTFT. Discount the tables by that much, or land #35118 first to
reproduce them as written.
What is in it
kernel instead of the eager-torch fallback that scales with batch x context and dominates
decode. Opt in with
SGLANG_FP8_PAGED_MQA_LOGITS_TORCH=0 SGLANG_OPT_USE_TILELANG_INDEXER=0._sparse_mla_sm120_paged_attention; indexer metadata is chunked at M=4096 (the DeepGEMMrow cap is SKU-dependent) and built once per batch instead of per layer.
_split_kv_pages_to_64re-laid out the whole SWA KV pool(~105 MB/layer) every decode step; now only the pages this step's top-k references are
split (CUDA-graph safe, bit-identical).
of hard-disabling DeepGEMM at
sm==120, plus the contiguous grouped-GEMM prefill path,the UE8M0 pow2-scale quant fix, and the swiglu-clamp fallback for TP>=2 shapes.
mhc_precompile fix, and the paged-MQA metadata kernel now sizes its shared-memoryrequest from the device budget instead of a fixed 128 KB.
Non-SM120 architectures are unchanged: every behavioural change is either gated on
is_sm120_supported()or is a fix that only engages where the previous code was wrong(the UE8M0 pow2-scale quant and the shared-memory cap).
E2E benefit
"main" is marlin MoE + the torch paged-MQA fallback, because that is the only SM120 path on
14bd315dthat starts: the default (flashinfer_mxfp4+ TileLang indexer) dies in theTileLang JIT for
sm_120a(TileLang ships nvcc 13.3,lmsysorg/sglang:dev-cu13has CUDA 13.0headers), and
--moe-runner-backend deep_gemmraisesAttributeError: module 'sglang.srt.layers.deep_gemm_wrapper' has no attribute 'get_mn_major_tma_aligned_tensor'(SM120 disables
ENABLE_JIT_DEEPGEMMwhile the runner stays selectable).Both sides then run identical server args, only the tree differs: TP4, marlin MoE, CUTLASS
FP8, chunked prefill 8192,
--disable-radix-cache, and no speculative decoding exceptwhere the tables say otherwise. 4x RTX PRO 6000
Blackwell (SM120, 96 GB, PCIe), DeepSeek-V4-Flash, OSL 256,
--warmup-requests 0so everymeasured request is a real prefill. TTFT is a median.
Single request (BS=1) — 3 sequential requests, median. TTFT:
TPOT, without and with MTP-2 (EAGLE, 2 steps / 3 draft tokens) on both sides:
Accepted length is within 0.2 of each other on the two sides at every context length, so the
MTP gain comes from the decode path itself, not from better speculation.
Concurrent (ISL 8K) —
--num-prompts BS --max-concurrency BS:TTFT holds at −20% across batch sizes; the decode multiple decays with batch (3.4x at BS1,
1.8x at BS16) because what this PR removes is per-step fixed cost, which amortises as the
batch grows. Speculative decoding amortises it the same way.
GSM8K (50 questions) is 0.980 on main and 0.960 on this PR at 8K — one question apart.
All tables are without prefill context parallelism, which is upstream code this PR does not
touch.
Recipes
Common to both:
--fp8-gemm-backend cutlass --chunked-prefill-size 8192 --max-prefill-tokens 8192 --swa-full-tokens-ratio 0.15 --cuda-graph-max-bs 32,plus
SGLANG_SM120_FLASHMLA_BACKEND=flashinfer SGLANG_FP8_PAGED_MQA_LOGITS_TORCH=0 SGLANG_OPT_USE_TILELANG_INDEXER=0.Prefill-optimised —
--moe-runner-backend deep_gemm --mem-fraction-static 0.85,SGLANG_OPT_FIX_MEGA_MOE_MEMORY=1 SGLANG_OPT_DEEPGEMM_HC_PRENORM=1.Decode-optimised —
--moe-runner-backend marlin --mem-fraction-static 0.90 --speculative-algorithm EAGLE --speculative-eagle-topk 1 --speculative-num-steps 2 --speculative-num-draft-tokens 3,SGLANG_OPT_USE_TILELANG_MHC_PRE=1.Dependencies
what
lmsysorg/sglang:dev-cu13currently ships.fp8_paged_mqa_logitsindexer path additionally needs DeepGEMM's attention host-gates toaccept SM120 (a 3-line arch gate, not yet upstream in sgl-project/DeepGEMM); without it,
keep the TileLang indexer default.
Tests
test/registered/kernels/ops/attention/test_silu_and_mul_contig_post_quant.py(9 cases,registered for CI) covers the fused swiglu-clamp + silu_mul + fp8-quant kernel against a
reference. GSM8K numbers are from
sglang.test.few_shot_gsm8k.Reviewed and validated with @ormandj (conflict resolution) and @moxcat (inference-mode
buffer fix, now #35116) on 2x and 4x RTX PRO 6000 Blackwell.
Re-validated after the split on 4x RTX PRO 6000 Blackwell, FlashInfer 0.6.15.post1 (the
pinned version), this tree plus #35116: GSM8K-50 1.000 with
--moe-runner-backend deep_gemm, 0.960 with MTP-2; ISL 8K BS1 TTFT 116/88 ms, TPOT 12.8/7.3 ms.CI States
Latest PR Test (Base): 🚫 Run #33691107019
Latest PR Test (Extra): 🚫 Run #33691106716
Latest PR Test (AMD ROCm 7.2): 🚫 Run #33691106965