Caches: prefix pool, spill tier, shared KV pool and vision

On this page

A conversation grows one turn at a time, and an agent sends nearly the same long prompt again and again. The engine keeps work it has already done so it does not redo it. This page lists the layers, from the fastest to the largest, and the flags that control them. Items marked v0.8.0 are new in that release.

The layers

Layer Where it lives What it keeps Flags Default
Prefix cache each lane, GPU memory the lane's own last prompt --prefix-cache on on in the recommended launch lines
Prefix pool GPU memory, shared by all lanes prompt states of conversations that lost their lane --prefix-pool-gb, --prefix-pool-floor-gb on, with --prefix-cache on
Spill tier disk (SSD) prompt states pushed out of memory --kv-spill, --kv-spill-gb off
Shared KV pool (v0.8.0) GPU memory, one pool for every lane's KV the KV rows lanes actually use --kv-pool, --kv-pool-gb, --fit-floor-gb off
Vision embed cache (v0.8.0) head memory the vision tower's output per image --vision-embed-cache-mb on

Prefix cache and prefix pool

With --prefix-cache on, a request whose prompt starts with what a lane already read resumes from there and reads only the new part. When a new conversation takes over a lane, the prefix pool copies the old conversation's prompt state into a pool shared by all lanes, so its next turn can still resume. --prefix-pool-gb caps the pool per machine and --prefix-pool-floor-gb is the free memory it always leaves. Under tensor parallelism each machine keeps its own share and the machines agree on every copy.

v0.8.0: the pool also keeps image prompts, and when it is full it keeps the deeper (more expensive to rebuild) prompts rather than simply the newest.

Spill tier

--kv-spill auto (or a directory) saves a prompt state to disk when it is pushed out, and restores it when its conversation returns, but only when reading it back beats reading the prompt again. --kv-spill-gb caps the store. It is off by default.

v0.8.0: a conversation that comes back while its snapshot is still being written waits briefly for the write instead of reading its prompt again; snapshots left on disk by an earlier run are taken back under the size cap at start-up (and broken ones deleted) instead of piling up unseen; and a conversation that returns shorter than its saved snapshot (a regenerated or edited last turn) restores the matching front part instead of reading the whole prompt again.

v0.8.1: every snapshot is sized exactly before it is copied off the GPU and checked against the memory actually free; one that does not fit is saved in a smaller form or skipped, identically on every machine.

Shared KV pool (v0.8.0, opt-in)

Normally every lane gets a fixed KV area sized for --max-seq-len. With --kv-pool lazy the lanes instead draw memory pages from one shared pool (--kv-pool-gb), mapped only for the rows a lane actually uses. One long conversation can then grow to a very long context while other lanes stay small, all from the same memory budget. When the pool is full, idle lanes are evicted first (their prompts are kept by the prefix pool and spill tier); a running lane that cannot grow finishes with finish_reason: length. CUDA graphs and kernels are unchanged. --kv-pool full maps every page at start-up and behaves like the fixed layout; off is the default.

Scope: the EXL3 server on one machine. With --tp, or on a model whose KV is laid out differently, the server starts with the standard layout, prints one line saying so and records it on /metrics. --fit-floor-gb sets the free memory the start-up plan keeps.

Contributed by @AbsolomBane (#43).

Vision embed cache (v0.8.0)

A chat client usually sends the same image again on every turn. The vision embed cache keeps the vision tower's output for each image, keyed on the image's content, and reuses it when the same image comes back, skipping the tower. A hit compares the image's data byte for byte, so it can never serve the wrong image. --vision-embed-cache-mb sets the size (default 512 MiB; 0 turns it off). Under tensor parallelism it lives on the head, where the vision tower runs.

Contributed by @rusty-dev (#42).

Seeing what they do

/metrics reports hits, misses, evictions and sizes for each layer (velogb10_vision_cache_*, velogb10_kv_vmm_* and the prefix and spill counters). Operating a deployment covers the rest of the metrics.