← Home

KV Cache as Editable Notebook: Prefill Writes Conclusions

By James Trappett · 18 June 2026

4 min read

Prefix caching is one of the more practically important optimisations in LLM deployment: reuse the key/value tensors from a shared prompt prefix and avoid recomputing them on every turn. The catch is that it requires an exact prefix match. Change a single token anywhere in the cached region and the entire downstream cache is invalidated. This paper, arXiv:2606.17107, investigates why a seemingly obvious fix fails, and turns the answer into two genuinely useful capabilities.

The obvious fix is surgical: when a mutable field changes (a timestamp, an order status, a user ID), refresh only that field's own key/value vectors and leave the rest of the cache intact. The paper reports this fails completely. The model's output reverts to the old field value as if the edit never happened. Understanding why leads to a reframing of what a KV cache actually is.

The Core Mechanistic Finding

The central claim is that during prefill, transformers do not merely cache raw token representations. At a small number of positions downstream of a mutable field, specifically at aggregator tokens like punctuation, newlines, and section breaks, the model computes a field-conditioned conclusion and writes it into those positions' cached key/value vectors at mid-to-late layers. The authors call these the notes. When the decode step generates a decision token, it attends back to these note positions rather than re-deriving the answer from the field itself. The field's own KV contribution to the final decision is measured at under 1% across four model families.

This account is established through four causal probes, not just correlational analysis:

These results replicate across Qwen3-8B/4B, Llama-3.1-8B, Gemma-2-9B, and Mistral-7B, ruling out tokeniser or architecture artefacts.

Two Practical Capabilities

Once you accept that the KV cache is a structured record of intermediate conclusions rather than a passive write-once byproduct of prefill, two operations become natural.

Editability. Rather than refreshing the field's KV, append a salient erratum after the field. This amends the notes that the decision reads. With chain-of-thought, the field-only edit alone (roughly 1% of compute) recovers the decision fully (1.00 on Qwen3-8B), because the reasoning chain re-reads the field and overwrites the stale note. Without CoT, the identical edit is ignored (0.00). The dividing factor is CoT mode, not model scale. For non-CoT settings, the recommended default is a field-plus-erratum append, which requires no prompt surgery and composes with production prefix caching at a 98.5% cache hit rate in an online vLLM benchmark.

Composability. Because the notes are position-portable, a precompiled skill (a cached KV block representing a tool specification, a policy, or a retrieved document) can be RoPE-repositioned and spliced into an arbitrary context. The authors report logit cosine similarity of 0.90 to 0.999 against full recompute across twelve models, at O(L) rather than O(L²) time-to-first-token cost. A unified edit-plus-compose agent achieves decision-identical outputs to full recompute at up to 14.9x lower latency, with p90 time-to-first-token reductions of 53 to 398x in the vLLM benchmark.

Methodology and Scope

The experimental setup is deliberately minimal but agent-realistic: a context contains a policy rule and a mutable field whose value determines the correct action. This is close enough to real agentic workloads (order status, user permissions, tool availability) to be meaningful, and controlled enough to measure causal effects cleanly. The authors also validate on a real retail policy benchmark (tau-bench) and real image inputs for multimodal caches, which partially addresses the synthetic-template concern.

Validation spans scale, quantisation, Mixture-of-Experts architectures, and multimodal caches. Attention variants including Multi-head Latent Attention and sliding-window attention are handled through small adapters, though with acknowledged edge cases. The approach is explicitly scoped to per-token attention KV caches; pure-recurrent, SSM, and diffusion models are out of scope, and hybrid attention-SSM models are only partially served.

One methodological point worth flagging: the field-plus-selective recompute approach (a CacheBlend-style ranked selective recompute) underperforms here because it targets tokens with high KV deviation, which are the field tokens themselves, rather than the aggregator tokens that actually carry the memoised conclusion. This is a useful illustration of why understanding the mechanism matters for engineering the right fix.

Limitations and Broader Implications

The authors are candid about what does not work reliably. The field-only surgical edit is model- and domain-dependent; the number of aggregator tokens needed (K*) varies non-monotonically with scale (approximately 4 at 8B but over 64 at 4B). It is presented as a fast-path under CoT, not a general default. Sequence-dimension KV compression and cross-attention image caches are analysed but not implemented. Broader real-workload evaluation beyond the retail policy benchmark remains future work.

The mechanistic finding connects naturally to the mechanistic interpretability literature on information routing through attention, and the aggregator-token account is consistent with prior work on how transformers use punctuation and structural tokens as information bottlenecks. What is new here is the causal demonstration that this routing writes reusable, addressable conclusions into the cache during prefill.

The longer-term implication the authors gesture toward is a KV cache that is programmable by design: models trained to expose cleanly addressable, composable notes rather than incidentally producing them. That is a training objective, not just an inference trick, and it would change how context engineering works at a fairly fundamental level. Skills, memory, and state become first-class cache objects rather than text that must be re-prefilled on every turn. This paper does not get there, but it establishes the mechanistic ground that such a direction would stand on.

The full paper is available at https://arxiv.org/abs/2606.17107.

LLM InferenceKV CacheTransformersMechanistic InterpretabilitySystems ML

Related Articles

DivInit: Diverse Query Init for Better Agentic Search ScalingRepSelect: Targeting Forget-Specific Representations for Deep LLM Unlearningllada.cpp: Diffusion LLM Inference on Mobile NPUs