[PD]: Bidirectional KV transfer#36
Open
S1ro1 wants to merge 1 commit into
Open
Conversation
ede4930 to
8d9bf63
Compare
ApprovabilityVerdict: Needs human review 1 blocking correctness issue found. This PR introduces substantial new functionality for bidirectional KV cache transfer, adding new caching logic and modifying request processing behavior. Additionally, there is an unresolved review comment identifying a potential bug where non-object cached values could break prefill-decode coordination. You can customize Macroscope's approvability policy. Learn more. |
926b0c4 to
645c4c0
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 2 potential issues.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 645c4c0. Configure here.
645c4c0 to
1a441d6
Compare
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.

Sibling to PrimeIntellect-ai/prime-rl#2522
Summary
pd_kv_cache_ttl_secs; default is0, so the existing path does no extra conversation parsing or decode KV work.x-conversation-id, caches only object-valued decodekv_transfer_params, and prunes expired entries before reads and writes.Validation
cargo build --all-targetscargo testsource .env && uv sync --all-extrasfrom the sibling prime-rl branch after pinning this router commitNote
Medium Risk
Adds a new in-memory, TTL-governed cache keyed by
x-conversation-idthat influences request payloads in the vLLM PD router; incorrect TTL sizing or high conversation churn could increase memory use or cause subtle routing/behavior changes in PD flows.Overview
Enables optional bidirectional KV transfer in vLLM Prefill/Decode mode by caching Decode-side
kv_transfer_paramsper conversation and reusing them on subsequent Prefill requests.Introduces
pd_kv_cache_ttl_secs(default0= disabled) wired through Python args/docs, RustRouterConfig, CLI (--pd-kv-cache-ttl-secs), and the PyO3 binding. When enabled,VllmPDRouterstoreskv_transfer_paramsextracted from Decode responses (including SSE streaming bodies) in a TTL cache keyed byx-conversation-id, evicts expired entries on access, and injects adjusted params into Prefill requests to point back at the Decode instance.Reviewed by Cursor Bugbot for commit 1a441d6. Bugbot is set up for automated code reviews on this repo. Configure here.
Note
Add bidirectional KV transfer support to
VllmPDRouterwith conversation-scoped cachingdecode_kv_cachetoVllmPDRouterthat storeskv_transfer_paramsfrom decode responses, keyed byx-conversation-idheader, with a configurable TTL (pd_kv_cache_ttl_secs, default 0/disabled).pd_kv_cache_ttl_secsthrough the RustRouterConfig, PythonRouterArgs, CLI (--pd-kv-cache-ttl-secs), and the PyO3Routerconstructor.pd_kv_cache_ttl_secs > 0and requests includex-conversation-id, prefillkv_transfer_paramswill differ from default based on prior decode responses.Macroscope summarized 1a441d6.