The Residual Stream Is All You Need: On the Redundancy of the KV Cache in Transformer Inference

Kaleem Ullah Qasim, Jiashu Zhang, Muhammad Kafeel Shaheen, Razan Alharith, Heying Zhang
3/20/2026
8 citations
cs.LGcs.AI
transformer-attention

Official code: Kaleemullahqasim/KV-Direct (10 stars, MIT, last commit 2026-08-12).

Abstract

The key-value (KV) cache is widely treated as essential state in transformer inference, and a large body of work engineers policies to compress, evict, or approximate its entries. We prove that this state is entirely redundant: keys and values at every layer are deterministic projections of the residual stream, and recomputing them from a single residual vector per token incurs exactly zero reconstruction error, not approximately, but bit-identically.

Show full abstract

We verify this across six models from four architecture families (135M to 4B parameters). Cross-task residual patching at every layer produces D_KL = 0 between patched and original output distributions, confirming that the residual stream satisfies a Markov property and is the sole information-carrying state. Removing the cache entirely and recomputing from scratch yields token-identical output under greedy decoding on all models tested. We build on this result with KV-Direct, a bounded-memory inference scheme that checkpoints residual vectors (5 KB per token on Gemma 3-4B) instead of full KV pairs (136 KB), recomputing keys and values on demand. Over 20 conversation turns, KV-Direct holds peak memory at 42 MB while the standard cache grows past 103 MB. Against five eviction baselines (H2O, StreamingLLM, SnapKV, TOVA, window-only), KV-Direct maintains 100% token match at every cache budget; all baselines degrade to 5-28%. A per-operation latency analysis shows recomputation runs up to 5x faster than reading cached tensors at moderate batch sizes. Code is available at https://github.com/Kaleemullahqasim/KV-Direct.

View on arXivView PDF

Code Implementations(1)

MIT

KV-Direct: lossless bounded-memory LLM inference via exact KV recovery from the residual stream. Paper under review at Journal of Systems Architecture

103Mar 18, 20263 months agoMIT
efficient-inferencekv-cachellm-inferenceresearch-papertransformers

Similar Papers

Cite this paper

@article{qasim2026residual,
  title  = {The Residual Stream Is All You Need: On the Redundancy of the KV Cache in Transformer Inference},
  author = {Kaleem Ullah Qasim and Jiashu Zhang and Muhammad Kafeel Shaheen and Razan Alharith and Heying Zhang},
  year   = {2026},
  eprint = {2603.19664},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/abs/2603.19664v1}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2603.19664.svg)](https://codeofpaper.com/paper/2603.19664)

Discussion