CASE STUDYRAG infrastructureOpen source · active development

VaultKV

Consistent knowledge. Current permissions. Answers you can trace.

RELEASE VALIDATION202passing tests in the documented public release
ANIMATED RESEARCH CONCEPT · NOT A PERFORMANCE FIGURE
ENGINEERING · LLM INFERENCE SERVING

The zeros in the cache: debugging CacheBlend output in LMCache

Reusing cached work made a 7B model up to 3.2× faster to its first token, and then the answers came out garbled. This is how I traced the damage to one separator token whose memory was exactly zero at every layer, and why I reported 0.440 when the target was 0.456.

8/8 → 0/8
corrupted 12k-token outputs
2.28×
median faster first token, full hits
0.440
F1, against 0.456 for full recompute
284 → 281
ms to first token, before and after
01 · NOTES YOU WOULD RATHER NOT RETAKE

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.

02 · WHY I PICKED SOMEONE ELSE'S BUG

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.

03 · THE FIRST FIX: A CATALOG THAT DISAGREED WITH THE SHELVES

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.

04 · FASTER, AND WRONG

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.

05 · THE ROOT CAUSE: A PAGE OF SILENCE

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).

06 · WHAT THE REAL BENCHMARK SAID

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

LMCache dev (no reuse)
0.459
#5584 only
0.405
#5584 + #5595
0.440
recompute 0.456

12k-token outputs with artifacts (of 8)

Exact repeat, before
8 / 8
Exact repeat, after #5595
0 / 8
Reordered, before
7 / 8
Reordered, after #5595
0 / 8
Figure 1. Reuse without the separator fix lost 5.1 F1 points; the fix recovered 3.5 of them and removed the visible artifacts. The F1 axis starts at 0.30 to separate close values.
07 · WHAT I WOULD KEEP

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.


ENGINEERING · RAG INFRASTRUCTURE

Two bugs my test suite missed and a real workload found

Two hundred tests passed. Then I pointed VaultKV at my own notes on a real Kubernetes cluster, let it run on a schedule, and watched a dashboard. The same day, two bugs showed up that no test had imagined.

23 → 69
content epochs with nothing changed
11.6 min
cold index on CPU
~0.6 s
exact repeat from the answer cache
202
tests after both fixes
01 · WHY RUN A SIDE PROJECT LIKE PRODUCTION

Why run a side project like production

VaultKV is a transactional RAG service. It answers questions from a knowledge base using immutable snapshots, checks permissions before any answer leaves, and exports Prometheus metrics to a Grafana dashboard.

The job descriptions I was reading kept asking for the same things: Kubernetes, monitoring, evaluation-gated CI and real users. I had built VaultKV and tested it, but I had never run it the way a team would run a service. So I gave it real infrastructure and a real, boring, repeating workload.

I deployed it with Helm on a local kind cluster (4 vCPUs, 8 GB) and ran the ingest job over my actual notes vault: 180 documents and 2,859 chunks, refreshed every 15 minutes by a CronJob. The first cluster, created while my disk was full, came up with broken networking, so the deployment began by tearing it down and building it again.

02 · BUG 1: AN ODOMETER TICKING IN A PARKED CAR

Bug 1: an odometer ticking in a parked car

The dashboard showed the content version climbing on every ingest run, from epoch 23 to 69 and 8,577 chunk versions, although nothing had changed. It was an odometer ticking away in a parked car. Re-importing an unchanged file published a new version each time.

That was not cosmetic. Caches in VaultKV are keyed by version, so a new version invalidates them. A version that changes every 15 minutes means a cache that never gets to work. The fix skips documents whose content is unchanged. Verified live, the next run republished 0 documents.

03 · BUG 2: A GAME WITH NO SAVE POINTS

Bug 2: a game with no save points

Cold embedding on CPU runs at about 4.4 chunks per second, so the first full index took 11.6 minutes. Embeddings were only saved when a request finished. Anyone who has played a long game level without save points knows the result: one timeout near the end and all the work so far was gone. Embeddings are now saved every 16-chunk batch, so an interrupted run picks up where it stopped.

04 · RESULTS AND LIMITS

Results and limits

After the fixes, warm questions take 5 to 6 seconds and exact repeats about 0.6 seconds from the answer cache. Both fixes shipped with tests, bringing the suite to 202. Access control works in the cluster: an unauthorized user gets no sources.

The honest limitation is the model. Retrieval finds the right documents, but a 1.5B local model often abstains or cites the wrong fact. That needs a bigger model or a larger excerpt budget, not more infrastructure.

Neither bug was exotic. Both were invisible to unit tests because unit tests check the behaviour you thought of. A real workload, repeated on a schedule with a dashboard watching it, checks the behaviour you did not.

Time to an answer (seconds, log scale)

Cold first index, CPU
11.6 min
Warm question
5–6 s
Exact repeat, answer cache
~0.6 s
Figure 2. Cold indexing is slow because embedding runs on CPU. Caching brings repeat questions under a second. The axis is logarithmic.
06 · EXPLORE THE WORK