Skip to content

vllm.v1.kv_offload.cpu.policies.lru

Classes:

  • LRUCachePolicy –

    LRU caching policy with logical recency independent of transfer pinning.

LRUCachePolicy

Bases: CachePolicy

LRU caching policy with logical recency independent of transfer pinning.

Eviction takes unretained chunks before retained chunks, in increasing (rank, key) order within each class. Recency can be updated while pinned; when it later becomes evictable, it is ordered by the rank assigned by the request rather than by its transfer-completion time.

Active requests share a provisional rank across batches, ordered by token position so tails precede heads. Finalization commits the request's recency.

A use is indicated by, - First time the key is added (store). - A request-scoped access.

Each evictable chunk is indexed exactly once, under its current retention class and rank. Updates avoid full rebuilds of the eviction order.

_push_evictable(key)

Index an evictable key using its current lease state.

_EvictionIndex

Exact rank order for one retention class.

Fresh maximum ranks append to the ordered tail in O(1). Entries that cannot append go into bounded sorted sublists. Iteration merges both parts, and each indexed key has exactly one entry.

_SortedEntries

Sorted list of distinct index entries in sublists of bounded length.

An insert or remove bisects the per-sublist maxima, then moves at most one sublist's worth of elements. Splitting a full sublist or dropping an empty one also shifts the per-sublist lists, which is O(number of sublists).