IN THIS BREAKDOWN · 10 SECTIONS
You can read 20% of this breakdown.
The paper in one minute
Caching a long context's KV cache saves prefill the next time the context is used: a chat history, a contract, a codebase file. The catch the paper points at is that the cache rarely stays in the same GPU's memory. It gets offloaded, stored on another server, or needed by a different GPU, and it is big. The paper's example: an 80,000-token annual report on a 34B model produces 19 GB of KV, about the size of the model. Between regular cloud servers, at single-digit Gbps, fetching that can take longer than computing it from the text.
CacheGen shrinks the cache for transmission rather than for GPU memory. Since the cache only has to be rebuilt into tensors on arrival, it can be encoded as a bitstream, much like video. Three observations drive the encoder. Within a channel, nearby tokens have similar values, so it stores one anchor token per group of 10 at 8 bits and the rest as differences. Errors in early layers hurt more than errors in deep layers, so deeper layers get coarser quantization. Values grouped by channel and layer have lower entropy than values grouped by token, so arithmetic coding uses a probability table per channel and layer, profiled once per model.
The second half is streaming. Each context is split into 1,500-token chunks, each encoded offline at several levels. When a request arrives, chunks are sent one at a time; for each, CacheGen measures the throughput of the previous chunk and picks the least lossy option that still meets the time-to-first-token (TTFT) target, including sending the raw text and recomputing that chunk. Decoding runs on the GPU and overlaps the next chunk's transfer.
On Mistral-7B, Llama-34B and Llama-70B over 662 long contexts, CacheGen's KV was 3.5-4.3x smaller than uniformly quantized KV at similar quality. At 3 Gbps, TTFT was 3.2-3.7x lower than the quantization baseline and 3.1-4.7x lower than sending text. Under fluctuating bandwidth with a 1 s target, misses dropped from 81% to 8%.
Research notes: the problem, approach and results
smaller KV cache than uniform quantization at similar quality, three models and four datasets
lower time to first token than the quantization baseline at 3 Gbps, including transfer and decoding
requests missing a 1 s time-to-first-token target under 0.1-10 Gbps bandwidth, quantization vs CacheGen
Reusing a long context's KV cache skips prefill, but the cache is large (19 GB for an 80,000-token report on a 34B model, per the paper) and usually sits on another machine. Over the single-digit Gbps links between ordinary cloud servers, fetching it can take as long as recomputing it, and bandwidth changes mid-transfer.
Encode the KV cache offline into bitstreams instead of keeping tensor shape: deltas against an anchor token every 10 tokens, coarser quantization in deeper layers, and arithmetic coding with a probability table per channel and layer. Store each 1,500-token chunk at several levels and pick a level (or plain text to recompute) per chunk while streaming, to meet a time-to-first-token target.
Across Mistral-7B, Llama-34B and Llama-70B on four long-context datasets, KV size fell 3.5-4.3x against uniform quantization at similar quality, and time to first token fell 3.2-3.7x against quantization and 3.1-4.7x against sending text, at 3 Gbps. With varying bandwidth and a 1 s target, misses fell from 81% to 8%.
Why it matters to an FDE
Once a customer's contexts outgrow GPU memory (long chat histories, document assistants, many tenants), cached KV lives in host memory, on SSD or on a storage service. At that point network bandwidth, not GPU compute, decides whether the cache helps.
Do the transfer arithmetic before promising a cache win. KV size per token is fixed by the model's shape; divide by the link speed and compare with prefill time. On a 10 Gbps link a multi-gigabyte cache may be slower than prefill.
Transmission-time compression is a different lever from GPU-memory compression. KV quantization for memory must keep tensors usable by the attention kernel; a codec for the wire can use entropy coding and deltas and decode on arrival. The two stack.
Treat cache fetch like a video stream with a deadline. Bandwidth inside a cloud region varies. Choosing quality per chunk against a TTFT target, with text as a fallback, keeps latency predictable instead of hoping the link holds.
Understand the mechanism. Try it on a real problem.
Unlock this breakdown and 149 more papers.
Premium opens every paper in full, plus every answer, concept, course and guide on the site. One payment for six months of access.
6 months · One payment · No auto-renewal
- ◇1 architecture diagram
- </>1 runnable code experiment
- ▦2 results tables
- ?5 interview questions with answers
- 03Key takeaways
The three KV properties, the encoder, the adaptation rule and three misreadings
Free account - 04How it works
The offline encoder, the per-chunk adapter, the integration and the default settings
Premium - 05The numbers that matter
Setup, size and TTFT results, adaptation, overheads and the storage cost note
Premium - 06Try it yourself
Recheck the paper's arithmetic, build the encoder step by step, and stream against an SLO
Premium - 07Where it breaks
Fixed tables, KV-shape assumptions, fast links, limited quality metrics and slips
Premium - 08Using it on a deployment
Deciding whether to cache, fetch or recompute, and how to set levels and SLOs
Premium - 09Interview angles
Five questions this paper prepares you for, with answer hints
Premium - 10Read next
Where to go from here on this site
Premium
