Frontier Foundry

KV Cache

The Power Plant · Inference & Serving

Memory of past tokens' attention keys and values, the main memory cost of long contexts.

Also called: kv-cache, prefix caching, pagedattention, paged attention, cache offloading. In the glossary.

KV Cache is cooling this week (×0.32 against the eight weeks before). What is moving.

How it works, as a machineThe Block Warehouse · turns

Follow one turn from a long prompt at the door to its first token, served from the cache, in a block warehouse behind a pod router's door.

  1. Route to the warm pod
  2. Match the prefix
  3. Page the blocks
  4. Stamp keys and values
  5. Shelve the blocks
  6. Append the new key
Play KV Cache

KV Cache in plain words

The KV cache is the working memory a model keeps for each token it has already read, so that it does not reprocess the whole text for every new token. It makes generation fast. It also grows with the length of the context, and is the main memory cost of long conversations.

An analogy

Notes taken while reading a long contract aloud. With a note on every clause so far, the reader can handle the next clause without going back to page one. The pile of notes grows with every page, and in the end the desk holds more notes than contract.

How KV Cache connects

12 typed relations in the knowledge graph

Builds on

  • Inference Serving: The router and the pods are the serving layer the request travels through.
  • Long Context: A longer context is more blocks on the shelves per user.
  • Quantization: Squeezing the blocks to fewer bits is quantization applied to the cache instead of the weights.

Built on by

  • Efficient Attention: The drawers are the key-value cache: what each token leaves behind for the ones after it.
  • Inference Serving: The prompt prefill scanner fills each request's KV cache and the scheduler spends the cache that is left.
  • Looped Transformers: Every pass leaves a cache of its own unless the passes share one.
  • Quantization: The cache beside the weights competes for the same video memory, and can be rounded too.
  • Speculative Decoding: Both models need key-value space on the GPU, so the second model has a memory cost.
  • Transformers & Attention: The shelf of earlier keys and values that decode reads is the KV cache.
  • Vision-Language Models: Thousands of visual tokens fill the key-value cache and make decoding expensive.
  • World Models: The cache rack is a bounded key-value cache; the drawers keep what it would evict.

Makes possible

  • Fast Inference: Keeping the keys and values of what was read makes each new token one step, not a rereading.

Often in the same sources

Speculative Decoding, Inference Serving, Quantization, Efficient Attention, Long Context, Fast Inference

See KV Cache in the knowledge graph

KV Cache in the news

from the daily digests

Who is behind KV Cache

people, labs, products and models

Named in its facts

What the sources say

3 parts · 11 sources · updated 2026-11-27

The KV cache is the memory a model builds while it reads a prompt: one key and one value for every token, kept so they are not computed again. Sources follow one turn through a router and a prefix match that reuse old blocks, a table and a bench that page and fill new ones, and the shelves in GPU memory that fill first; squeezing the blocks to fewer bits frees room and costs speed.

Front hall: from a turn to its matched prefix

Two stations a turn meets before any new keys are made: a router that sends it to the pod that already holds its opening, and a ledger that matches that opening to cached blocks.

  1. The router sends the turn to the pod that already holds its prefix and has room to serve it.
  2. The prefix ledger matches the turn's opening to cached blocks, so only the new tail needs new keys.
well over 90%
Cache hit rate the speakers usually see on agent workloads that reuse the system prompt and tool definitions Yuchen Fama
10x
Price gap between cached and uncached tokens on one lab's API, as a speaker cites it Yuchen Fama
about 3 seconds against about 1 second
Time for a first turn that fills the cache against a second turn with the same system prompt, in a routing demo Yuchen Fama
  • A router that is aware of the KV cache scores each pod on running and waiting requests, KV cache use and whether the prefix is cached, then picks the lowest-load pod most likely to hit. Yuchen Fama
  • In a demo, the first turn filled the cache and took about 3 seconds; the second turn, with the same system prompt, went to the same pod and took about 1 second. Yuchen Fama
  • Agent traces reuse the system prompt and the tool definitions every turn, so their cache hit rates are very high. Yuchen Fama

Block hall: from a new tail to filled blocks

Two stations that give the new tail memory and keys: the table that hands out small blocks and the bench that computes and writes one key and one value per token.

  1. The block table desk hands each request small blocks, one at a time as its new tokens need room.
  2. The key-value bench computes one key and one value for each token of the tail and writes them into its blocks.
50%
Memory wasted in the speaker's example, where each request gets a contiguous slab twice the size it needs Harshul Jain
about 900 ms against about 100 ms
P99 gap between tokens, in one case study of aggregated against prefill-decode split serving of a multi-turn workload with a 10,000-token prefix Ashish Kamra
  • Every token needs its key and value vectors, so the number of vectors grows with the length of the input. Harshul Jain
  • Without a cache, each new token recomputes the vectors of all earlier tokens, which is quadratic work; a memory of the vectors trades that for space. Harshul Jain
  • Paged attention treats memory as blocks that are given out as new tokens arrive; a request sees contiguous memory that maps to scattered physical blocks. Harshul Jain

Shelf hall: from filled blocks to the next token

Two stations where the cache lives and grows: the block pool in what the weights leave of GPU memory, and the counter that adds one key and value per step. The pool fills first.

  1. The block pool holds every request's blocks in the memory the weights leave free on the card.
  2. The append counter adds one key and value per step and reads all earlier ones to choose the next token.
131 KB per token, 42 GB for 80 users at 4K
Cache size per token for a 7-billion-parameter model, and the total the speaker computes for 80 users at 4K context Harshul Jain
more than half
Cut to tokens per second that a 4-bit cache method adds, because decode does extra computation, as the speaker reports Philip Kiely
890 bytes per token
Cache footprint that must stay on the card for one model that combines cross-layer reuse with 4-bit storage, about a quarter of its predecessor Hugging Face
up to 40 percentage points
Spread in long-context retrieval accuracy across token phases in open-weight models with chunked cache compression Hugging Face
32-43% higher throughput
Gain of random eviction over the strongest score-based evictor in one vLLM deployment, while matching it on six reasoning tasks Hugging Face
  • GPU memory holds the fixed weights, a fixed overhead, and what is left for keys and values; that leftover sets how many tokens can be held at once. Harshul Jain
  • For a fixed card and model, the leftover is split between context length and users: more users means a shorter context, which can cost quality. Harshul Jain
  • Decode time still rises with input length, because each step pulls the keys and values of every earlier token from memory. Harshul Jain

When it breaksThe shelves fill before the users do. The workshop speaker works the numbers for a 7-billion-parameter model: each token costs 131 KB, 80 users at 4K context need 42 GB, and a 24 GB card is out of room. More users means a shorter context, or the answers are cut. Harshul Jain

Open questionWhen the shelves are full, which cached tokens do you drop?

  • Score each token by attention and by how surprising it was, and keep the top ones; entropy tells which tokens matter far ahead. Hugging Face
  • The score adds almost nothing: keep the prompt and evict at random inside each head, because the reasoning trace repeats what it still needs. Hugging Face

Sources

11 in all

More in Inference & Serving

The Power Plant: the whole area