KV-Fold: One-Step KV-Cache Recurrence for Long-Context Inference
On the map: Efficient LLM inference and serving → KV cache optimization
Abstract (arXiv)
We introduce KV-Fold, a simple, training-free long-context inference protocol that treats the key-value (KV) cache as the accumulator in a left fold over sequence chunks. At each step, the model processes the next chunk conditioned on the accumulated cache, appends the newly produced keys and values, and passes the enlarged cache forward; the same one-step update is applied repeatedly, analogous to foldl in functional programming. Building on the KV cache concatenation primitive introduced for latent multi-agent communication, we repurpose it as a chunk-to-chunk recurrence for long-context inference. When processing chunk t, the model attends to the KV cache carried from earlier chunks as a prefix, reusing its internal state across segments without modifying or retraining the model. Despite its simplicity, the induced recurrence is stable: per-step drift rises briefly and then saturates into a flat plateau that persists across deep chains. This plateau is insensitive to a 10,000x change in numerical precision, robust across chunk sizes, and consistent across model families. At the task level, KV-Fold preserves exact information over long distances. On a needle-in-a-haystack benchmark, it achieves 100% exact-match retrieval across 152 trials spanning contexts from 16K to 128K tokens and chain depths up to 511 on Llama-3.1-8B, while remaining within the memory limits of a single 40GB GPU. Compared to streaming methods, which trade fidelity for bounded memory, KV-Fold maintains long-range retrieval while operating as a sequence of tractable forward passes. Overall, our results show that frozen pretrained transformers already support a stable form of KV-cache recurrence, providing a practical route to long-context inference without architectural changes or training.
Key facts. No citing papers in the map yet (data through 14 Oct 2026). Placed in KV cache optimization, one of 12 directions in Efficient LLM inference and serving. Builds on 37 of its 40 references that are in the map. First posted on arXiv 12 May 2026.
Builds on
37 of 40 references.
Closest ancestors · 6
Same direction, newest first
- 2024PyramidKV: Dynamic KV Cache Compression based on Pyramidal Information Funneling4 Jun
- 2024SnapKV: LLM Knows What You are Looking for Before Generation22 Apr
- 2023Model Tells You What to Discard: Adaptive KV Cache Compression for LLMs3 Oct
- 2023Efficient Memory Management for Large Language Model Serving with PagedAttention12 Sep
- 2023H2O: Heavy-Hitter Oracle for Efficient Generative Inference of Large Language Models24 Jun
- 2023Scissorhands: Exploiting the Persistence of Importance Hypothesis for LLM KV Cache Compression at Test Time26 May
Other references · 31
- 2017Attention Is All You Needcited by 60,361
- 2023Mamba: Linear-Time Sequence Modeling with Selective State Spacescited by 4,718
- 2021RoFormer: Enhanced Transformer with Rotary Position Embeddingcited by 4,703
- 2022FlashAttention: Fast and Memory-Efficient Exact Attention with IO-Awarenesscited by 3,673
- 2020Longformer: The Long-Document Transformercited by 3,413
- 2023FlashAttention-2: Faster Attention with Better Parallelism and Work Partitioningcited by 2,598
- 2021Efficiently Modeling Long Sequences with Structured State Spacescited by 2,465
- 2023Efficient Streaming Language Models with Attention Sinkscited by 2,186
- 2020Transformers are RNNs: Fast Autoregressive Transformers with Linear Attentioncited by 2,022
- 2019Transformer-XL: Attentive Language Models Beyond a Fixed-Length Contextcited by 1,850
- 2020Big Bird: Transformers for Longer Sequencescited by 1,684
- 2020Rethinking Attention with Performerscited by 1,601
19 more
- 2019Generating Long Sequences with Sparse Transformerscited by 1,546
- 2023LongBench: A Bilingual, Multitask Benchmark for Long Context Understandingcited by 1,417
- 2024RULER: What's the Real Context Size of Your Long-Context Language Models?cited by 1,346
- 2021Train Short, Test Long: Attention with Linear Biases Enables Input Length Extrapolationcited by 1,103
- 2020Efficient Transformers: A Surveycited by 790
- 2023Extending Context Window of Large Language Models via Positional Interpolationcited by 740
- 2019Compressive Transformers for Long-Range Sequence Modellingcited by 726
- 2024KIVI: A Tuning-Free Asymmetric 2bit Quantization for KV Cachecited by 637
- 2023YaRN: Efficient Context Window Extension of Large Language Modelscited by 601
- 2024KVQuant: Towards 10 Million Context Length LLM Inference with KV Cache Quantizationcited by 591
- 2023Ring Attention with Blockwise Transformers for Near-Infinite Contextcited by 457
- 2024LongRoPE: Extending LLM Context Window Beyond 2 Million Tokenscited by 313
- 2024OLMoE: Open Mixture-of-Experts Language Modelscited by 301
- 2022Memorizing Transformerscited by 226
- 2022Recurrent Memory Transformercited by 203
- 2024Leave No Context Behind: Efficient Infinite Context Transformers with Infini-attentioncited by 200
- 2023LM-Infinite: Zero-Shot Extreme Length Generalization for Large Language Modelscited by 124
- 2022Block-Recurrent Transformerscited by 110
- 2024ReAttention: Training-Free Infinite Context with Finite Attention Scopecited by 13
Built on by
Not cited yet.
Similar, not cited
Close in wording, no citation either way
- 2024RefreshKV: Updating Small KV Cache During Long-form Generation
- 2026Make Each Token Count: Towards Improving Long-Context Performance with KV Cache Eviction
- 2024Get More with LESS: Synthesizing Recurrence with KV Cache Compression for Efficient LLM Inference
- 2026C2KV: Compressed and Composable KV Cache Reuse for Efficient LLM Inference
- 2026ResidualKV: Residual-Based KV Cache Compression for Efficient Long-Context Inference
- 2026Beyond Speedup -- Utilizing KV Cache for Sampling and Reasoning
- 2025KVCompose: Efficient Structured KV Cache Compression with Composite Tokens
- 2026KVSculpt: KV Cache Compression as Distillation