feat(core): add optional no-op KV cache connector seam - #2364
marcusacosta wants to merge 3 commits into
Conversation
Wire an additive KvCacheConnector into prefix-cache lookup, store, and evict paths so external KV tiers can plug in later without changing default local-only behavior (EricLBuehler#2308). Co-authored-by: Cursor <cursoragent@cursor.com>
Code Metrics Report━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ Language Files Lines Code Comments Blanks ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ C Header 24 4497 3151 790 556 CSS 3 282 252 6 24 CUDA 124 26447 21760 1707 2980 Dockerfile 1 35 19 9 7 HTML 2 27 27 0 0 JavaScript 3 578 563 12 3 Jinja2 7 694 656 5 33 JSON 27 17989 17986 0 3 Makefile 1 18 16 0 2 MDX 36 6285 0 4616 1669 Metal Shading Lan| 37 14416 11408 1136 1872 PowerShell 1 657 571 31 55 Python 151 12539 10418 480 1641 Shell 3 1071 852 115 104 Plain Text 53 10687 0 9209 1478 TOML 28 1389 1209 39 141 TypeScript 11 1649 1410 66 173 YAML 3 25 23 2 0 ───────────────────────────────────────────────────────────────────────────────── Jupyter Notebooks 3 122 83 23 16 |- Markdown 1 60 30 22 8 |- Python 1 122 113 1 8 (Total) 304 226 46 32 ───────────────────────────────────────────────────────────────────────────────── Markdown 273 12055 0 8981 3074 |- BASH 24 300 221 47 32 |- Dockerfile 2 14 12 0 2 |- JSON 6 289 289 0 0 |- PowerShell 1 1 1 0 0 |- Python 135 7349 6120 306 923 |- Rust 62 3840 2849 394 597 |- TOML 7 92 78 0 14 (Total) 23940 9570 9728 4642 ───────────────────────────────────────────────────────────────────────────────── Rust 705 354276 318622 5547 30107 |- Markdown 416 9915 452 8275 1188 (Total) 364191 319074 13822 31295 ───────────────────────────────────────────────────────────────────────────────── Svelte 19 1969 1826 51 92 |- CSS 1 4 4 0 0 |- JavaScript 19 921 767 25 129 (Total) 2894 2597 76 221 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ Total 1515 490614 401788 41895 46931 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ |
|
Hey @marcusacosta! Thanks for the PR. Perhaps we can add an example of an external KV cache manager if this is the purpose? |
|
Yes, the seam is meant for external KV tiers. I’ll add a small example external connector (in-process / reference manager) that shows store/lookup/evict through KvCacheConnector, without a full cloud backend. Sound good? |
Provide a reference InMemoryKvCacheConnector and a runnable example so reviewers can see how an external tier plugs into the EricLBuehler#2308 seam. Co-authored-by: Cursor <cursoragent@cursor.com>
|
Added a reference external manager:
This shows store/lookup/hit through the seam. It does not offload tensor bytes to disk/S3 yet (that still needs a hydrate path). Happy to adjust the example shape if you want something different. |
|
Hmm, I was thinking something more along the lines of using the manager as one would in a realistic setting, in contrast to demonstrating the manager in isolation. Is this what you had in mind as well? |
Install KvCacheConnector via PagedAttentionConfig/MetaBuilder into the live scheduler CacheConfig, and rewrite the example as a realistic ModelBuilder + paged-attention chat run. Co-authored-by: Cursor <cursoragent@cursor.com>
|
Updated to a realistic path:
|
Summary
KvCacheConnectorhook (defaultNoopKvCacheConnectordoes nothing) so later backends (memory/disk/S3/etc.) can plug in without changing normal users.get_computed_blocks,cache_blocks, and block-pool eviction).with_connectoris opt-in); no behavior change unless a real connector is installed.Notes for reviewers
lookup_blocksreturns block IDs, those IDs must already exist in the local block pool (a future connector would download/hydrate first, then return local IDs).