[Hybrid KV Cache] Retain finalized Mamba decode checkpoints for prefix caching - #50551
qianlihuang wants to merge 4 commits into
Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds an opt-in mechanism for sparse prefix-cache retention (VLLM_PREFIX_CACHE_RETENTION_INTERVAL=0) to privately pin the latest scheduler-aligned Mamba align-mode decode checkpoint during generation and publish it to the local prefix cache only when the request finishes with FINISHED_STOPPED. This targets multi-turn “full-history replay” workflows (e.g., Kimi K3) by enabling deeper reusable replay boundaries with minimal additional storage.
Changes:
- Introduces private per-request decode-checkpoint candidates in the Mamba align KV cache manager and publishes/discards them at request finalization.
- Adds BlockPool support for caching an exact decode checkpoint hash alias without disturbing other existing hash aliases.
- Wires scheduler and KV cache manager/coordinator logic to update candidates on non-stale outputs and finalize them on request completion; includes validation + env var + comprehensive tests.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| vllm/v1/core/single_type_kv_cache_manager.py | Tracks/pins latest aligned decode checkpoint candidate per request in Mamba align mode; publishes on finalization. |
| vllm/v1/core/sched/scheduler.py | Updates decode-checkpoint candidates on fresh outputs and finalizes them during request teardown. |
| vllm/v1/core/kv_cache_manager.py | Computes “materialized” token boundary and forwards candidate updates/finalization to the coordinator. |
| vllm/v1/core/kv_cache_coordinator.py | Adds config validation and coordinator fan-out for candidate update/finalization across cache groups. |
| vllm/v1/core/block_pool.py | Adds cache_decode_checkpoint to publish a specific checkpoint hash alias and optionally emit events. |
| vllm/envs.py | Adds VLLM_PREFIX_CACHE_RETAIN_DECODE_CHECKPOINTS env var and updates retention-interval description. |
| tests/v1/core/test_prefix_caching.py | Adds unit tests covering candidate selection, pin semantics, promotion behavior, event emission, and config validation. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Data point supporting this PR: on 8×MI325X (ROCm, nightly g3ee2df303 + #50597/#50817 for the SITU MoE path), enabling |
|
This pull request has merge conflicts that must be resolved before it can be |
Co-authored-by: OpenAI Codex <codex@openai.com> Signed-off-by: Yiliu Dong <91178480+qianlihuang@users.noreply.github.com>
Signed-off-by: Yiliu Dong <91178480+qianlihuang@users.noreply.github.com>
Preserve current main replay-boundary and offload handling. Validate the resolved retention policy and cover stopped publication, discard, and unsupported configurations. Co-authored-by: OpenAI Codex <noreply@openai.com> Signed-off-by: Yiliu Dong <91178480+qianlihuang@users.noreply.github.com>
288074c to
3414566
Compare
|
This pull request has merge conflicts that must be resolved before it can be |
Purpose
With:
vLLM uses a sparse retention policy that aims to maximize cache reuse per retained SSM state, providing high prefix-cache hit potential with minimal storage overhead.
Currently, it retains the prompt replay boundary and reactively discovered Marconi-style shared-prefix junctions. Marconi's admission policy also retains the last decoded state for conversation-history reuse.
This PR completes that behavior for sparse retention by privately pinning the latest materialized, scheduler-aligned decode checkpoint and publishing it to the local prefix cache after
FINISHED_STOPPED.Enable with:
Examples
Kimi K3 requires the complete assistant message returned by the API, including
reasoning_contentandtool_calls, to be passed back in the next request.History prefix hit examples
History followed by a tool result
The hit lands at the deepest scheduler-aligned boundary within the replayed assistant prefix.
History followed by a user message
Again, the hit is the deepest aligned checkpoint within the replayed assistant prefix.
Because the completed assistant message is rendered again before the new tool or user message, the latest decode checkpoint provides the deepest reusable prefix.
Test Plan
Server
Client
Test Result
Relationship to prior work
#37898 added Marconi-style shared-prefix admission while preserving the existing last-state behavior.
#45845 introduced sparse Mamba retention. With VLLM_PREFIX_CACHE_RETENTION_INTERVAL=0, retention became based on replay boundaries and no longer included the finalized decode endpoint.
#47782 preserved shared-prefix junctions under sparse retention, but did not restore the finalized decode endpoint.
This PR restores that remaining last-state behavior.
Future work
A separate follow-up will support hidden-state drafting.
A follow-up can offload finalized Decode-side checkpoints through KV connectors for reuse by Prefill workers in P/D deployments.
Essential Elements of an Effective PR Description Checklist
supported_models.mdandexamplesfor a new model.