TL;DR
As Large Language Models process longer contexts, their "working memory"—the KV-cache—balloons in size, becoming a massive bottleneck. This paper tackles the fundamental limits of compressing that memory: how many key-value pairs can you throw away while mathematically guaranteeing the attention output barely changes for any reasonable future query? By wielding geometric discrepancy theory, the authors prove the existence of "coresets" (tiny, representative subsets of the cache) that are nearly as small as the laws of information theory allow.
What Problem Does This Paper Address?
Every time a transformer generates a token, it looks back at a cached history of Keys ($K$) and Values ($V$). For massive context windows, storing this KV-cache eats up enormous amounts of memory. While engineers use plenty of clever heuristics to prune unimportant tokens, a nagging theoretical question remained open: what is the optimal compression rate if you demand provable error guarantees?
The authors study this via coreset selection—finding a tiny subset $(K', V')$ of the original $n$ key-value pairs in $d$-dimensional space such that the attention output stays within an error tolerance $\varepsilon$ of the true output. Crucially, this guarantee must hold simultaneously for all possible future queries $q$ whose length (norm) is bounded by some threshold $\rho$. Prior theoretical attempts at this left a sizable gap between what we knew how to achieve and what was provably impossible, particularly because the attention numerator outputs vectors rather than simple scalar numbers.
Methods
To shrink a dataset of $n$ items without ruining the output, the authors rely on a classic iterative "halving trick." Imagine assigning a $+1$ or $-1$ sign to every key-value pair. If you can choose signs such that the $+1$ group and the $-1$ group almost perfectly cancel each other out across all possible queries, then keeping just the $+1$ group (and doubling its weight) gives you half the data with almost the exact same behavior! Repeat this halving step logarithmically many times, and you get a tiny coreset.
Finding those magical $\pm 1$ signs is the domain of discrepancy theory, specifically a famous result called Banaszczyk’s vector balancing theorem. Here is what is standard versus what is novel:
- Standard: Using Taylor expansions to turn the exponential function in softmax ($e^{q^T k}$) into an infinite sum of tensor products, and using existing scalar coreset results to approximate the softmax denominator.
- Novel: Extending discrepancy balancing to the vector-valued numerator of attention. Instead of crudely bounding general tensor norms, the authors surgically craft a custom convex body tailored to tensors shaped specifically like attention queries ($\hat{q}^{\otimes m} \otimes u$). Because this custom shape only depends on two $d$-dimensional test vectors rather than $m$ of them, it has a much larger Gaussian volume, allowing Banaszczyk's theorem to guarantee vastly tighter cancellation.
- Simultaneous Balancing: They concatenate three vector-balancing problems into one—simultaneously preserving the attention numerator, the softmax denominator, and keeping the keys centered around zero.
Finally, to prove you can't do much better, they construct an information-theoretic lower bound using spherical codes and a reduction from the classic one-way INDEX communication game (where Alice compresses a bitstring and Bob tries to recover a random bit using an attention query).
Datasets
Not discussed in the paper. (This is a purely theoretical work proving mathematical existence and information-theoretic bounds rather than evaluating empirical benchmarks.)
Key Insights and Ideas
- Why query norms must be bounded: Why restrict queries to norm $\rho$? Think about what attention actually is: differentiable key-value retrieval. If a query vector is allowed to have an infinitely large norm, you can point it directly at a single key and scale it up until the softmax weight on that key hits $1$, cherry-picking its exact value. Supporting unbounded queries requires memorizing every value, making lossy compression mathematically impossible. Bounding the query norm is the only escape hatch.
- Independence from context length ($n$): Amazingly, the optimal coreset size doesn't depend on how many tokens $n$ were in the original prompt! Whether you compress 10,000 tokens or 10 million, the required subset size depends only on the vector dimension $d$, error $\varepsilon$, and max query norm $\rho$.
- Exploiting rank-1 query structure: When expanding $e^{q^T k} v$ into high-order tensors, a naive union bound pays a heavy price for every tensor order $m$. Recognizing that we only ever test these tensors against highly structured, rank-1 query outer products ($\hat{q}^{\otimes m}$) is the "aha" moment that shaves off massive factors in the bound.
Key Results
Assuming unit-norm keys and values in $\mathbb{R}^d$ (with centered keys) and queries of norm at most $\rho$:
- Upper Bound: There always exists an $\varepsilon$-coreset of size $S = O\left(\frac{\sqrt{d}}{\varepsilon} e^{\rho + o(\rho)}\right)$, where the $o(\rho)$ term is specifically $\frac{1}{2}\log(\rho) + O(\log\log \rho)$.
- Improvement over Prior Art: Compared to the best prior discrepancy-based streaming construction (which required size roughly $\frac{\sqrt{d}\log n}{\varepsilon} e^{2\rho}$), this completely eliminates the $\log(n)$ dependence on sequence length and cuts the exponential dependence from $e^{2\rho}$ down to roughly $e^\rho$—an improvement factor of $\log(n) \cdot e^{\rho - o(\rho)}$.
- Matching Lower Bound: Any coreset algorithm (when $\varepsilon \le 1/\sqrt{d}$) must retain at least $S = \Omega\left(\frac{\sqrt{d}}{\varepsilon} e^\rho\right)$ pairs. For general arbitrary bit-sketches (not restricted to subsets of tokens), at least $\Omega(d e^\rho / \varepsilon)$ bits are required.
Limitations and Future Work
- Existence vs. Construction: Because the proof relies directly on the classic (non-constructive) form of Banaszczyk’s theorem, this paper proves that these tiny coresets exist, rather than providing a fast, practical algorithm to find them during LLM inference (though the authors note subsequent work found polynomial-time randomized constructions using kernel discrepancy).
- A Tiny Remaining Gap: The upper and lower bounds still differ by a small factor of $O(\rho^{1/2 + o(1)})$—which translates to at most $O(\sqrt{\log n})$ in regimes where coresets are smaller than the dataset itself.
- The Large-Error Regime: When the allowed error is relatively large ($\varepsilon > 1/\sqrt{d}$), the behavior changes. For a weaker "for each fixed query" guarantee, the optimal size is $\Theta(e^\rho / \varepsilon^2)$; proving that this exact bound also holds simultaneously for all queries remains an open conjecture.
Summary updated