Repository navigation
[Perf] [NVIDIA] kimi-k3: Route draft/dense bf16 GEMMs to TGV and narrow the MLA output gate vector - #46468
Merged
kpham-sgl merged 1 commit intoOct 26, 2026
Conversation
… vector (sgl-project#36) Route three more Kimi-K3 TP8 per-rank bf16 GEMM shapes (M <= 8) to the CuTe DSL TGV kernel instead of cuBLAS: DSpark draft down_proj (7168x1792), draft o_proj (7168x512) and the dense-layer gate_up (8448x7168). Draft down_proj was the one kernel measurably slower on Rubin than on B200. Halve the MLA output-gate vector width (8 -> 4 bf16 per thread), doubling the CTA count for the [8, 12, 128] verify tile. Output stays bit-exact. CUDA-graph us/call, cold weights, M=7 (draft) / 8: | op | SM107 before | SM107 after | SM100 before | SM100 after | |---------------------------|--------------|-------------|--------------|-------------| | draft down_proj 7168x1792 | 6.23 | 3.90 | 5.64 | 4.77 | | draft o_proj 7168x512 | 3.00 | 1.92 | 3.07 | 2.53 | | dense gate_up 8448x7168 | 14.07 | 13.70 | 19.47 | 18.95 | | mla_output_gate | 1.28 | 1.02 | 1.29 | 1.07 | End to end on Rubin TP8 (2x4 SM107, NVFP4 + fp8 KV, DSpark, bs1, 8k in / 1k out): 645.6 -> 647.7 / 651.7 output tok/s, ITL 1.55 -> 1.53 ms (single runs; ~25 us/step expected on an 8.5 ms step). Co-authored-by: Claude Opus 5.5 <[email protected]> (cherry picked from commit 33d6cea13e5552359803374096907df7206c5b64)
Collaborator
Author
|
/rerun-test test_mla_output_gate.py test_cutedsl_bf16_gemm.py |
kpham-sgl
requested review from
BBuf,
DarkSharpness,
HaiShaw,
HydraQYH,
celve and
yuan-luo
as code owners
October 25, 2026 21:02
Contributor
|
🚀 |
Collaborator
|
cc @leejnau |
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
A per-kernel comparison of Kimi-K3 NVFP4 target verify (bs=1, 8 tokens, TP8 per-rank shapes) found three small-M bf16 GEMMs still on cuBLAS where TGV is faster, and an MLA output gate launch with too few CTAs for its
[8, 12, 128]tile.Modifications
cutedsl_bf16_gemm.py: add(7168, 1792)DSpark draft down,(7168, 512)draft o_proj and(8448, 7168)dense gate_up to_K3_TGV_WIN_SHAPES. The table only applies at M <= 8, so this affects decode and verify.mla_output_gate.cuh: 4 bf16 per thread instead of 8, doubling the CTA count. Output is bit-exact.Accuracy Tests
mla_output_gate: bit-exact against the torch reference for T in {1, 2, 5, 8, 16, 128, 1024}.test_mla_output_gate.pyOK andtest_cutedsl_bf16_gemm.py462 passed on both SM107 and GB300 (SM103).Speed Tests and Profiling
CUDA-graph us per call with cold weights (rotated past L2). M=7 for the draft shapes, M=8 otherwise.
About 25 us per decode step in total; end to end it is within run-to-run noise (SM107 TP8, bs=1, 8k in / 1k out: 645.6 vs 647.7 / 651.7 tok/s single runs), with the trace confirming the new kernel selection.
Checklist
test_mla_output_gate.pyandtest_cutedsl_bf16_gemm.pycover both changes).🤖 Generated with Claude Code