Streaming Attention Approximation via Discrepancy Theory

Insu Han, Michael Kapralov, Ekaterina Kochetkova, Kshiteej Sheth, Amir Zandieh
2/11/2025
cs.LGcs.AIcs.DS

No official code found. Best implementation: ksheth96/BalanceKV (9 stars, last commit 2025-09-28).

Abstract

Large language models (LLMs) have achieved impressive success, but their high memory requirements present challenges for long-context token generation. In this paper we study the streaming complexity of attention approximation, a key computational primitive underlying token generation. Our main contribution is BalanceKV, a streaming algorithm for $ε$-approximating attention computations based on geometric process for selecting a balanced collection of Key and Value tokens as per Banaszczyk's vector balancing theory. We complement our algorithm with space lower bounds for streaming attention computation. Besides strong theoretical guarantees, BalanceKV exhibits empirically validated performance improvements over existing methods, both for attention approximation and end-to-end performance on various long context benchmarks.

View on arXivView PDF

Code Implementations(1)

ksheth96/BalanceKVCommunity65%

[NeurIPS 2025 Spotlight] Official implementation of our KV cache compression algorithm BalanceKV in our NeurIPS 2025 Spotlight paper "Streaming Attention Approximation via Discrepancy Theory" https://arxiv.org/abs/2502.07861

90PythonFeb 23, 20251 years ago

Cite this paper

@article{han2025streaming,
  title  = {Streaming Attention Approximation via Discrepancy Theory},
  author = {Insu Han and Michael Kapralov and Ekaterina Kochetkova and Kshiteej Sheth and Amir Zandieh},
  year   = {2025},
  eprint = {2502.07861},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/abs/2502.07861v2},
  journal = {NEURIPS 2025 2025}
}

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/2502.07861.svg)](https://codeofpaper.com/paper/2502.07861)

Discussion