[Kernel] Add KDA NVFP4 GEMM for Qwen3.x on SM120 - #36865
Merged
Merged
Conversation
BBuf
requested review from
Alisehen,
AniZpZ,
DarkSharpness,
Edwardf0t1,
FlamingoPg,
HaiShaw,
HydraQYH,
OrangeRedeng,
b8zhong,
celve,
ch-wan,
mmangkad and
yuan-luo
as code owners
August 28, 2026 12:48
Collaborator
Author
|
/tag-and-rerun-ci |
Co-authored-by: Song Bian <biansonghz@gmail.com>
BBuf
force-pushed
the
bbuf/kda-nvfp4-gemm
branch
from
August 28, 2026 13:51
c59750a to
dc04b61
Compare
This was referenced Aug 29, 2026
Co-authored-by: Cursor <cursoragent@cursor.com>
ModelOpt now dispatches the SM120 GEMM from the E2E shape allowlist. Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Replace the pybind11 cpp_extension loader with sglang.kernels.jit load_jit. Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
7 tasks
StevenChenSE
pushed a commit
to StevenChenSE/sglang
that referenced
this pull request
Sep 6, 2026
Co-authored-by: Song Bian <biansonghz@gmail.com> Co-authored-by: Cursor <cursoragent@cursor.com>
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.
Summary
python/sglang/kernels/kda_kernelsas the home for kernels generated by kernel-design agents and register their provenance asKernelBackend.KDA.sglang.kernels.opsas the stable public facade.516c976cee824a236679adf6eb525275a0a9a120.This supersedes #36043, which has been closed.
Production dispatch contract
The Qwen3.5 decode fast path accepts
M in {1, 2, 4, 8}for these exact(K, N)pairs:Qwen3.5
M=9remains callable through the low-level API for testing but is not production-dispatched. Qwen3.8 keeps its deliberately narrow production path: only the DSpark-qualified down projection(M, K, N) = (9, 17408, 5120)dispatches to KDA. The captured Qwen3.8 M=1/M=9 decode and M=4369 prefill shapes remain available through the low-level API.All paths also retain the exact dtype, layout, device, and SM120 capability gates. Unsupported Cartesian combinations fall back to FlashInfer.
Why Qwen3.8 remains narrow
The original isolated-GEMM policy persisted each layer's 5.6--11 MiB weight-scale tensor in L2. That helped repeated single-kernel benchmarks but displaced attention/SSM state in the complete serving pipeline. Enabling every captured Qwen3.8 decode shape preserved acceptance but regressed end-to-end output throughput by 0.76%.
Streaming both the one-pass FP4 weights and their scales, then dispatching only
(9, 17408, 5120), changed the three-round Qwen3.8-27B DSpark mean from 128.35 to 129.60 output tok/s (+0.98%) with unchanged accept length and fixed-prompt output.The Qwen3.5 paths are not inferred from that microbenchmark. They have their own model-specific shape allowlist, CUDA Graph correctness coverage, and end-to-end concurrency sweep below.
Qwen3.5 SM120 validation
Hardware and software:
2.13.0+cu130flashinfer-python==0.6.18; stale 0.6.17 cubin/JIT-cache packages were removed rather than bypassing FlashInfer's package-version guardAxionML/Qwen3.5-4B-NVFP4at4521f321dc8c46d255929203ae6d3062e51d52faAxionML/Qwen3.5-9B-NVFP4at97aef92393f126bf649f310cd40861be8dad3279GPU correctness and CUDA Graphs
GPU correctness on SM120 was checked against FlashInfer for Qwen3.5 M=1/2/4/8/9 decode shapes, Qwen3.8 decode/prefill, CUDA Graph replay, ModelOpt dispatch, and unsupported-shape fallback.
The multi-weight benchmark rotates eight distinct weights inside a CUDA Graph, alternates FlashInfer/KDA timing order across five trials, and uses the median per-call latency. All 20 Qwen3.5 rows passed
rtol=1e-2,atol=2e-2.The geometric-mean speedup is 1.319x across the 16 production-dispatched M=1/2/4/8 rows and 1.318x across all 20 rows.
End-to-end concurrency sweep
Protocol: 32 fixed-seed
random-idsrequests per round, 2048 input tokens, 512 output tokens, concurrency 1/2/4/8, cache flush before every round, three baseline rounds, three KDA rounds, and one adjacent baseline round. Every formal round completed all 32 requests (65,536 input and 16,384 output tokens).Adjacent-baseline throughput stays within 0.32% of the original baseline mean. TTFT changes range from -1.93% to +3.57%, while TPOT and total E2E latency improve at every concurrency, consistent with a decode-focused kernel.
Validation summary
KDA ownership and per-kernel provenance are documented in
python/sglang/kernels/kda_kernels/README.md.Related benchmark protocol: #34934.
CI States
Latest PR Test (Base): 🚫 Run #33539263034
Latest PR Test (Extra): ❌ Run #33539262840
Latest PR Test (AMD ROCm 7.2): ⏳ Run #33539263039