Repository navigation
[Kimi] Support DCP + DSpark (ported from kimi-k3 branch) - #32828
Conversation
|
Caution The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased. |
|
Caution The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased. |
c576713 to
b8bf4c3
Compare
b8bf4c3 to
ddac145
Compare
|
Caution The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased. |
|
/rerun-test test/registered/dcp/test_kimi_linear_dcp_dspark4.py test/registered/dcp/test_tokenspeed_mla_dcp_metadata.py |
|
Results for 🚀 |
|
Caution The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased. |
sgl-project#32612 landed DCP for Kimi Linear with its test diff trimmed to test_kimi_linear_dcp4.py, leaving the speculative-decoding path uncovered. No test on main combines Kimi Linear with DSPARK. - dcp/test_tokenspeed_mla_dcp_metadata.py: pins global_seq_lens_k (the global causal boundary) against seq_lens_k (rank-owned pages) in the TokenSpeed CUDA-graph metadata, so conflating them fails at unit level instead of as a silent accuracy drop. - dcp/test_kimi_linear_dcp_dspark4.py: 4xBlackwell GSM8K acceptance for static verify, with and without --dcp-replicate-q-proj.
DSPARK on a hybrid linear-attention target (Kimi Linear) never committed the target's KDA/mamba recurrent state to the accepted length after verify, so the state drifted from the accepted token sequence every step. The server stays healthy and output degrades to noise: GSM8K 0.02 on tp4/dcp4 and 0.015 on tp1 with no DCP, while the same model without speculation scores 0.905. Pure-MLA targets have no recurrent state to commit, which is why the existing DSPARK tests (DSV4 / model-agnostic) do not catch this. Arm the track buffers before the verify forward and commit the last accepted step's state afterwards, gated on a mambaish target whose backend exposes update_mamba_state_after_mtp_verify. Chain layout only (topk == 1). Ported from the kimi-k3 branch.
e671e81 to
75669ca
Compare
Three remaining pieces of the feature as it exists on the kimi-k3 branch: - tokenspeed_mla_backend: DCP target verify gathers Q to the full head count before launching TokenSpeed, so size the workspace for that launch shape and derive max_q_len from max_speculative_num_draft_tokens rather than the hardcoded ceiling. - kv_cache_configurator: draft pools are replicated, not DCP-sharded, yet consume the shared allocator's virtual locs in [0, max_total * dcp_size) untranslated, so every token-loc-indexed draft capacity must cover the full virtual space. - pool_configurator: budget the replicated draft pool at dcp_size x in the memory solve so the larger pool is accounted for instead of taken from the target's share. All three are no-ops at dcp_size == 1.
|
/rerun-test registered/dcp/test_kimi_linear_dcp_dspark4.py |
|
Results for 🚀 |
…r-dcp-dspark # Conflicts: # python/sglang/srt/mem_cache/common.py
|
https://github.com/sgl-project/sglang/actions/runs/30669840509/job/91295368972?pr=32828 All other tests passed and safe to merge |
86 main commits in (incl. the #33011/#33012/#33013 config refactor, #32692 GDN ReplaySSM fold, #32828 DCP+DSpark port, #31987 BCG eligibility rewrite, unified-memory #32971/#32972/#33046). 24 conflicted files. Key resolutions: - ReplaySSM: converge on main's --enable-gdn-replayssm-spec (the branch's --enable-linear-replayssm-spec rename is dropped) and main's GDN fold-every-commit semantics. The KDA fold keeps its fork behavior under the same flag: d/k rings stay allocated (KDA decode routes on their presence), the window stays --linear-replayssm-cache-len long with the power-of-two + 2x margin backstop, and the fused ring-write keeps the per-K vector gate layout (branched on IS_KDA next to main's scalar GDN layout). replayssm_ring_bytes_per_req accounts both layouts. - spec_utils KDA commit: gate on replayssm_spec_fold + replayssm_is_kda; the old cursor-presence proxy is never allocated under fold and would have silently skipped the KDA fold. - prefill BCG: fold the branch's mla_pinned_under_bcg exemption into main's rewritten can_replay_locally prefix guard. - config refactor fallout: NS("exec.mamba") added to the branch-only linear_attn_verify_backend field (test_server_args_namespaces coverage); branch server_args writes verified pre-publish (kimi_k3_hook only). - trtllm_mla: main's unified_mla_hooks predicate; the branch's fused KV-scatter+q-concat stays. - forward_mla: keep the branch's broader DCP decode-phase predicate; main's re-added _is_dcp_mla_decode_phase helper (deleted on the branch) is dropped again. Co-Authored-By: Claude Fable 5 <[email protected]>
…locator Follow-up to #32828, which sized the replicated DSPARK draft KV pool for the DCP virtual loc space by scaling max_total_num_tokens by dcp_size, but left its page_size at the per-rank value. The shared PagedTokenToKVPoolAllocator is built with page_size = get_schedule().page_size * dcp_size and reserves the padding slot by handing out pages 1..num_pages, so the last page it can emit begins at exactly `size` and spans a full allocator page. A KV pool only over-allocates one of its own pages past `size`, so under dcp_size=8 the draft pool backed 64 of that final 512-slot page and 448 slots had no memory behind them. Once occupancy is high enough for the allocator to reach its last page, the draft decode CUDA-graph replay writes into that tail and trips kvcache.cuh: Assertion `index >= 0 && index < size_limit` failed on every TP rank. Scale the draft pool's page granularity alongside its capacity, and express the rule once as accessors on KVCacheConfigurator rather than inlining it per call site. Every pool construction now takes pool_page_size; allocators and sizing helpers keep the raw page. No-op at dcp_size == 1 and for non-draft workers. Validated on 8xB300 (tp8, dcp8, DSPARK): 256/256 requests, zero asserts, throughput unchanged. Reproduces in ~35s without the fix at 16384/1024, concurrency 64, 256 prompts.
Port the Kimi Linear DCP + DSPARK feature from the
kimi-k3branch, and add its test coverage.mainhad the DCP half (#32612) but not the DSPARK half for a hybrid linear-attention target: the target's KDA/mamba recurrent state was never committed to the accepted length after verify, so it drifted from the accepted token sequence every step.Changes
speculative/dspark_components/dspark_worker_v2.py— commit the last accepted verify step's recurrent state (gated on a mambaish target whose backend exposesupdate_mamba_state_after_mtp_verify; chain layout only).layers/attention/tokenspeed_mla_backend.py— size the TokenSpeed workspace for the DCP-gathered head count and the real speculative width.mem_cache/kv_cache_configurator.py— size replicated draft pools for the DCP virtual loc space.model_executor/pool_configurator.py— budget the replicated draft pool atdcp_size xin the memory solve.The last four are no-ops at
dcp_size == 1.Tests
dcp/test_tokenspeed_mla_dcp_metadata.py— global vs per-rank KV lengths in the TokenSpeed CUDA-graph metadata.dcp/test_kimi_linear_dcp_dspark4.py— 4xBlackwell GSM8K acceptance, with and without--dcp-replicate-q-proj.CI States
Latest PR Test (Base): ✅ Run #30669840663
Latest PR Test (Extra): ❌ Run #30669840509