Summary
This RFC proposes replication-aware KV-cache eviction for PegaFlow. Each resident block receives an eviction rank, and blocks are maintained in per-rank LRU lists:
higher rank -> evict earlier
same rank -> evict by LRU
The goal is to reduce P2P/RDMA replica expansion while preserving the decode-side Pega cache in PD-separated deployments.
Related background: #389.
Motivation
Production observations show that MetaServer redundancy can rise substantially while owner count grows faster than unique block entries. RDMA block requests, cache insertions, and registrations increase in the same periods, which is consistent with P2P/RDMA-fetched blocks becoming additional resident owners.
D-side Pega save_only should remain available because decode-side memory is intended to be used as a cache tier.
Rank Semantics
rank is an eviction-pressure score, not an exact or continuously synchronized owner count.
New local resident
After InsertBlockHashes, initialize the new resident with:
rank = max(1, owner_count_hint - 1)
The -1 reserves one level for the newly admitted resident, which is important for the P/D case. If MetaServer is unavailable or the hint is missing, use rank = 1 and do not block cache admission.
The hint initializes a new resident only. It must not overwrite the rank of an already resident block.
Pega P2P transfer
For a source block transferred to a new destination:
destination.rank = source.rank
source.rank += 1
The source records the destination for (namespace, block_hash). A repeated transfer of the same block to the same destination does not increment the source again.
This gives a move-like behavior:
A=1
B <- A => A=2, B=1
C <- B => A=2, B=2, C=1
NIXL PD transfer
NIXL is not modified and PegaFlow does not receive the destination node identity.
On the P side, the existing vLLM MultiConnector aggregated finished_sending signal is used as an idempotent hint:
This is applied once per resident state, not once per request, so repeated finished_sending events cannot increase rank indefinitely.
On the D side, a new Pega save_only resident uses the MetaServer owner hint and the owner_count - 1 rule. In the simple case:
P save -> P=1
P finished_sending -> P=2
D save_only, owners=2 -> D=1
If a Pega P2P path later transfers from a rank-2 P/D node, the normal P2P rule applies and produces source=3, destination=2.
AlreadyExists recovery
When local cache insertion returns AlreadyExists, apply a saturating local recovery:
This covers both:
- P/D NIXL GDR followed by D-side
save_only when D already has the block.
- Pega P2P/prefetch batches where some requested blocks already exist locally.
This is local state only; it does not send a rollback RPC. Repeated recovery stops at rank 1.
Example:
P=2, D1=1
P is evicted
P <- D1 via Pega P2P -> P=1, D1=2
P -> D1 via NIXL, D1 already has the block
P finished_sending -> P=2
D1 AlreadyExists -> D1=1
Eviction Data Structures
The cache keeps one block payload and two key-level indexes:
Hash -> block payload
Hash -> set/list of seen Pega-P2P destination addresses
rank -> LRU list<Hash>
Rank changes move only the key between rank LRU lists; block payloads are not copied.
When reclaiming blocks, always select the LRU victim from the highest non-empty rank list. Within one rank, use LRU order. No global candidate scan is required.
This deliberately prioritizes replication pressure over local recency. A hot, highly replicated block can be evicted and fetched again. The design assumes cache-aware routing can move hot blocks toward nodes where their replicas are useful.
Failure and Staleness Model
The design does not add eviction-to-source rollback communication. If a source or destination disappears, rank can remain temporarily high. This is acceptable because PegaFlow cache is not authoritative; the effect is replacement quality, not data correctness.
A state such as A=2, B=2, C=1 may become A=2, B=2 after C is evicted. The absence of a rank-1 anchor is accepted in the first version.
Scope
In scope:
- MetaServer Insert owner hint returned per block/batch position.
- Rank-aware resident admission and replacement.
- Pega P2P source/destination rank propagation with destination de-duplication.
- P/D NIXL handling through existing
finished_sending, without changing NIXL.
- Saturating
AlreadyExists rank recovery.
- Fixed per-rank LRU lists.
Out of scope:
- NIXL protocol changes or peer identity propagation.
- Per-eviction rollback RPCs.
- MetaServer background full scans or owner push protocol.
- Canonical owner or exact replica-count synchronization.
- Backpressure, delayed registration, or new configuration switches.
Metrics and Validation
Track at least:
- rank distribution and maximum rank;
- evictions by rank;
- RDMA/P2P fetches after eviction;
- cache
AlreadyExists recovery count;
- MetaServer redundancy;
- cache hit/miss and reclaimed bytes.
The main risk to validate is hot-block churn: high-rank local hot blocks may be evicted and fetched repeatedly if routing is not sufficiently cache-aware.
Open Questions
- Confirm the exact MetaServer Insert response shape for owner hints per block.
- Confirm the stable destination identity used by Pega P2P de-duplication.
- Benchmark per-rank LRU bookkeeping under the observed eviction rate.
Summary
This RFC proposes replication-aware KV-cache eviction for PegaFlow. Each resident block receives an eviction
rank, and blocks are maintained in per-rank LRU lists:The goal is to reduce P2P/RDMA replica expansion while preserving the decode-side Pega cache in PD-separated deployments.
Related background: #389.
Motivation
Production observations show that MetaServer redundancy can rise substantially while owner count grows faster than unique block entries. RDMA block requests, cache insertions, and registrations increase in the same periods, which is consistent with P2P/RDMA-fetched blocks becoming additional resident owners.
D-side Pega
save_onlyshould remain available because decode-side memory is intended to be used as a cache tier.Rank Semantics
rankis an eviction-pressure score, not an exact or continuously synchronized owner count.New local resident
After
InsertBlockHashes, initialize the new resident with:The
-1reserves one level for the newly admitted resident, which is important for the P/D case. If MetaServer is unavailable or the hint is missing, userank = 1and do not block cache admission.The hint initializes a new resident only. It must not overwrite the rank of an already resident block.
Pega P2P transfer
For a source block transferred to a new destination:
The source records the destination for
(namespace, block_hash). A repeated transfer of the same block to the same destination does not increment the source again.This gives a move-like behavior:
NIXL PD transfer
NIXL is not modified and PegaFlow does not receive the destination node identity.
On the P side, the existing vLLM
MultiConnectoraggregatedfinished_sendingsignal is used as an idempotent hint:This is applied once per resident state, not once per request, so repeated
finished_sendingevents cannot increase rank indefinitely.On the D side, a new Pega
save_onlyresident uses the MetaServer owner hint and theowner_count - 1rule. In the simple case:If a Pega P2P path later transfers from a rank-2 P/D node, the normal P2P rule applies and produces
source=3, destination=2.AlreadyExists recovery
When local cache insertion returns
AlreadyExists, apply a saturating local recovery:This covers both:
save_onlywhen D already has the block.This is local state only; it does not send a rollback RPC. Repeated recovery stops at rank 1.
Example:
Eviction Data Structures
The cache keeps one block payload and two key-level indexes:
Rank changes move only the key between rank LRU lists; block payloads are not copied.
When reclaiming blocks, always select the LRU victim from the highest non-empty rank list. Within one rank, use LRU order. No global candidate scan is required.
This deliberately prioritizes replication pressure over local recency. A hot, highly replicated block can be evicted and fetched again. The design assumes cache-aware routing can move hot blocks toward nodes where their replicas are useful.
Failure and Staleness Model
The design does not add eviction-to-source rollback communication. If a source or destination disappears, rank can remain temporarily high. This is acceptable because PegaFlow cache is not authoritative; the effect is replacement quality, not data correctness.
A state such as
A=2, B=2, C=1may becomeA=2, B=2after C is evicted. The absence of a rank-1 anchor is accepted in the first version.Scope
In scope:
finished_sending, without changing NIXL.AlreadyExistsrank recovery.Out of scope:
Metrics and Validation
Track at least:
AlreadyExistsrecovery count;The main risk to validate is hot-block churn: high-rank local hot blocks may be evicted and fetched repeatedly if routing is not sufficiently cache-aware.
Open Questions