Skip to content

Add GPU Automatic Prefix Caching (APC) with LRU eviction - #25

Open
agrawal-nikita wants to merge 5 commits into
IBM:mainfrom
agrawal-nikita:feature/gpu-apc
Open

Add GPU Automatic Prefix Caching (APC) with LRU eviction#25
agrawal-nikita wants to merge 5 commits into
IBM:mainfrom
agrawal-nikita:feature/gpu-apc

Conversation

@agrawal-nikita

Copy link
Copy Markdown
Contributor

Adds vLLM-style Automatic Prefix Caching to the worker: KV-cache blocks already resident in GPU HBM are matched, ref-counted, and shared across requests (and across turns of the same session) instead of being recomputed. Requests skip prefill for matched prefix tokens. When HBM fills, an LRU eviction policy frees idle blocks and optionally writes them through to the CPU DRAM KVC tier so the prefix stays reusable from a slower tier.

How to test

OPAL_LOG_LEVEL=DEBUG PYTHONPATH=pwd:$PYTHONPATH python ./opal/main.py -c ./configs/defaults_apc.json

Look for GPU APC enabled: policy=LRUPolicy... at startup,
[LRU.evict] lines on eviction, and [
APC] [Evict] ... Proactively migrated N block(s) to CPU DRAM from the monitor.

Per-tier hit rates appear in the run statistics.

Nikita Agrawal added 5 commits July 28, 2026 11:34
Signed-off-by: Nikita Agrawal <Nikita.N.Agrawal@ibm.com>
Signed-off-by: Nikita Agrawal <Nikita.N.Agrawal@ibm.com>
Signed-off-by: Nikita Agrawal <Nikita.N.Agrawal@ibm.com>
Signed-off-by: Nikita Agrawal <Nikita.N.Agrawal@ibm.com>
Signed-off-by: Nikita Agrawal <Nikita.N.Agrawal@ibm.com>
@animeshtrivedi

Copy link
Copy Markdown
Collaborator

hi @agrawal-nikita - could you rebase this PR and can we review this / prepare for merging?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants