Last Layer KV Cache is All You Need

Zefan Cai1 Sai Bi2 Lin Zhang1 Yicong Hong3 Yuchen Zhu4 Lu Li5 Haozhe Zhao6 Hanwen Jiang2 Qinzhe Hu1 Zeyi Huang1 Shawn Lin7 Cheng Luo8 Chongjian Ge2 Jinlin Jian9 Ruijie Zhu10 Xun Huang3 Jiuxiang Gu2 Junjie Hu1 Hao Tan2
1University of Wisconsin–Madison 2Adobe 3Roblox 4Georgia Institute of Technology 5University of Pennsylvania 6University of Illinois at Urbana-Champaign 7Kuma Stroies Ltd. 8California Institute of Technology 9The Scripps Research Institute 10University of California, Santa Cruz

TL;DR — LastKV lets every layer read one shared last-layer history. It reduces long-term KV storage toward 1/L of a standard L-layer Transformer and feeds deep past representations back into future computation. Recurrence happens across chunks, while tokens within each chunk are processed in parallel.

Despite substantially compressing history, LastKV matches or outperforms standard Transformers across language modeling, state tracking, novel view synthesis, and video generation.

One history for every layer

Transformers store separate key–value (KV) states at every layer, causing memory to scale with network depth while preventing deep representations of the past from informing shallower future layers. In LastKV, all layers instead share the last-layer KV states of completed context. This reduces long-term KV storage by approximately the number of layers and creates recurrence across both time and depth.

Transformer layers each retain their own historical KV; LastKV feeds one shared last-layer KV history into all future layers.
Scroll horizontally to view the full figure. Select the image to open it at full size.
Deep history, shared across depth. A standard Transformer stores separate historical KV at every layer. LastKV exposes completed last-layer states to every layer of subsequent chunks, creating recurrence across both time and depth.

Share the deepest states

Every layer attends to the last-layer KV of completed chunks alongside its own current-chunk KV. Past tokens remain directly accessible through attention.

Keep chunks parallel

Tokens within a chunk use ordinary causal attention. Once the chunk completes, its last-layer KV is appended to the shared history for subsequent chunks.

Blend recent context

Learned per-head gates combine layer-local and last-layer KV for the immediately preceding chunk, smoothing the transition at chunk boundaries.

With L layers, T tokens, and C tokens per chunk, the persistent KV ratio relative to a standard Transformer is (T + (L − 1)C) / (LT), which approaches 1/L as the number of chunks grows.

The limit assumes equal KV widths and deduplicated storage. It counts persistent KV entries; temporary buffers and training activations are excluded. Dense attention remains quadratic.

Recurrence and gradient flow

Gradient paths and probes show how LastKV feedback connects future computation to deeper historical states.
Scroll horizontally to view the full figure. Select the image to open it at full size.
Feedback also connects the backward pass. Retaining the shared KV computation graph lets later losses reach the computations producing earlier deep states. These probes use randomly initialized six-layer models; broader gradient connectivity alone does not establish better optimization.

Long-context language modeling

We pretrain 124M and 760M models at 32K context. Tail loss measures the 30K+ portion of the sequence; RULER accuracy averages evaluations at 4K, 8K, 16K, and 32K. LastKV improves average retrieval at both scales.

124M760M
ModelTail loss ↓RULER ↑Tail loss ↓RULER ↑
Transformer3.086916.522.59834.2
Mamba-23.08513.02.58623.5
Kimi Delta Attention3.05712.12.57122.8
MoBA3.087214.702.56334.2
LaCT3.1238.52.57923.2
YOCO3.067215.142.57526.4
HySparse3.083518.742.63630.2
LastKV3.106720.052.55634.3

Selected baselines; RULER in %. Bold marks the best value in each column. At 124M, LastKV’s tail loss is higher than Transformer; at 760M, its tail loss is lower and the average retrieval advantage is small at the displayed precision. The paper reports all baselines and per-length RULER results.

State tracking and memory retention

LastKV is best or tied-best on five of the seven synthetic task families in the full comparison. The paired results below report token accuracy at 2K context.

TaskTransformerLastKV
Fixed finite-state automaton40.743.2
Mode switch78.892.6
Generalized modular sum11.421.3
Group word25.327.6
Permutation composition57.759.8
Multi-query associative recall68.4100.0
Selective copy99.9100.0

Token accuracy (%), higher is better. Bold marks the best value among all methods in the paper’s full comparison.

Novel view synthesis

Sharing last-layer KV improves reconstruction PSNR on both evaluated datasets.

ModelObjaverse PSNR ↑DL3DV PSNR ↑
Transformer25.3617.41
DeltaNet23.9415.82
Gated DeltaNet24.3216.05
LaCT23.9916.14
LastKV25.94†17.80

PSNR in dB. Bold marks the best value in each column. † The Objaverse LastKV result uses logged in-training evaluation with random view draws. Other NVS results use fixed-view full-test evaluation.

Loss and reconstruction curves

124M per-token loss, 760M per-token loss, and the shared method legend arranged in three columns.
Scroll horizontally to view the full figure. Select the image to open it at full size.
Per-token loss across the 32K sequence. Validation loss by token position, with a log-scaled position axis and positions below 2K omitted. Lower is better.
Objaverse and DL3DV per-view reconstruction PSNR curves arranged side by side with a shared legend.
Scroll horizontally to view the full figure. Select the image to open it at full size.
Reconstruction quality as observed views grow. Per-view reconstruction PSNR; higher is better. The Objaverse LastKV curve uses logged in-training evaluation with random view draws; other curves use fixed-view test evaluation.

Autoregressive video generation

LastKV improves VBench total scores at both 1.3B and 14B after teacher-forced fine-tuning.

ModelQuality ↑Semantic ↑Total ↑
Transformer 1.3B83.176.581.8
LastKV 1.3B83.578.082.4
Transformer 14B82.272.780.3
LastKV 14B83.076.481.6

VBench scores (%), from 4,730 generated videos: 946 prompts × five samples. Bold marks the better value at each size. The paper provides the full VBench breakdown and user-study protocol.

Selected 14B examples

Five selected comparisons highlighting LastKV’s prompt adherence and visual coherence. Each pair uses the same prompt.

Loading examples…

Less cache, with measured training costs

LastKV substantially reduces physical self-attention KV allocation after prefill and cached decoding. The comparisons use matched workloads, precision, and A100-SXM4-80GB hardware. LLMs train at 32K and use a 128K inference prefix with 4K chunks.

Measured training seconds per step and physical KV allocations: LastKV uses substantially less prefill and decode KV across NVS, video, and LLM workloads.
Scroll horizontally to view the full figure. Select the image to open it at full size.
Matched measurements across domains. Larger chunks reduce training cost. The memory panels count shared physical KV allocations once, including retained local buffers; they exclude model weights and temporary workspaces.
Train (s/step) ↓Prefill KV (GiB) ↓Decode KV (GiB) ↓
WorkloadTransformerLastKVTransformerLastKVTransformerLastKV
NVS1.991.890.3750.0470.3750.047
Video 1.3B13.6515.0811.2471.98212.8542.035
LLM 760M2.913.2818.0001.87518.0351.876
LLM 1.5B4.314.8925.0002.56225.0492.564
LLM 3B7.127.8136.0003.75036.0703.753

Absolute training time and physical self-attention KV allocation; bold marks the lower value in each pair. LLM decode KV follows 128 additional tokens. The 1.5B and 3B training fixtures use matched random initialization to measure runtime.

What the results establish

Sharing the last-layer history reduces persistent KV storage toward 1/L while LastKV matches or outperforms standard Transformers across the four task domains in the reported settings. The gains are not uniform: at 124M, LastKV’s long-context tail loss is higher than Transformer’s, and at 760M its average retrieval advantage is small at the displayed precision. The Objaverse LastKV result uses in-training evaluation with random view draws; the other NVS results use the fixed-view protocol.

Physical KV savings are not total GPU-memory savings, and training time increases in the reported LLM and video configurations. Dense attention remains quadratic, and broader gradient connectivity alone does not establish better optimization.

Citation

@misc{cai2026lastkv,
  title  = {Last Layer {KV} Cache is All You Need},
  author = {Cai, Zefan and Bi, Sai and Zhang, Lin and Hong, Yicong and
            Zhu, Yuchen and Li, Lu and Zhao, Haozhe and Jiang, Hanwen and
            Hu, Qinzhe and Huang, Zeyi and Lin, Shawn and Luo, Cheng and
            Ge, Chongjian and Jian, Jinlin and Zhu, Ruijie and Huang, Xun and Gu, Jiuxiang and
            Hu, Junjie and Tan, Hao},
  year   = {2026},
  note   = {Preprint},
  url    = {https://zefan-cai.github.io/LastKV.github.io/}
}