Skip to content

[Bugfix][Kimi-K3] Keep transient checkpoints out of prefix-cache eviction - #56794

Merged
ZJY0516 merged 5 commits into
vllm-project:mainfrom
Sy0307:fix-kda-intermediate-checkpoint-retention-clean
Sep 15, 2026
Merged

ZJY0516 merged 5 commits into
vllm-project:mainfrom
Sy0307:fix-kda-intermediate-checkpoint-retention-clean

Conversation

@Sy0307

@Sy0307 Sy0307 commented Sep 14, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Keep transient KDA/Mamba prefill checkpoints out of the ordinary prefix-cache eviction set when sparse retention is explicitly active.

This change targets Kimi-K3's hybrid attention path.

Problem

FlashKDA creates internal checkpoints so the current prefill can continue from a recurrent-state boundary without an additional scheduling step. A checkpoint in the middle of a prompt is useful to the current request, but it is not necessarily a reusable shared-prefix boundary.

Before this change, such a checkpoint could be re-keyed and registered as a normal prefix-cache block. It then participated in the same GPU LRU eviction pool as reusable hot prefixes:

middle checkpoint -> hash -> prefix-cache LRU -> evicts hot prefix
                                             -> later local hit becomes a miss
                                             -> extra load or prefill work

Before/after cache lifecycle:

Before:

  KDA prefill
      |
      +--> temporary checkpoint
      |        |
      |        +--> hash + ordinary LRU
      |                     |
      |                     +--> competes with hot prefix
      |                                  |
      |                                  +--> local prefix miss

After:

  KDA prefill
      |
      +--> temporary checkpoint ------------------> current request can use it
      |                                              |
      |                                              +--> no ordinary LRU entry
      |
      +--> shared-prefix-boundary checkpoint ------> reusable prefix cache
                                                     |
                                                     +--> may be retained/shared

This is particularly problematic when prefix_cache_retention_interval == 0: intermediate checkpoints are not intended to be retained as dense semantic checkpoints, but their temporary hash could still make them eviction candidates.

Fix

Pass the active retention interval into checkpoint publication. When sparse retention is active and the checkpoint is neither at the end of the prompt nor at the shared-prefix boundary, treat it as request-local state:

middle checkpoint -> current request may use it
                  -> temporary hash is removed
                  -> no ordinary prefix-cache LRU entry
                  -> reusable hot prefixes remain protected

Prompt-end and shared-prefix-boundary checkpoints retain the existing publication behavior. This change does not disable KDA checkpoint computation or change the state written by FlashKDA.

Performance

On a representative B200 Kimi-K3 hybrid workload using TP8/PP2/direct DCP8, the isolated production-style comparison was:

Configuration Output throughput
Checkpoint disabled (diagnostic baseline) 1013.00 tokens/s
Checkpoint enabled with transient-checkpoint retention fix 1091.80 tokens/s

The fixed configuration improved throughput by 7.78% over the checkpoint-disabled diagnostic baseline while retaining the internal checkpoint feature. A separate run with the GEMM-AR option disabled measured 1108.89 tokens/s; that result is included only as context and is not an isolated measurement of this patch.

These measurements are workload-specific and are not used as a claim that this small cache-lifecycle change explains every difference between software stacks. The primary regression signal is the cache-manager reproduction: temporary checkpoint publication changes which blocks compete in the local prefix-cache eviction pool.

Why this is not a duplicate

Validation

Focused prefix-cache tests should be run with:

pytest tests/v1/core/test_prefix_caching.py -q

The change is intentionally small and preserves the current-request checkpoint path. Model-scale performance validation is still required on a representative hybrid KDA workload.

This change was prepared with AI assistance; the author should review the complete diff and test results before merging.

@mergify mergify Bot added bug Something isn't working kv-cache-manager labels Sep 14, 2026
@Sy0307 Sy0307 changed the title [Bugfix][Mamba] Keep transient checkpoints out of prefix-cache eviction [Bugfix][Kimi-K3] Keep transient checkpoints out of prefix-cache eviction Sep 14, 2026
@Sy0307
Sy0307 marked this pull request as ready for review September 14, 2026 09:16

@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.

@Sy0307
Sy0307 force-pushed the fix-kda-intermediate-checkpoint-retention-clean branch from 798039c to 105db25 Compare September 14, 2026 09:18
@Sy0307
Sy0307 marked this pull request as draft September 14, 2026 09:19
@Sy0307
Sy0307 marked this pull request as ready for review September 14, 2026 09:21
@ZJY0516 ZJY0516 added the verified Run pre-commit for new contributors without triggering other tests label Sep 14, 2026

@gcanlin gcanlin 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.

ZJY0516 and others added 2 commits September 14, 2026 12:19
… tests

- Make retention_interval a required parameter of _cache_partial_tail_block
  so future callers cannot silently fall back to dense behavior.
- Evict via block_pool._maybe_evict_cached_block directly instead of the
  connector-facing evict_blocks API.
- Add regression tests pinning that a mid-prompt internal checkpoint stays
  out of the prefix cache under latest-only retention while the prompt-end
  checkpoint is still published, and that a stale boundary hash on the
  checkpoint slot is evicted rather than left pointing at overwritten state.

Co-authored-by: Kimi Code <noreply@moonshot.ai>
Signed-off-by: zjy0516 <riverclouds.zhu@qq.com>
Co-authored-by: Kimi Code <noreply@moonshot.ai>
Signed-off-by: zjy0516 <riverclouds.zhu@qq.com>
@ZJY0516

ZJY0516 commented Sep 14, 2026 •

Copy link
Copy Markdown
Member

I directly pushed some changes:

  • Made retention_interval a required parameter of _cache_partial_tail_block so future callers can't silently fall back to dense behavior
  • Replaced the block_pool.evict_blocks(...) with a direct block_pool._maybe_evict_cached_block(checkpoint_block) call
  • Added regression tests

@ZJY0516

ZJY0516 commented Sep 14, 2026

Copy link
Copy Markdown
Member

/ci run

@ZJY0516
ZJY0516 enabled auto-merge (squash) September 14, 2026 12:30
@github-actions github-actions Bot added the ready ONLY add when PR is ready to merge/full CI is needed label Sep 14, 2026
@github-actions

Copy link
Copy Markdown

βœ… Triggered Buildkite CI #88813 for commit b1bca7b11dc5.

Signed-off-by: Sy03 <1370724210@qq.com>
auto-merge was automatically disabled September 14, 2026 20:14

Head branch was pushed to by a user without write access

@Sy0307

Sy0307 commented Sep 14, 2026

Copy link
Copy Markdown
Contributor Author

Follow-up: updated the existing Mamba checkpoint regression test to pass the newly required retention_interval argument. The earlier CI failure was a stale direct test call; no production logic changed in this fix.

@Sy0307

Sy0307 commented Sep 14, 2026

Copy link
Copy Markdown
Contributor Author

/ci run

@github-actions

Copy link
Copy Markdown

βœ… Triggered Buildkite CI #88907 for commit be1a1c940da9.

@Sy0307

Sy0307 commented Sep 15, 2026

Copy link
Copy Markdown
Contributor Author

CI have passed. Can you merge it? Thx. @ZJY0516

@ZJY0516
ZJY0516 merged commit f547c23 into vllm-project:main Sep 15, 2026
112 of 113 checks passed
keneoneth pushed a commit to keneoneth/vllm that referenced this pull request Sep 16, 2026
…tion (vllm-project#56794)

Signed-off-by: Sy03 <1370724210@qq.com>
Signed-off-by: zjy0516 <riverclouds.zhu@qq.com>
Co-authored-by: zjy0516 <riverclouds.zhu@qq.com>
Co-authored-by: Kimi Code <noreply@moonshot.ai>
michael-gpu pushed a commit to practical-inference/vllm-ampere-extended that referenced this pull request Oct 20, 2026
…tion (vllm-project#56794)

Signed-off-by: Sy03 <1370724210@qq.com>
Signed-off-by: zjy0516 <riverclouds.zhu@qq.com>
Co-authored-by: zjy0516 <riverclouds.zhu@qq.com>
Co-authored-by: Kimi Code <noreply@moonshot.ai>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working k3 kimi kv-cache-manager ready ONLY add when PR is ready to merge/full CI is needed verified Run pre-commit for new contributors without triggering other tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants