Repository navigation
[Feat] kimi-k3.1: DSPARK and DFLASH under decode context parallelism - #48739
Merged
Merged
Conversation
41 of 42 tasks
kpham-sgl
marked this pull request as ready for review
November 5, 2026 22:43
kpham-sgl
requested review from
1am9trash,
Fridge003,
Qiaolin-Yu,
Ying1123,
alphabetc1,
ch-wan,
fzyzcjy,
hanming-lu,
hnyls2002,
huangtingwei9988,
hubertlu-tw,
hzh0425,
ispobock,
kkHuang-amd,
merrymercy,
xiezhq-hermann and
yizhang2077
as code owners
November 5, 2026 22:43
kpham-sgl
requested review from
BBuf,
Edwardf0t1,
HaiShaw,
YAMY1234,
hebiao064 and
rainj-me
as code owners
November 5, 2026 22:43
…oject#48414 Copy the speculative hunks of the Kimi-K3.1 Day-0 branch's DCP runtime onto the DCP decode port as they are: DSA target verify returns per-rank partials, the verify rows' local lengths (DG-native on SM100), the DSPARK and DFLASH branches of the Kimi-K3.1 DCP override, and DFLASH MLA drafts on the MLA-only draft backends under DCP. Follow-up commits adapt it to main.
…sl_mla - The draft-backend check loads the draft config with get_config and reads parse_dflash_draft_config(...).is_mla, as main's trtllm_mha check does, instead of the source's is_dflash_mla_draft_config. - Only cutedsl_mla is an MLA-only DFLASH draft backend here; trtllm_mla needs the sliding-window draft table work that is not ported. - The DFlashMLAAttention comment points at mla_attention_dcp_size, which keeps a DCP MLA draft on per-rank owner rows on main.
The target's pool budget charged the DFLASH draft KV at attn_dcp_size times its cell size, as if the draft pool always spanned the widened locs. On main an MLA draft that executes DCP (mla_attention_dcp_size) keeps per-rank rows, so its loc_space_scale is 1 and the charge was dcp_size times too high. - draft_loc_space_scale(hf_config=, use_mla_backend=, dcp_size=) holds KVCacheConfigurator.loc_space_scale's draft rule; the draft property calls it, and the target-side configurator resolves dflash_draft_loc_space_scale from the draft model config with it. - _dflash_draft_cell_size and the layer-count fallback scale the draft by dflash_draft_loc_space_scale instead of attn_dcp_size. - Drop the source's mla_draft_rows_are_dcp_collapsed predicate and its resolver; main's rule replaces them. - The unit test covers both scales and draft_loc_space_scale itself.
sgl-project#48721 dropped its target-verify branches and moved the sharded-mode checks to dsa_shards_index_k. Restore verify on top of that shape: - the paged top-k and the k-only path take target-verify rows; - prefill gathers KV only outside target verify; - the merge sizes rows by draft tokens; - the verify-only sites test dsa_shards_index_k instead of the DCP width. The Kimi-K3.1 DCP override admits DSPARK (static ragged verify) and DFLASH (cutedsl_mla draft) inline, with decode attention mode for verify.
…ckend check Main moved sglang.srt.utils.hf_transformers to sglang.srt.hf_transformers (sgl-project#48758).
kpham-sgl
force-pushed
the
kpham/k31-dcp-spec-verify
branch
from
November 6, 2026 09:28
ffb95fb to
1699dd3
Compare
Collaborator
Author
|
/rerun-failed-ci one |
The DCP draft row scale now reads both from the draft model config.
Collaborator
Author
|
/rerun-test test/registered/unit/model_executor/test_pool_configurator.py |
Contributor
|
🚀 |
…cp-spec-verify # Conflicts: # python/sglang/srt/layers/attention/dsa_backend.py
Collaborator
Author
EricKing626
added a commit
to EricKing626/sglang
that referenced
this pull request
Nov 9, 2026
Two conflicts, both against the kimi-k3.1 DCP work that landed on 11-06. sgl-project#48739 widened the absorbed-MLA gather to skip target-verify, where a sharded index-K now keeps its per-rank partials. The gathered-prefill override is a different route and the two cannot both be on: the route is planned only when index-K is replicated. Keep both, ours first, and keep the dcp_gathered local the rest of the method reads. sgl-project#48740 added dcp_push_combine_fits and dcp_push_combine_reduce to the layers.dcp import in forward_mla, next to is_dsa_dcp_gathered_prefill. Take the union.
This was referenced Nov 12, 2026
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.

Original authors: @yhyang201
Stacks on #48721. The diff includes #48721 until it merges; the commits of this PR start at "Raw port of DSPARK and DFLASH under DCP".
Port of #48414
On top of the Kimi-K3.1 DCP decode runtime (#48721), this ports the branch's speculative decoding under DCP. DSA target verify attends over each rank's shard and returns
(o, lse)partials for the existing DCP merge, as decode does. The indexer scores each verify row's local share of its causal length; on SM100, DG-native paged MQA logits read a request's index-K once for all of its draft rows. The Kimi-K3.1 DCP override admits DSPARK (static ragged verify, decode attention mode) and DFLASH (cutedsl_mla draft backend, decode attention mode). DFLASH MLA drafts are no longer rejected under DCP: they run the target's DCP decode path. The target's pool budget charges the DFLASH draft KV once per draft pool row per target row, not per widened location (#64 on the branch).Against the raw port (first commit), the draft-backend check reads the draft config through main's
get_config/parse_dflash_draft_config(...).is_mlainstead of the branch'sis_dflash_mla_draft_config. Onlycutedsl_mlais admitted as an MLA-only DFLASH draft backend; the branch also admitstrtllm_mla, which needs the sliding-window draft table work. For the draft KV budget, the branch'smla_draft_rows_are_dcp_collapsedpredicate and its resolver are replaced by main's rule.draft_loc_space_scale(hf_config=, use_mla_backend=, dcp_size=)now holdsKVCacheConfigurator.loc_space_scale's draft rule; the target-side configurator resolvesdflash_draft_loc_space_scalefrom the draft model config with it._dflash_draft_cell_sizeand the layer-count fallback scale the draft by that instead ofattn_dcp_size. API changes for the branch's callers:_dflash_draft_loc_scale/dflash_draft_rows_dcp_collapsedbecomeKVCacheConfigurator.dflash_draft_loc_space_scale.Not taken, because main's design covers it: the branch's DCP-collapsed draft row layout (
draft_mla_rows_are_physical,mla_draft_rows_are_dcp_collapsed). On main,mla_attention_dcp_sizealready keeps a DCP-executing MLA draft on per-rank rows (loc_space_scale == 1).Left for later ports:
splitmode; their only caller is the megakernel verify path.Modifications
dsa_backend.py: target verify under DCP skips the prefill KV gather and asks_forward_flashmla_kvfor a partial. Verify rows get this rank's local lengths, laid out[B, next_n]for DG-native. The captured-verify DG-native refresh stays off under DCP.dsa_indexer.py: DG-native paged MQA logits for DCP verify on SM100.kimi_k3.pyoverride: DSPARK and DFLASH rules in the DCP branch of_kimi_k31_overrides. PD, HiCache, HiSparse and prefill CP stay rejected.speculative_hook.py,draft_worker_common.py:cutedsl_mlais a DFLASH draft backend for MLA drafts.models/dflash.py: drop the--dcp-size > 1rejection of MLA drafts.kv_cache_configurator.py,pool_configurator.py: the DFLASH draft KV is charged atcell_size * dflash_draft_loc_space_scale: 1 for an MLA draft that executes DCP,attn_dcp_sizefor a draft that spans the widened locs. Before, it was alwaysattn_dcp_size.Tests
Static checks:
pre-commitandruff --select Fon the touched files.test_pool_configurator.pycovers the draft charge at loc_space_scale 1 and 8 anddraft_loc_space_scaleitself; it has not been run yet (pending a/rerun-test). GPU validation owed: Kimi-K3.1 TP8 / DCP8 with DSPARK (SGLANG_RAGGED_VERIFY_MODE=static) and with an MLA DFLASH draft on B300, checking accept length and GSM8K (sgl-eval) against DCP1.CI States
Latest PR Test (Base): ⏳ Run #42339255226
Latest PR Test (Extra): ⏳ Run #42339255042
Latest PR Test (AMD ROCm 10): ⏳ Run #42339255091
Tip
Base CI only covers the core cases, and its workload may not exercise your change. Use
/rerun-testto run the tests your change touches, or copy this prompt for an agent: