Skip to content

[ROCm][DSpark][DCP] Serve prefix cache hits under DCP for Kimi-K3 - #53598

Merged
ywang96 merged 3 commits into
vllm-project:mainfrom
YukioZzz:yichaozhu/k3-draft-cache-fix
Aug 31, 2026
Merged

ywang96 merged 3 commits into
vllm-project:mainfrom
YukioZzz:yichaozhu/k3-draft-cache-fix

Conversation

@YukioZzz

@YukioZzz YukioZzz commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

Summary

Use each KV-cache group's effective DCP geometry when constructing cache managers and performing hybrid prefix-cache lookup.

Kimi-K3 mixes DCP-sharded MLA/full-attention groups with replicated Mamba groups. Applying the process-wide DCP size to every group makes the scheduler, block hashing, and cache managers disagree about block geometry.

This PR is intentionally limited to per-group DCP cache geometry. It does not include:

Implementation

  • Construct full-attention/MLA cache managers with the process DCP size.
  • Keep replicated state groups, including Mamba, at DCP size 1.
  • Use each manager's effective block size and DCP/PCP geometry during prefix-cache lookup.
  • Propagate the validated hash alignment to cache-manager retention, so non-EAGLE fine-grained DCP hits are not discarded at the larger scheduler LCM.
  • Add focused coverage for per-group geometry and DCP hybrid prefix lookup.

Validation

Validation used an integration stack containing #51705 and this PR with DCP8, DSpark, FP8 KV cache, prefix caching, eager execution, and block rejection sampling.

Server reproduction args:

vllm serve /data/model/Kimi-K3 \
  --served-model-name moonshotai/Kimi-K3 \
  --host 0.0.0.0 \
  --port 8892 \
  --trust-remote-code \
  --moe-backend auto \
  --tensor-parallel-size 8 \
  --decode-context-parallel-size 8 \
  --load-format fastsafetensors \
  --gpu-memory-utilization 0.82 \
  --language-model-only \
  --max-num-seqs 20 \
  --enable-auto-tool-choice \
  --tool-call-parser kimi_k3 \
  --reasoning-parser kimi_k3 \
  --max-model-len 1048576 \
  --enable-prefix-caching \
  --kv-cache-dtype fp8 \
  --enforce-eager \
  --speculative-config '{"model":"/data/model/Kimi-K3-DSpark","num_speculative_tokens":2,"method":"dspark","attention_backend":"TRITON_MLA","kv_cache_dtype":"auto","draft_sample_method":"probabilistic","rejection_sample_method":"block"}'

Accuracy

GSM8K full-set, 5-shot, num_concurrent=64:

  • Strict-match exact match: 0.9682 +/- 0.0048.
  • Flexible-extract exact match: 0.9682 +/- 0.0048.
  • The server remained healthy after the run.

After adding hash-aligned manager retention in 8d28f83fcc, a full non-DSpark max-throughput run produced:

  • GSM8K flexible-extract: 0.9644 +/- 0.0051.
  • GSM8K strict-match: 0.9629 +/- 0.0052.
  • AIPerf actual local prefix hit: 8,775,168 / 11,093,014 = 79.11%.
  • AIPerf theoretical prefix hit: 84.39%.
  • AIPerf input/output throughput: 10,627.90 / 139.31 tokens/s.
  • AIPerf requests/duration: 186 / 926.13s, with TTFT and ITL coverage both 100%.

Reproduction command:

python3 -m lm_eval \
  --model local-chat-completions \
  --apply_chat_template \
  --tasks gsm8k \
  --num_fewshot 5 \
  --output_path /tmp/gsm8k_dcp8_full_conc64_out \
  --log_samples \
  --model_args "model=moonshotai/Kimi-K3,base_url=http://127.0.0.1:8892/v1/chat/completions,api_key=EMPTY,eos_string=</s>,max_retries=5,num_concurrent=64,timeout=1800,tokenized_requests=False" \
  --gen_kwargs "max_tokens=12288,temperature=0,top_p=1"

AIPerf fast

The sustained agentic replay run used:

aiperf profile --scenario inferencex-agentx-mvp \
  --url http://localhost:8892 \
  --endpoint /v1/chat/completions --endpoint-type chat --streaming \
  --model moonshotai/Kimi-K3 \
  --tokenizer /data/model/Kimi-K3 \
  --concurrency 16 \
  --benchmark-duration 900 \
  --stats-interval 30 \
  --random-seed 42 \
  --failed-request-threshold 0.10 \
  --trajectory-start-min-ratio 0.0 \
  --trajectory-start-max-ratio 0.0 \
  --warmup-requests-per-lane 1 \
  --trace-idle-gap-cap-seconds 300 \
  --warmup-grace-period 1800 \
  --use-server-token-count --no-gpu-telemetry --tokenizer-trust-remote-code \
  --num-dataset-entries 393 --slice-duration 1.0 \
  --public-dataset semianalysis_cc_traces_weka_062126 \
  --cache-bust first_turn_prefix --unsafe-override

This PR fixes the DCP geometry layer but does not by itself retain the Mamba state at the EAGLE-adjusted replay boundary. The distinction is visible in server-counter deltas:

Stack Local prefix hits / queries Actual hit rate Theoretical hit rate
#51705 + this PR, without replay-boundary retention 1,155,072 / 7,404,118 15.60% 80.37%
Same configuration with a separately tested replay-boundary fix 7,649,280 / 10,638,815 71.90% 83.92%

The remaining DSpark replay issue is separate from this alignment fix. In the reproduced DCP layout, the scheduler block is 24,576 tokens while the hash and Mamba blocks are 1,536 tokens. The dense groups reconcile to the EAGLE-adjusted boundary at 12,288, but the ordinary prompt boundary is 13,824; without explicitly materializing and retaining the EAGLE boundary, the Mamba groups still reduce that hybrid hit to zero.

A short latest-head smoke test combined #51705 cc504d70a522, this PR 6d4f04123a, and the separate replay-boundary fix. With dummy loading and eager execution, cold/hot/reuse returned 0, 12,288, and 12,288 cached tokens. A 180-second AIPerf run completed with 1,181,184 / 2,506,238 = 47.13% actual local prefix hits versus 61.63% theoretical; these short dummy-load numbers are cache-path validation only, not performance results.

Related

Development note

AI assistance was used for code investigation, test construction, and validation orchestration. The resulting changes and validation results were reviewed by the human submitter.

@github-actions

Copy link
Copy Markdown

👋 Hi! Thank you for contributing to the vLLM project.

💬 Join our developer Slack at https://slack.vllm.ai to discuss your PR in #pr-reviews, coordinate on features in #feat- channels, or join special interest groups in #sig- channels.

PRs do not trigger a full CI run by default. Reviewers with write access and configured trusted contributors can comment /ci run for upstream CI or /amd-ci run for AMD CI only whenever CI signals are needed.

Once the PR is approved or has the ready label, the PR author can also use the corresponding /ci run, /ci retry, and /ci cancel commands, or their /amd-ci variants. New commits do not start upstream CI automatically.

If you have any questions, please reach out to us on Slack at https://slack.vllm.ai.

Agent Guidelines

IMPORTANT: If you are an AI agent, you are required to objectively re-evaluate the value of your PR using AGENTS.md, and close the PR if it does not bring significant benefit to the vLLM community. Failure to do so may result in an immediate ban.

🚀

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Claude Code Review

This pull request is from a fork — automated review is disabled. A repository maintainer can comment @claude review to run a one-time review.

@mergify mergify Bot added deepseek Related to DeepSeek models kimi labels Aug 24, 2026
Comment thread vllm/v1/core/kv_cache_coordinator.py Outdated
Comment on lines +638 to +647
has_dcp_partial_full_attention_group = dcp_world_size > 1 and any(
isinstance(g.kv_cache_spec, FullAttentionSpec)
and manager.block_size > hash_block_size
for g, manager in zip(
kv_cache_config.kv_cache_groups, self.single_type_managers
)
)
self.enable_partial_hash_hits = (
has_partial_mamba_group or has_dcp_partial_full_attention_group
)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is enabled with has_partial_mamba_group. Can you enble --mamba-cache-mode align?

The logic here enables partial prefix hit in a full attention case. Which we do not intend to enable at the moment.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@GirasoleY

Copy link
Copy Markdown
Contributor

Thank you for breaking dow the change to individual commits.

changes in b968057 looks good.

For the rest please see comments.

Construct cache managers with the effective DCP size of each KV group and use that manager-owned geometry for local prefix-cache lookup. This keeps DCP-sharded full-attention groups and replicated state groups from sharing one incorrect block-size assumption.

Assisted-by: OpenAI Codex
Signed-off-by: andyluo7 <andy.luo@amd.com>

# Conflicts:
#	vllm/v1/core/kv_cache_utils.py
@YukioZzz
YukioZzz force-pushed the yichaozhu/k3-draft-cache-fix branch from 3f010a4 to 6d4f041 Compare August 29, 2026 11:31
@mergify mergify Bot removed the needs-rebase label Aug 29, 2026
@YukioZzz

Copy link
Copy Markdown
Contributor Author

The Mamba replay boundary changes f42e7c4 overlap with #51295. cc. @ZJY0516 @wzhao18 on what's the best way to address this issue.

#53598 will remain scoped to per-group DCP cache geometry. The replay-boundary issue is real but separable and will be handled independently. @GirasoleY

#50897 is too big, and we might also check if successor-aware hashing is enabled to do legacy drop or not? @ZJY0516
#51295 is good. But it becomes draft and did not handle dcp hash prefix boundary. I might open a new PR to enable a minimal EAGLE × Mamba replay-boundary and co-author @wzhao18 to see if is accepted?

Hybrid DCP lookup can use a finer hash alignment than the scheduler LCM. Propagate that validated alignment to cache managers so sparse Mamba retention does not discard checkpoints that local lookup can reuse. Keep scheduler alignment as the default and whenever fine-grained lookup is disabled, including CPU offload coordinators.

Cover the behavior without EAGLE to keep this geometry fix independent from replay-boundary handling.

Co-authored-by: andyluo7 <andy.luo@amd.com>
Signed-off-by: Yichao Zhu <Yichao.Zhu@amd.com>
@YukioZzz
YukioZzz requested a review from GirasoleY August 31, 2026 06:21
@YukioZzz

Copy link
Copy Markdown
Contributor Author

/amd-ci run

@github-actions

Copy link
Copy Markdown

@YukioZzz, A reviewer with write access must run /amd-ci run, approve the PR, or add the ready label first.

@shen-shanshan

Copy link
Copy Markdown
Collaborator

/amd-ci run

@github-actions

Copy link
Copy Markdown

✅ Triggered Buildkite AMD CI #12457 for commit 8d28f83fcc62.

@YukioZzz

Copy link
Copy Markdown
Contributor Author

/ci run

@github-actions

Copy link
Copy Markdown

@YukioZzz, A reviewer with write access must run /ci run, approve the PR, or add the ready label first.

@GirasoleY GirasoleY left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@github-project-automation github-project-automation Bot moved this from In review to Ready in NVIDIA Aug 31, 2026
@ywang96 ywang96 added the ready ONLY add when PR is ready to merge/full CI is needed label Aug 31, 2026
@ywang96
ywang96 merged commit 2ba984a into vllm-project:main Aug 31, 2026
5 of 10 checks passed
@github-project-automation github-project-automation Bot moved this from Backlog to Done in Sprint - DFlash Aug 31, 2026
@github-project-automation github-project-automation Bot moved this from Ready to Done in NVIDIA Aug 31, 2026
@github-project-automation github-project-automation Bot moved this from Todo to Done in AMD Aug 31, 2026
@github-actions

Copy link
Copy Markdown

@YukioZzz, CI is now available for this PR.

  • /ci run starts upstream CI; /amd-ci run starts AMD CI only.
  • /ci retry retries failed jobs in the CI build for the current PR head. If the current head has no CI build, it starts a new CI build for the current head containing only jobs that failed in the latest earlier CI build for this PR.
  • /amd-ci retry retries failed jobs in AMD CI for the current PR head. Use /amd-ci run when the current head has no AMD CI build.
  • /ci cancel cancels scheduled or running CI builds for this PR branch; /amd-ci cancel does the same for AMD CI only.

ianlevesque pushed a commit to ianlevesque/vllm that referenced this pull request Sep 1, 2026
…lm-project#53598)

Cherry-picked from upstream 2ba984a onto build/kimi-k3-v2-dcp16-20260819
(base 99e62b8). Root-cause fix for the Kimi-K3 TP16/DCP16 long-context
needle failures: pre-fix, every single-type KV cache manager was constructed
with the process DCP world size, so the Mamba/KDA manager applied x16 block
geometry to per-rank-replicated state - prefix-cache hits then resumed at
positions where no KDA checkpoint exists, positionally desyncing the KDA and
full-attention layer families on every cache-hit request.

Adaptations to this tree (vs the upstream commit):
- kept this branch's kv_cache_utils imports (_use_lockstep_mla_allocation,
  is_deepseek_v4_hybrid_kv_cache_config) alongside the new helper
- unified has_partial_mamba_group with this branch's DCP1-only expression
  (upstream relaxes partial hash hits to DCP>1 when mamba block >= hash block)
- ported the small KVCacheSpec.prefix_cacheable property (base True +
  UniformTypeKVCacheSpecs all()) which upstream added separately; this tree
  has no CircularBufferSpec so no False override exists
- test fixture: dropped MambaSpec.num_prefill_checkpoint_blocks (upstream
  prefill-checkpoint feature absent here), added the lcm import, and kept
  this tree's unparametrized test_mamba_align_split_partial_tail_schedule
  (the dcp mock attrs it threads are upstream-scheduler-only)

Original-author: Yichao Zhu <Yichao.Zhu@amd.com> (and co-authors, vllm-project#53598)
Claude-Session: https://claude.ai/code/session_01SnjnheY7rHpk73rGeNS5Sk
am-cohere pushed a commit to am-cohere/vllm that referenced this pull request Sep 1, 2026
…lm-project#53598)

Signed-off-by: Yichao Zhu <Yichao.Zhu@amd.com>
Co-authored-by: andyluo7 <andy.luo@amd.com>
mylibrar pushed a commit to tanyuqian/vllm that referenced this pull request Sep 3, 2026
…lm-project#53598)

Signed-off-by: Yichao Zhu <Yichao.Zhu@amd.com>
Co-authored-by: andyluo7 <andy.luo@amd.com>
sheralskumar pushed a commit to sheralskumar/vllm that referenced this pull request Sep 8, 2026
…lm-project#53598)

Signed-off-by: Yichao Zhu <Yichao.Zhu@amd.com>
Co-authored-by: andyluo7 <andy.luo@amd.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working deepseek Related to DeepSeek models dflash k3 kimi kv-cache-manager kv-connector mrv2 Model Runner V2 specific nvidia ready ONLY add when PR is ready to merge/full CI is needed rocm Related to AMD ROCm scheduler speculative-decoding verified Run pre-commit for new contributors without triggering other tests

Projects

Status: Done
Status: Done
Status: Done

Development

Successfully merging this pull request may close these issues.

5 participants