Repository navigation
Conversation
ormandj
requested review from
Alisehen,
AniZpZ,
BBuf,
DarkSharpness,
Edwardf0t1,
FlamingoPg,
HaiShaw,
HydraQYH,
OrangeRedeng,
b8zhong,
celve,
ch-wan,
mmangkad and
yuan-luo
as code owners
October 7, 2026 03:13
ormandj
force-pushed
the
sm120-mxfp8-skinny
branch
from
October 7, 2026 05:42
7719b51 to
2e33029
Compare
17 of 56 tasks
ormandj
force-pushed
the
sm120-mxfp8-skinny
branch
from
October 9, 2026 18:39
2e33029 to
1a5573c
Compare
4 tasks done
ormandj
force-pushed
the
sm120-mxfp8-skinny
branch
from
October 19, 2026 17:33
1a5573c to
7d84b0e
Compare
detain
added a commit
to detain/sglang
that referenced
this pull request
Oct 20, 2026
…ps.quantization in this tree Upstream PR sgl-project#42865 forked before ue8m0_scale moved out of ops.layernorm into ops.quantization (where dsv4_wo_a.py already imports it from). Point the new sm120_mxfp8_skinny_gemm.py at the current location; identical symbol.
detain
added a commit
to detain/sglang
that referenced
this pull request
Oct 20, 2026
…/deferred/avoid map - 3A [24-35]: NVFP4 MoE boot sgl-project#39807/sgl-project#40173, block-FP8 TP refine sgl-project#42566, k-pool indexer split sgl-project#43619, SM120 skinny GEMM sgl-project#42865/sgl-project#42867, DeepGEMM warmup guards sgl-project#32686/sgl-project#43712, autotune sgl-project#43363/sgl-project#40420, mHC overlap sgl-project#42985, FP8-einsum precompile sgl-project#42821. - 3B [36-43]: PCIe CustomAllreduce VMM sgl-project#44448, EP local expert ids sgl-project#44480, shm TP broadcast sgl-project#44202, PCIe-IPC all-gather sgl-project#42863 + multicast guard sgl-project#41888, TP-sampling consistency sgl-project#41916/sgl-project#38565, draft embed/lm_head VRAM sgl-project#37155. - sgl-project#39807 toolchain commit verified safe against our CUDA_HOME=12.9 pin (cu13 fallback needs CUDA_HOME unset AND glibc>=2.41; we are 2.39). - stack_want.txt: execution-status banner. Branch tip 5dd6ec7.
FlashInfer's SM120 MXFP8 CUTLASS GEMM has no split-K, so decode-sized GEMMs with small N run on few CTAs. Block-FP8 (32x32, UE8M0) linears served as MXFP8 now run tuned shapes at up to 16 rows on a Triton GEMM (tl.dot_scaled) that can split K with a deterministic, batch-invariant reduction, and whose activation quantization is bit-identical to flashinfer.mxfp8_quantize. SGLANG_ENABLE_SM120_MXFP8_SKINNY_GEMM=0 turns it off.
Split-K counters must now be a contiguous int32 tensor on the activation's device; anything else raises ValueError. Linear dispatch takes BF16 and FP16 activations only, the dtypes the FlashInfer MXFP8 path accepts, and the docs note that SM120 reaches the MXFP8 view only with --fp8-gemm-backend flashinfer_cutlass or flashinfer_cutedsl. Tests add FP16/FP32 inputs against the FP64 reference, counter rejection (strided view, int64, too few, CPU, missing), FP16 dispatch, and a biased layer that keeps the existing path; the CuTe-DSL case checks availability explicitly instead of skipping on any RuntimeError.
update_weights_from_disk reruns weight postprocessing without recapturing CUDA graphs by default, and _prepare_mxfp8_skinny replaced the layer's FP32 scale and split-K counter tensors each time, leaving captured launches with freed pointers. Buffers from an earlier call are now refilled in place, so captured launches see the new scales and zeroed counters. A test captures a split-K layer, reloads its weights with stale counters, takes over same-size allocations, and checks that replay matches eager.
ormandj
force-pushed
the
sm120-mxfp8-skinny
branch
from
October 29, 2026 22:19
7d84b0e to
391c2a8
Compare
Main moved mxfp8_epilogue from kernels/ops/layernorm to kernels/ops/quantization (sgl-project#45112); the rebased skinny GEMM still imported the old path.
ormandj
added a commit
to ormandj/sglang-deepseek-v41-flash-sm120
that referenced
this pull request
Oct 30, 2026
Patch 11 (sgl-project/sglang#42865 at b2182fc605) imports ue8m0_scale from main's kernels/ops/quantization (rc.2 failed the installed-image import check); the dependency gate expects the 2026-10-29 vendor base's NIXL 1.5.1. Same stack key.
Contributor
|
Thanks @ormandj. Closing this because you have 25 PRs open and none updated in 7 days, over our soft cap of 5 for idle PRs. Reopen the two or three you most want reviewed - a short active set moves faster than a long idle one. Some directories moved recently, so an older branch may need retargeting: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
On SM120, block-FP8 checkpoints with 32x32 UE8M0 scales (DeepSeek-V4.1-Flash) can be served as MXFP8 through FlashInfer's CUTLASS
mm_mxfp8. Its SM120 configs have no split-K, so at decode / speculative-verify row counts the weight read is spread over very few CTAs. For example,wqkv_a(N=1792, K=5120) runs with a 128-wide N tile on 14 CTAs of a 188-SM RTX PRO 6000 and reads its 9 MB weight at about 0.6 TB/s.Modifications
kernels/ops/gemm/sm120_mxfp8_skinny_gemm.py(registered asgemm.sm120_mxfp8_skinny_gemm): Triton MXFP8 GEMM for small M. It usestl.dot_scaled(native block-scaled MMA, E4M3 with UE8M0 scales, FP32 accumulate) and can split K across CTAs. Split-K partials go to an FP32 workspace and the last CTA of each N tile adds them in split order, so the result is deterministic. Per-layer arrival counters reset themselves, so the kernel is CUDA-graph safe, and a weight reload refills the layer's scale and counter buffers in place, so graphs captured before the reload stay valid; the counters must be a contiguous int32 tensor on the activation's device, zero on entry (not checked); a wrong dtype, device, layout or size raisesValueError. BN, BK and SPLIT depend only on (N, K), so a row's result does not change with the batch size. The weight is read in its checkpoint layout (E4M3 + FP32 power-of-two 32x32 block scales); nothing is copied. The activation is either taken prequantized asMxfp8SwizzledInput(128x4-swizzled UE8M0 scales) or quantized in-kernel from BF16, FP16 or FP32. In-kernel quantization reuses the UE8M0 helper of the fused RMSNorm+MXFP8 epilogue and is bit-identical toflashinfer.mxfp8_quantizewith the CuTe-DSL backend, which SGLang calls (tested for BF16).Fp8LinearMethod: a block-FP8-as-MXFP8 linear uses the kernel only when all of these hold:Mxfp8SwizzledInput);--enable-deterministic-inferenceis off. Below and above 16 rows the two kernels reduce in different orders, so a row's result would depend on the batch size.Everything else keeps the existing MXFP8 backend.
SGLANG_ENABLE_SM120_MXFP8_SKINNY_GEMM=0turns the path off.Backend selection: the kernel hooks the MXFP8 view of block-FP8 linears, and on SM120 that view exists only with
--fp8-gemm-backend flashinfer_cutlass(orflashinfer_cutedslwhere FlashInfer's CuTe-DSL MXFP8 GEMM supports the GPU). The SM120 default,auto, resolves tocutlass, which does not serve block-FP8 as MXFP8; 32x32-block linears then take the existing block-FP8 Triton kernel, and the automatic MXFP8 backend choice for DeepSeek-V4.1 applies to SM100/SM103 only. This PR does not change the SM120 default, so a default launch is unaffected; all measurements below use--fp8-gemm-backend flashinfer_cutlass.Tuned table: seven DeepSeek-V4.1-Flash shapes with six (BN, SPLIT, BK) configurations, four of which split K.
wqkv_a(replicated)wq_b(TP4)wo_b(TP4)wkv(replicated)wq_awkvmain_projThe shared-expert shapes (1152x5120, 5120x576) are left out on purpose. The kernel is faster on them in isolation (4.8 vs 16.5 µs and 3.3 vs 5.3 µs at M=6), but in serving they run on the MoE side stream, overlapping the routed experts, and the many-CTA split-K kernel competes with that work. Moving them back to CUTLASS raised decode steps/s by 0.4-2.6%.
Accuracy Tests
test/registered/kernels/ops/gemm/test_sm120_mxfp8_skinny_gemm.py(SM 12.0 only, registered for the 1-gpu-small runner), 63 test cases:wkvshares thewq_bconfiguration and is left out for memory. Max absolute error < 8e-3 of the largest reference value.ValueError(5 cases).flashinfer.mxfp8_quantize(CuTe-DSL and CUDA backends), and so is the prequantized path, which reads the swizzled scales. This holds at M = 1, 6, 16, 32, 48 and 128 for rows from 2^-120 to 2^30 and for edge blocks: all zero, amax/448 exactly a power of two, and amax/448 at the smallest scale. FlashInfer's CUDA backend departs from CuTe-DSL on rows below about 2^-100, so it is compared from 2^-100 up. A block whose UE8M0 scale byte is 0 quantizes to zero, as in FlashInfer. The CuTe-DSL case is skipped only whenflashinfer.cute_dsl.is_cute_dsl_available()is false; any other FlashInfer error fails the test.ColumnParallelLinearandFp8LinearMethod.applywith BF16 and FP16 activations on a split-K and a non-split shape (4 cases). Up to 16 rows (2D, 3D and, for BF16,Mxfp8SwizzledInputfrom FlashInfer's quantizer, CuTe-DSL when installed) take the kernel, and 17 rows keep CUTLASS. The kernel's output is bit-identical to calling it directly and within 1e-2 of FlashInfer CUTLASS. Split-K counters are allocated only for the shape that splits K.update_weights_from_diskdoes by default) keeps the scale and counter storage, takes the new scales and zeroes stale counters; a CUDA graph captured before the reload replays bit-identical to eager with the new weights (1 case).--enable-deterministic-inference, and the environment switch keep CUTLASS (1 case).All 63 tests pass on an RTX PRO 6000 Blackwell (torch 2.14.1+cu130, Triton 3.8.0), both with the published
flashinfer-python0.7.2 that main pins and with FlashInfer 0.7.2 built from itsmain.The serving A/B below measured decode speed only; no end-to-end accuracy comparison between kernel on and off is reported here.
Speed Tests and Profiling
Hardware: 4x RTX PRO 6000 Blackwell (SM120, 188 SMs, PCIe).
Per-call microbenchmark at M=6, in µs, for the four target-model shapes (the DSpark draft shapes were not part of this microbenchmark). The kernels replay in a CUDA graph over enough weight copies to keep L2 cold, as in a decode step. The CUTLASS column includes
mxfp8_quantizeof the activation; this kernel quantizes in-kernel.Above about 32 rows CUTLASS is faster. A serving trial that extended the kernel to 16 < M <= 64 lowered decode steps/s by 5% at batch 8/16, so the band stops at 16.
Serving A/B, kernel on (default) vs off (
SGLANG_ENABLE_SM120_MXFP8_SKINNY_GEMM=0). DeepSeek-V4.1-Flash on 4x RTX PRO 6000 Blackwell Max-Q (PCIe, 250 W power limit), TP4,--fp8-gemm-backend flashinfer_cutlass, DSpark speculative decoding, temperature 1, top_p 0.95. All runs use the same server build and configuration, which also carries changes that are not part of this PR; only this switch differs between runs. The kernel-on configuration was measured before and after the kernel-off run.Metric: steps/s is computed from SGLang's TP0
Decode batchlog lines asgen throughput (token/s) / accept len, grouped by the logged running batch size, and taken as the median over a measurement window of about 30 s after warmup. It counts sequence decode steps per second (batch decode steps per second multiplied by the batch size), so it does not depend on the acceptance length. Each configuration ran 3 repetitions; each cell gives the median of the 3 repetitions followed by the 3 values.In a verify pass the linears see M = batch x verify width rows, with a verify width of up to 6 tokens per sequence. At batch 1-2 every verify call is therefore within the kernel's 16-row band; at batch 4 and above only calls with at most 16 rows take the kernel.
At batch 1 and 2, every kernel-off repetition is below every kernel-on repetition, and the kernel-off median is about 4% lower. At batch 4, 8 and 16 the kernel-off median is 1.3-2.6% lower, but the kernel-off repetitions overlap the kernel-on ones and the two kernel-on medians differ by up to 3.1% (batch 4), so this sample does not resolve a difference at those batch sizes.
Checklist
Review and Merge Process
/tag-and-rerun-ci,/tag-run-ci-label,/rerun-failed-ciDeveloped with AI assistance.
CI States
Latest PR Test (Base): ❌ Run #40984454672
Latest PR Test (Extra): ❌ Run #40984454634
Latest PR Test (AMD ROCm 10): ❌ Run #40984454495