feat(cache): prioritize reclaiming redundant KV replicas#404
Open
GentleCold wants to merge 9 commits into
Open
feat(cache): prioritize reclaiming redundant KV replicas#404GentleCold wants to merge 9 commits into
GentleCold wants to merge 9 commits into
Conversation
There was a problem hiding this comment.
Pull request overview
This PR introduces a cold/warm segmented eviction policy for the in-memory resident KV read cache to reduce redundant P-side copies in P/D deployments. It threads a new “demote to cold” signal from vLLM’s scheduler connector through the Python RPC bindings and gRPC server into pegaflow-core, and adds metrics for resident tiering and tier-based eviction.
Changes:
- Add cold/warm resident classes to the
ReadCache, evicting cold blocks before warm blocks and supporting promotions/demotions with metrics. - Add
SetColdBlocksgRPC API + Rust/PyO3/Python stub plumbing, and call it from the vLLM scheduler connector onfinished_sending. - Add unit tests covering “demote saved hashes once” behavior and the new cache tier semantics.
Reviewed changes
Copilot reviewed 12 out of 13 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
python/tests/test_combine_hashes.py |
Adds tests ensuring finished_sending only triggers demotion once and that SAVE_ONLY does not demote. |
python/src/lib.rs |
Exposes set_cold_blocks on the Python RPC client and wires it to the new gRPC method. |
python/pegaflow/pegaflow.pyi |
Updates Python type stubs with the new EngineRpcClient.set_cold_blocks API. |
python/pegaflow/connector/scheduler.py |
Tracks pending saved hashes per request and demotes them on finished_sending (best-effort). |
pegaflow-server/src/service.rs |
Implements the SetColdBlocks gRPC endpoint on the server side. |
pegaflow-proto/proto/engine.proto |
Adds SetColdBlocksRequest/Response messages and SetColdBlocks RPC to the Engine service. |
pegaflow-core/src/storage/read_cache.rs |
Implements cold/warm class tracking, promotion/demotion, tier-first eviction, and related metrics. |
pegaflow-core/src/storage/mod.rs |
Adds StorageEngine::set_cold_blocks plumbing into the read cache. |
pegaflow-core/src/metrics.rs |
Adds resident-class attributes and metrics for resident blocks, promotions/demotions, and evictions-by-class. |
pegaflow-core/src/lib.rs |
Exposes PegaEngine::set_cold_blocks API. |
pegaflow-core/src/internode/p2p_service.rs |
Adds a “not served” stub implementation for the new RPC on the P2P transfer service. |
pegaflow-core/src/cache.rs |
Adjusts TinyLFU cache API to support keyed removals used by tiered eviction. |
docs/pd-redundancy-prefix-repetition.svg |
Adds the PD redundancy comparison visualization referenced by the PR description. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
GentleCold
force-pushed
the
feat/pd-cold-warm-eviction
branch
from
July 17, 2026 06:24
a7bceb5 to
80236cd
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.
Summary
Related RFC: #398
Reduce redundant resident KV copies in P/D deployments with a two-class replacement policy:
retained.reclaimable.finished_sendingmarks the saved blocks for that request asreclaimable.reclaimablewhenowners >= 3.reclaimableblocks beforeretainedblocks, with LRU order inside each class.The policy changes replacement priority only. It does not change NIXL, add a data-path RPC, delay registration, or introduce backpressure.
PD E2E Validation
Baseline and feature used the same generated multi-turn corpus and seed in a single-host 2P2D deployment:
MultiConnector.150 GBper instance.DeepSeek-V2-Lite-Chat.0.e3443b744287912e79e2de3a72cfbfade82972a9ec4eed77b94f5b94877ef0d1.Both runs completed all
4096/4096requests. The pool was large enough to represent the intended deployment shape while the sustained workload still created eviction pressure.Results
The feature substantially suppresses high-replication blocks once reclaim pressure begins. It performs more evictions, but the identical cache-miss count, slightly lower RDMA volume, and effectively unchanged throughput/TTFT indicate that this run did not turn the additional eviction into extra recomputation or transfer cost.
Scope and Tradeoffs
owners >= 3rule applies to every newly inserted local resident, including D-side save-only copies; the policy does not pin all D-side copies asretained.owner_countsis treated as a protocol error.Checks
pegaflow-core: 139 passed, 1 ignored.pegaflow-metaserver: 31 passed.