Notes you would rather not retake
When a language model reads a prompt, it takes notes on every token as it goes: a key and a value at every layer, together called the KV cache. Generating an answer means consulting those notes. Writing them is the slow part, so serving systems try hard never to write the same notes twice.
The easy case is a shared prefix. If two prompts start with the same text, the notes for that opening can be reused. Retrieval-augmented generation breaks that case: the same passages come back in a different order every time, so the shared text is rarely at the start. CacheBlend handles this by reusing each passage's notes wherever it appears and recomputing a small slice to stitch the passages together.
In LMCache with the vLLM V1 connector, that path was broken (issue #3238). Stored passages were never found again.
Why I picked someone else's bug
I had my own project in this space, a transactional layer for RAG. Looking at it honestly, I concluded it was neither impressive enough nor useful to enough people. A bug that blocked everyone using CacheBlend on vLLM V1 was both, so I made it the headline and moved my own design to an optional layer.
Someone had claimed the issue a few weeks earlier, so before writing any code I asked in the thread whether they were still on it. I also set myself a constraint: free compute only, using Colab and my university's cluster.
The first fix: a catalog that disagreed with the shelves
The first bug was a librarian's nightmare: the catalog and the shelves disagreed. Empty segments made the lookup and storage token databases differ, so a stored passage could never be matched. My first fix (PR #5584) skipped empty segments. Non-prefix reuse started working, and on reordered documents a Qwen2.5-7B benchmark showed a 3.2× faster time to first token.
Faster, and wrong
With reuse working, blended answers were visibly corrupted, with stutters like the the in the middle of sentences. On 12k-token prompts, 8 of 8 outputs had artifacts. Donald Knuth called premature optimization the root of all evil. A speedup that changes the answer is not a speedup at all, so this became the real problem.
I isolated it by ablation instead of guessing, ruling out one suspect at a time. Without blending, LMCache produced correct text. With blending but no write-back, the output was still garbled. All 28 layers were flushed, and the fused RoPE path passed its self-check. That ruled out storage, positions and the KV layout. As Sherlock Holmes put it, once you have eliminated the impossible, whatever remains must be the truth. What remained was the blender itself.
The root cause: a page of silence
Between passages sit separator tokens, the model's equivalent of a chapter break. The layerwise blend loader zero-filled the notes at those separator positions, and the blender never recomputed them. Every delimiter token therefore had K = V = 0 at every layer. Imagine a book stitched together from chapters where every chapter break has been replaced by a page that is not blank but pure static. Attention found holes exactly where the model expects document boundaries.
The fix (PR #5595) recomputes only those gap positions. Artifacts on 12k-token Qwen2.5-7B prompts went from 8/8 to 0/8 on exact repeats and from 7/8 to 0/8 on reordered passages. Time to first token was unchanged (284 → 281 ms).
What the real benchmark said
Artifact counts are not task accuracy, so I ran LongBench 2WikiMQA on an A100: 97 questions, with passages precomputed alone and then blended. Full recomputation scored F1 0.456. Reuse without the separator fix dropped to 0.405. With both fixes it was 0.440, recovering 3.5 of the 5.1 lost points. On paired full-hit prompts the median time to first token was 2.28× faster than recomputation.
The remaining gap pointed to a second bug. Flash-attention's bottom-right causal alignment lets scattered recomputed queries attend to future keys, which is a bit like letting a reader peek at the next chapter. A true-mask probe confirmed it, but it ran 4× slower. A correct fix that makes a speedup feature four times slower defeats its purpose, so I filed issue #5596 with a proposed paged fix instead of shipping the slow one.
F1 on 97 2WikiMQA questions
12k-token outputs with artifacts (of 8)
What I would keep
Measure correctness before celebrating latency, ablate one component at a time, and report the honest number: 0.440 is not 0.456. All three upstream items were still open and under review when this was written.