Repository navigation
Conversation
jeff3071
force-pushed
the
feat/runtime-max-cached-tokens
branch
from
October 28, 2026 05:51
e009f4e to
017b638
Compare
Collaborator
|
Could you clarify the failure semantics in the docstring for |
jeff3071
marked this pull request as ready for review
October 28, 2026 12:23
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.
Summary
Update the idle prefix-cache (
MAX_CACHED_TOKENS) retention policy at runtime.KVCACHED_MAX_CACHED_TOKENSremains the startup value. Any process with access to the engine's existing native ledger directory can subsequently publish an update through:Before
sequenceDiagram participant Operator participant Engine participant PrefixCache Operator->>Engine: Start with KVCACHED_MAX_CACHED_TOKENS Engine->>PrefixCache: Configure fixed retention limit PrefixCache->>PrefixCache: Evict after request completion Note over Engine,PrefixCache: Changing the policy requires restarting the engineAfter
sequenceDiagram participant Caller participant Control as kvcached.control participant Ledger as Existing Native Ledger participant Scheduler as Engine / Scheduler participant Policy as Retention Policy participant Cache as Prefix Cache participant Eviction as Existing Eviction Path Caller->>Control: set_prefix_cache_retention_limit(tokens, instance_name=...) Control->>Ledger: Publish limit and retention revision on each GPU Control-->>Caller: Publication status Scheduler->>Ledger: Read matching assignments across GPUs Note over Scheduler: SGLang TP ranks receive the same update Scheduler->>Policy: Update process-local limit Policy->>Cache: Enforce new limit Cache->>Eviction: Evict currently evictable excess Eviction-->>Cache: Active or locked KV remains protected Note over Caller,Eviction: Acceptance does not imply completed eviction or physical GPU memory release Scheduler->>Cache: Request finishes later Cache->>Policy: Read current limit Cache->>Eviction: Evict newly evictable excessThe implementation reuses the existing vLLM and SGLang eviction paths. Active KV is excluded through the engines' existing ref-count and lock eligibility rules.
Updates use the existing native ledger, with eviction performed on the engine or scheduler thread, including while idle. Engines consume only matching retention revisions and values across all GPUs. Callers can inspect per-GPU publication status and republish the desired limit to repair partial failures.
Current limitations
pp_size=1. TP ranks apply updates together. With pipeline parallelism, publication may return accepted, but schedulers do not apply the update.cache_finished_reqenforcement hook. A later request transition will enforce the policy, but immediate enforcement after every HiCache transition is not guaranteed.Related to #585 (comment) .