[Perf][DSv4.1] Native-head Triton sparse MLA for SM90 few-head prefill - #57673
Open
positive666 wants to merge 3 commits into
Open
positive666 wants to merge 3 commits into
positive666 wants to merge 3 commits into
Conversation
Hopper FlashMLA sparse prefill only accepts h_q in {64, 128}. DSV4.1-Flash
TP8 has 8 local Q heads, so BF16 prefill currently pads 8 to 64. Decode FP8
still needs that pad; prefill does not. Use a native-head kernel when s_q
is at least 2048. Default on; set VLLM_DSV41_FEWHEAD_PREFILL=0 to restore
the padded path.
Signed-off-by: Cheng Rui <286040359@qq.com>
positive666
requested review from
AndreasKaratzas,
DarkLight1337,
WoosukKwon,
mgoin,
tlrmchlsmth,
yewentao256,
ywang96 and
zyongye
as code owners
September 19, 2026 07:45
Match serving: non-contiguous q/out views, in-place out=, s_q 64/2048/8192, and the 2048 MIN_SQ gate boundary. Signed-off-by: Cheng Rui <286040359@qq.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.
Purpose
SM90 FlashMLA sparse prefill (
flash_mla_sparse_fwd) tiles WGMMA withB_H=64, so the kernel only acceptsh_qin{64, 128}. DeepSeek-V4.1-Flash under TP8 has 8 local Q heads, and prefill currently zero-pads 8 → 64. Decode FP8 still needs that width. BF16 prefill does not: most of the QK/PV work is dummy heads.This PR adds a Triton sparse MLA kernel that runs at native
h_qfor those prefill chunks. Decode stays on padded FP8 FlashMLA.The path is on by default, and only used when:
0 < n_local_heads < padded_heads(the pad-64 / pad-128 case)s_q >= VLLM_DSV41_FEWHEAD_MIN_SQ(default 2048)Short prefills stay on FlashMLA.
VLLM_DSV41_FEWHEAD_PREFILL=0restores the old path.This is not covered by #47629 (SM80/SM121 Triton MLA backend), #54929 (SM12x fallback), or #54592 (Q8KV8 sparse prefill). None of those skip SM90 pad-64 FlashMLA prefill for DSV4.1 TP8.
Test Plan
Kernel tests compare native
h_q=8against pad-64 FlashMLA ats_qin{64, 2048, 8192}using the production layout: non-contiguousq[:, :8]/out[:, :8]views into a pad-64 buffer,out=in-place, andtopk_length=512. The wrapper test also uses a dim-0 slice of a larger token buffer, matching_forward_prefill.Serving A/B on 8×H20, TP8, DSpark 5, same launch flags, uncached prompts. Those numbers were collected on frozen image
dsv41-flash-h20:d-bb550774-pr56697-r2with this kernel overlaid; the in-tree tests above are the checks for this PR SHA.MIN_SQ=2048, so 512 stays on FlashMLA)VLLM_DSV41_FEWHEAD_MIN_SQ=0so every prefill chunk, including 15-token turns, uses the kernelTest Result
Kernel vs pad-64 FlashMLA (
h_q=8,d=512, combined topk 640,attn_sink+topk_length). In-tree tests on H20 ats_q64/2048/8192 with non-contiguousq[:, :8]/out[:, :8]andout=: mean_abs 3.4e-5, max_abs 3.91e-3. Isolated 8192-token chunk ~1.51× vs pad-64.Closed-loop throughput (
MIN_SQ=2048, 0 errors). Token counts are identical on both arms, so the relative gain is wall-clock only.tok/sbelow is(prompt + completion) / wall; output tok/s iscompletion / wall.DSpark accept: C16 0.355 → 0.377; C4 0.412 → 0.395.
Cold TTFT (n=3, uncached): 32k 3.49s → 3.22s (−7.8%); 128k 15.38s → 14.30s (−7.0%).
512-token short requests at the production gate (
MIN_SQ=2048) stay on FlashMLA. After an 8k prefill, 512 e2e was 0.304s → 0.293s (n=5). The before-8k 512 set moved with DSpark accept noise (one sample), not the Triton path.GSM8K,
MIN_SQ=0: 1275/1319 → 1277/1319. Spec accept rate 0.589 → 0.594. Five items flipped baseline-correct / few-head-wrong and seven the other way. This is a no-collapse check, not a claim of exact quality equivalence.AI assistance was used for coding and testing.