IN THIS BREAKDOWN · 10 SECTIONS
You can read 19% of this breakdown.
The paper in one minute
A RAG prompt stacks several retrieved chunks in front of the question. The same chunks keep coming back across queries, so it is tempting to compute each chunk's KV cache once and reuse it. Two existing ways do that, and both fall short. Prefix caching (vLLM, SGLang) reuses a cache only when it is the prompt's prefix, so with six chunks it saves the first one at best. Full KV reuse (PromptCache) concatenates each chunk's separately computed cache with its positions corrected. It is fast, but each chunk's cache was computed without seeing the chunks before it, so the cross-attention between chunks is missing. The paper's example: one chunk gives Messi's World Cup goals, another Ronaldo's, and full reuse can't compare them.
CacheBlend reuses every chunk's cache and repairs it. On each layer it recomputes the KV of a small share of tokens, the ones whose cached KV deviates most from what a full prefill would produce. Finding them exactly would need the full prefill, so it uses a shortcut: tokens that deviate on one layer tend to deviate on the next. It recomputes all tokens on the first layer, ranks them by deviation, and on later layers recomputes only the top-ranked tokens, narrowing the set slightly each time. About 10% to 15% of tokens carry most of the deviation, and 15% is the default.
The second idea is pipelining. Recomputing a layer's selected tokens can overlap with loading the next layer's cache from CPU memory or SSD; when loading is the slower step, the recompute is free. That makes cheap, large storage (SSD) usable for KV caches.
Across Mistral-7B, Yi-34B and Llama-70B on 2WikiMQA, Musique, SAMSum and MultiNews, time to first token (TTFT) fell 2.2-3.3x against full prefill with quality within about 0.02, and throughput rose 2.8-5x. The code lives in the LMCache repository.
Research notes: the problem, approach and results
lower time to first token than full prefill, three models and four datasets, quality within about 0.02
share of tokens recomputed per layer by default; 5%-18% lost at most 0.002 F1 or Rouge-L on Yi-34B
per-layer time to recompute 15% of tokens versus load the layer's KV from NVMe, Llama-7B, 4K context
RAG inputs are several retrieved chunks, and the same chunks recur across queries in different orders. Prefix caching reuses only the first chunk. Concatenating separately cached chunks (full KV reuse) is fast, but each chunk's cache was computed without the chunks before it, so answers that need facts from two chunks go wrong.
Reuse every chunk's cached KV, then on each layer recompute the KV of the small set of tokens whose cached values deviate most from what a full prefill would give. Find them on the first layer and narrow the set layer by layer, and pipeline this recompute with loading the next layer's cache from RAM or SSD so it adds little or no delay.
Across Mistral-7B, Yi-34B and Llama-70B on four datasets, time to first token fell 2.2-3.3x and throughput rose 2.8-5x against full prefill, with F1 and Rouge-L within about 0.02. Full KV reuse scored 0.15-0.35 lower.
Why it matters to an FDE
In a customer's RAG deployment, the retrieved context is most of the prompt and most of the prefill time; the question itself is a few dozen tokens. Popular documents, policies and product pages get retrieved again and again, in different combinations. That repeated work is what CacheBlend targets.
Prefix caching does less for RAG than people assume. It helps the shared system prompt and the first chunk. Unless the customer always retrieves the same chunks in the same order, the rest is recomputed every time.
Naive chunk caching is a correctness bug, not just a quality dip. Gluing separately cached chunks together drops the attention between them. Questions that compare or join facts across documents are exactly the ones that break, and they are often the ones the customer cares about.
Where the cache lives is a latency decision. CacheBlend's pipelining lets a slower, cheaper tier serve the cache without adding delay, up to the point where loading becomes the bottleneck. That turns "can we afford to cache this corpus" into arithmetic you can do in an afternoon.
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
Four reuse strategies compared, why sparse recompute works, the pipeline, and three misreadings
Free account - 04How it works
The selective recompute, the narrowing token selection, the loading controller and the store
Premium - 05The numbers that matter
Setup, TTFT and quality, throughput, recompute ratios and storage tiers
Premium - 06Try it yourself
Check the per-layer timing, run selective recompute on a toy model, and size the storage tier
Premium - 07Where it breaks
Approximation limits, workload assumptions, a single storage tier and slips
Premium - 08Using it on a deployment
Measuring chunk reuse, choosing the storage tier, and checking quality on cross-document questions
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
