Repository navigation
[#20551][perf] MLA DSpark: run each drafter layer's kv path beside its q path - #20552
Draft
lucifer1004 wants to merge 3 commits into
Draft
lucifer1004 wants to merge 3 commits into
lucifer1004 wants to merge 3 commits into
Conversation
…r bookkeeping into Triton kernels TLLM_DFLASH_FUSED_PROLOGUE=1 runs the draft block-table refresh, the gen-request bookkeeping in prepare_1st_drafter_inputs, the single-latent context write, and the MLA drafter's block fixup and block-latent pool write as single Triton kernels, bit-exact with the torch code they replace. TLLM_DFLASH_OVERLAP_CONTEXT_PROJECTION=1 forks the gen tokens' context projection onto an aux stream ahead of sample/accept. Signed-off-by: Zihua Wu <13583761+lucifer1004@users.noreply.github.com>
…xup builder too With TLLM_DFLASH_FUSED_PROLOGUE=1 the block decode builds its fixup with _build_mla_block_fixup_fused, so the branch check counts either builder (and requires the fused one when the env is on); the numeric comparison is unchanged. Signed-off-by: Zihua Wu <13583761+lucifer1004@users.noreply.github.com>
…ide its q path TLLM_DSPARK_MLA_SPLIT_QKV_STREAMS=1: in the kernel block-decode paths, every drafter layer runs kv_a -> RMSNorm/RoPE -> pool write on an aux stream while the q path runs on the main stream, joined before attention. On the CuTe DSL variant the RMSNorm/RoPE kernel stores the block latents straight into the pool. Signed-off-by: Zihua Wu <13583761+lucifer1004@users.noreply.github.com>
lucifer1004
force-pushed
the
upstream/dspark-mla-qkv-streams
branch
from
October 19, 2026 03:58
fee0fb7 to
77ad5ad
Compare
This branch has not been deployed
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.
Description
Fixes #20551. Stacked on #20550, so this branch also contains that PR's commit. Review only the last commit, "MLA DSpark: run each drafter layer's kv path beside its q path".
Note: #19275 moves
cute_dsl_kernels/blackwell/dspark_rmsnorm_rope.pytoattention/kernels/blackwell/. Whichever of the two lands second updates the oneDSparkRMSNormRoPEKernelimport inmodeling_dspark.py.In
MLADSparkForCausalLM.dflash_forward, each drafter layer runs its q path and its kv path one after another on one stream, although they are independent until attention. WithTLLM_DSPARK_MLA_SPLIT_QKV_STREAMS=1, read per call and applied on the kernel block-decode paths only:input_layernorm, the layer forks to a lazily created aux stream;kv_a_proj_with_mqa-> RMSNorm/RoPE -> block write into the context pool;q_a_proj->q_a_layernorm->q_b_proj->rope_into-> k absorption;_mla_paged_attention, which skips its own block write (block_written=True).Everything the aux stream reads is produced before the fork, and everything it writes is read only after the join. The next layer's fork orders the aux stream after this layer's main-stream work.
On the CuTe DSL block-decode variant, the RMSNorm/RoPE kernel stores the block latents straight into the pool at the fixup's pages / offsets, without a staging buffer and scatter. That kernel (
_RMSNormRoPEPoolWriteKernel) isDSparkRMSNormRoPEKernelwith only the store index changed. Other variants keep the staged write.Two seams (
_split_qkv_use_aux_stream,_split_qkv_direct_pool_write) let the two halves be measured separately.Performance, Rubin, TP8 across 2 nodes (MNNVL), Kimi K3 with an MLA DSpark drafter, CUDA graphs, single request, decode step time, on top of #20550. This is a cross-job comparison, so the differences are close to cross-node noise; on a later stack, turning the switch off cost about +0.06 ms per step.
Accepted tokens per step, accuracy and needle checks were unchanged.
In a single-GPU microbenchmark (Rubin single GPU, 200-SM engineering sample, drafter forward under CUDA graph replay), it saves 56-68 µs per step at B = 1 / 4. Almost all of that comes from the two streams; the direct pool write alone saves 6-19 µs but adds about nothing on top of the streams, because it is hidden behind the q path.
Test Coverage
tests/unittest/_torch/speculative/test_dspark_cute_dsl_rmsnorm_rope.py(SM100 / SM103, inl0_b200.yml): new test that the direct pool write is bitwise what_rmsnorm_rope_batchedplus the staged scatter write (B = 1 / 4).is_fused_dspark_rmsnorm_rope_supported, and on maindspark_rmsnorm_rope_custom_op._DSV4_DSPARK_ARCH_BY_SMonly maps SM100 / SM103, so on SM107 (Rubin) the kernel path is not taken and the switch falls back to the staged write. [#20365][fix] Use the fused DSpark RMSNorm/RoPE kernels on SM107 #20366 adds SM107 to that map; validating the pool write on SM107 needs it.-p no:skipping) fails as expected there, because the fused kernel is unsupported on SM107 without [#20365][fix] Use the fused DSpark RMSNorm/RoPE kernels on SM107 #20366 and the function reports the fallback; the existingtest_fused_dspark_rmsnorm_rope_*cases fail the same way on main;test_dspark_cute_dsl_rmsnorm_rope.py+test_dflash_fused_prologue.pywith the normal skips: 17 passed, 22 skipped (the 17 are [#20548][perf] DFlash / MLA DSpark: fuse the decode-step drafter bookkeeping into Triton kernels #20550's).dflash/dsparkCPU tests have the same result as main.DSparkWorkerandMLADSparkForCausalLMat Kimi K3 per-rank shapes:PR Checklist