alphaFeedback

WorksComputer Science

Attention under Bounded Key-Query Similarity: Space Complexity and Transformer Anisotropy

AI contributions
  • generative AI tools
View details

Abstract

A growing body of work on KV-cache compression aims to reduce the memory requirements of autoregressive generation. These methods compress the stored context while approximately preserving attention computation, enabling generation with reduced memory consumption. Almost tight theoretical results on the worst case space complexity of attention have recently been obtained, but they are achieved by instances where queries can be perfectly aligned with keys. This directly contradicts the observed anisotropy of the key/query geometry in real transformers. In particular, it has been shown empirically that key/query cosine similarities are small even for most correlated pairs, i.e., near-perfect alignment of queries with keys does not happen in practice. In this paper, we study the space complexity of attention approximation under the assumption that key/query cosine similarities belong to a small interval around zero, i.e., a query cannot align too much with any key. We give a nearly space optimal algorithm and a corresponding space lower bound. Surprisingly, the distribution of key/query cosine similarities in our lower bound exhibits the anisotropy property empirically established and studied in the literature. Additionally, we show that the simple uniform sampling algorithm is nearly optimal for a typical range of parameters, supporting its surprising effectiveness on real datasets.

Introduction

The high memory consumption of modern large language models (LLMs) is a major challenge in their deployment, as the decoding stage of transformers requires storage of all tokens seen so far. The growing body of work on Key-Value (KV) cache compression has been proposed to address this challenge. These algorithms rely on innovative ways of approximating the attention function of the context using small space, either by quantizing the vectors, or evicting some of them to retain the most informative ones. In both cases, the goal is to approximate the value of the attention function:

Attn⁡(K,V,q)=∑i=1ne⟨ki,q⟩/dvi∑i=1ne⟨ki,q⟩/d.(1)\operatorname{Attn}(K,V,q)=\frac{\sum_{i=1}^{n}e^{\langle k_i,q\rangle/\sqrt{d}}v_i}{\sum_{i=1}^{n}e^{\langle k_i,q\rangle/\sqrt{d}}}. \tag*{(1)}

where K=(k1,…,kn)⊂RdK=(k_1,\ldots,k_n)\subset\mathbb{R}^{d} is the set of all keys, V=(v1,…,vn)⊂RdV=(v_1,\ldots,v_n)\subset\mathbb{R}^{d} is the set of corresponding values and query q∈Rdq\in\mathbb{R}^{d} is the query.

We consider randomized algorithms for token eviction that are query-oblivious. That is, before seeing the specific query, the algorithm constructs a weighted summary by selecting a random subset of token indices I⊆[n]I\subseteq[n] together with positive weights wiw_i (and evicts the other tokens). Given a query qq, the algorithm returns

Attn⁡^(K,V,q)=∑i∈Iwie⟨ki,q⟩/dvi∑i∈Iwie⟨ki,q⟩/d.(2)\widehat{\operatorname{Attn}}(K,V,q)=\frac{\sum_{i\in I}w_i e^{\langle k_i,q\rangle/\sqrt{d}}v_i}{\sum_{i\in I}w_i e^{\langle k_i,q\rangle/\sqrt{d}}}. \tag*{(2)}

For every fixed query qq, we require

Pr⁡[∥Attn⁡(K,V,q)−Attn⁡(K,V,q)∥≤ε]≥23.(3)\Pr\left[\left\lVert\operatorname{Attn}(K,V,q)-\operatorname{Attn}(K,V,q)\right\rVert\le\varepsilon\right]\ge\frac{2}{3}. \tag*{(3)}

The probability is over the randomness used to construct the summary. The query is fixed independently of this randomness; we do not require simultaneous success for all queries. Assume that ∥ki∥≤rk\lVert k_i\rVert\le r_k for every ii and ∥q∥≤rq\lVert q\rVert\le r_q. We will assume ∥vi∥≤1\lVert v_i\rVert\le1.

Query-oblivious weighted token eviction (a.k.a. coresets) has been a subject of multiple recent theoretical investigations, leading to (almost) tight bounds on the worst case space complexity Haris & Onak [9]; Liberty et al. [13]; Chen et al. [4], see Table 2 for details. These results show that an erkrq/de^{r_k r_q/\sqrt{d}} dependence in the space bound is sufficient and necessary. While these results are close to optimal in the worst case, some of their implications significantly deviate from what one sees in practical instances:

ReferenceModel / regimeUpper boundLower bound
Kochetkova et al. [11]Coreset size (tokens)O~(de2R2)\widetilde{O}\left(\sqrt{d}e^{2R^{2}}\right)Ω~(1)\widetilde{\Omega}(1)
Haris & Onak [9]1Space complexity (bits)O~(nd)\widetilde{O}(nd)Ω(nd)\Omega(nd)
Liberty et al. [13]2Coreset size (tokens)O~(deR2+log⁡R+o(log⁡log⁡R))\widetilde{O}\left(\sqrt{d}e^{R^{2}+\log R+o(\log\log R)}\right)Ω~(deR2)\widetilde{\Omega}\left(\sqrt{d}e^{R^{2}}\right)
Chen et al. [4]3Space complexity (bits)O~(e(1+o(1))R2)\widetilde{O}\left(e^{(1+o(1))R^{2}}\right)Ω~(e(1−o(1))R2)\widetilde{\Omega}\left(e^{(1-o(1))R^{2}}\right)
This work4, b−a≤1+b2b-a\le\frac{1+b}{2}Coreset size (tokens)O~(e(b−a)R2)\widetilde{O}\left(e^{(b-a)R^{2}}\right)Ω~(e(b−a−o(1))R2)\widetilde{\Omega}\left(e^{(b-a-o(1))R^{2}}\right)
This work4, b−a>1+b2b-a>\frac{1+b}{2}Coreset size (tokens)O~(e1+b2R2)\widetilde{O}\left(e^{\frac{1+b}{2}R^{2}}\right)Ω~(e(1+b2−o(1))R2)\widetilde{\Omega}\left(e^{(\frac{1+b}{2}-o(1))R^{2}}\right)

Table 2. Worst-case space complexity of attention. O~\widetilde{O}, Ω~\widetilde{\Omega} suppress poly(ε−1log⁡n\varepsilon^{-1}\log n) factors.

  1. The space lower bound of erkrq/de^{r_k r_q/\sqrt{d}} can be much larger than the size of the input itself, given that the values of rk,rqr_k,r_q are often on the order of 15−2015-20 (see, for example, Table 3 in Kochetkova et al. [11] and our Figure 9) and d=128d=128; in such cases, the upper bound becomes vacuous.

  2. The hard distribution of the keys used to prove the lower bounds is isotropic, whereas in practice, keys and queries are known to be anisotropic, concentrating in a relatively narrow cone of the high-dimensional space Godey et al. [8].

  3. The worst case hard instances have the queries align perfectly (i.e., have a high dot product) with one of the keys; in contrast, in practice, the key-query cosine similarity is small in absolute value once the attention sink is excluded and stored separately (see e.g., Mazaré et al. [16] and our Figure 1).

Figure 1. Cosine similarities between the final 256 queries and preceding context keys in layer 8 of Qwen3-8B, for an 8K-token LongBench v2 input, excluding the first key (attention sink).

Figure 9. Key and query magnitudes across models. Layer 8 on the LongBench v2 input (8,192 tokens). Columns show Llama 3.1 8B, Qwen3 8B, Ministral 3 8B. The top row uses 7,935 keys per model: all eligible earlier-context keys. Blue baseline marks indicate the initial key (attention sink) norm in each model. The bottom row uses the final 256 queries.

Our results

Reflecting this discrepancy, we study the space complexity of attention approximation under the following assumption:

(⋆)(\star) Every key/query cosine similarity lies in some range [a,b][a,b], where the magnitudes ∣a∣,∣b∣≪1\lvert a\rvert,\lvert b\rvert\ll1, i.e., no query can align significantly with any key.

Before we state our main theorem, we need to introduce some notation. Fix radius parameters rk,rqr_k,r_q. Suppose ∥ki∥≤rk\lVert k_i\rVert\le r_k for every ii, and fix a pair of parameters a,b∈[−1,1]a,b\in[-1,1]. We take the admissible query set to be

Q:={q∈Rd: ∥q∥≤rq, a≤⟨ki,q⟩∥ki∥∥q∥≤b  ∀i∈[n]}.(4)Q:=\left\{q\in\mathbb{R}^d:\ \lVert q\rVert\le r_q,\ a\le\frac{\langle k_i,q\rangle}{\lVert k_i\rVert\lVert q\rVert}\le b\ \ \forall i\in[n]\right\}. \tag*{(4)}

Let OPTAttn\mathrm{OPT}_{\mathrm{Attn}} denote the optimal worst-case number of retained tokens subject to

Pr⁡[∥Attn⁡(K,V,q)−Attn⁡(K,V,q)∥≤ε]≥23\Pr\left[\left\lVert\operatorname{Attn}(K,V,q)-\operatorname{Attn}(K,V,q)\right\rVert\le\varepsilon\right]\ge\frac{2}{3}

for every fixed admissible qq. The algorithm knows keys, values, and parameters rk,rq,a,br_k,r_q,a,b, but not the particular query in QQ. All norms are Euclidean, and all logarithms are natural. We use O~\widetilde{O} to suppress factors polylogarithmic in nn.

Our main result shows that importance sampling is a nearly optimal token eviction policy for attention approximation. Surprisingly, for a wide range of parameters (see Figure 2) all importance weights can be set to 11, i.e. the most basic uniform sampling is optimal. Formally, we define two regions in the space of parameters (a,b)(a,b), see also Figure 2 for an illustration:

Uniform sampling and importance sampling regions in parameter space

Figure 2. Uniform sampling and importance sampling regions in parameter space.

Definition 1 (Uniform & importance sampling regimes). We say that fixed parameters −1≤a≤b≤1-1\le a\le b\le1 lie in the uniform sampling regime if a<0<ba<0<b and b−a≤1+b2b-a\le\frac{1+b}{2}.

We say that fixed parameters −1≤a≤b≤1-1\le a\le b\le1 lie in the importance sampling regime in any other case.

Our main result is as follows.

Theorem 2. Fix any constant ϵ∈(0,1/2]\epsilon\in(0,1/2] independently of nn, and assume d=ω(log⁡n)d = \omega(\log n). Fix parameters rk,rq>0r_k,r_q > 0 and −1≤a<b≤1-1 \le a < b \le1. Suppose ∥k∥≤rk\lVert k \rVert\le r_k for every key, and the admissible query set QQ is described as Equation (4). Let R2=rkrq/dR^2 = r_k r_q/\sqrt{d}, then

  1. In the uniform sampling regime, uniform sampling achieves asymptotically tight space bounds:

Ω(min⁡{n,e(b−a)R2}⋅e−o(R2))≤OPT⁡Attn≤O(min⁡{n,e(b−a)R2}).\Omega\left(\min\left\{n,e^{(b-a)R^2}\right\} \cdot e^{-o(R^2)}\right) \le\operatorname{OPT}_{\mathrm{Attn}} \le O\left(\min\left\{n,e^{(b-a)R^2}\right\}\right).
  1. In the importance sampling regime, importance sampling achieves asymptotically tight space bounds:

Ω(min⁡{n,e1+b2R2,e(b−a)R2}⋅e−o(R2))≤OPT⁡Attn≤O(min⁡{n,e1+b2R2,e(b−a)R2}).\Omega\left(\min\left\{n,e^{\frac{1+b}{2}R^2},e^{(b-a)R^2}\right\} \cdot e^{-o(R^2)}\right) \le\operatorname{OPT}_{\mathrm{Attn}} \le O\left(\min\left\{n,e^{\frac{1+b}{2}R^2},e^{(b-a)R^2}\right\}\right).

Theorem 2 is achieved by uniform sampling when the key/query cosine similarities are small (a<0<ba < 0 < b and b−a≤1+b2b-a \le\frac{1+b}{2}), and by an importance sampling scheme for larger cosine similarities. Interestingly, even though uniform sampling is by no means the best token eviction policy, it is quite competitive with some earlier works on token eviction for KV cache compression, especially query-independent ones. See, for example, Table 1 in Kochetkova et al. [11] for a comparison of SnapKV and BalanceKV with uniform sampling. The recent work of Wang et al. [18] provides more evidence for this phenomenon. Figure 2 helps explain this from the perspective of theory: the empirical (a,b)(a,b) values for widely used models lie in or close to the uniform sampling regime.

ModelLayer 4Layer 8Layer 16Layer 24
Llama 3.1 8B−0.584±0.148-0.584 \pm0.148−0.725±0.098-0.725 \pm0.098−0.681±0.076-0.681 \pm0.076−0.688±0.105-0.688 \pm0.105
Qwen3 8B0.068±0.0370.068 \pm0.037−0.146±0.034-0.146 \pm0.0340.024±0.0440.024 \pm0.044−0.143±0.080-0.143 \pm0.080
Ministral 3 8B−0.724±0.047-0.724 \pm0.047−0.628±0.086-0.628 \pm0.086−0.613±0.078-0.613 \pm0.078−0.658±0.045-0.658 \pm0.045

Table 1. Cosine similarity between mean query and key vectors. Values are means ±\pm standard deviations across example/context-length configurations common to all models and layers.

In addition to the theorem statement, the proof of the theorem provides insights into another empirical phenomenon. Specifically, the anisotropy of the key/query space that has been empirically observed in the literature Godey et al. [8] appears naturally in our lower bound instance. In our hard input distribution on key and query vectors, the keys and queries are similarly distributed except that the keys are positively shifted along a specific direction e0e_0 while the queries are negatively shifted along e0e_0. This construction, which is critical to establishing a matching space lower bound, is indeed anisotropic: the keys have a large positive projection on a common direction, and the queries have a large negative projection on the same direction, similarly to distributions observed in practice (Table 1, Figure 5). See § 2.2 for more details.

Figure 5. Query-key geometry in Llama 3.1 8B on LongBench v2 example (8K context, layer 8, head 0). A joint PCA is fitted with equal total weight for queries and keys. Initial-token (attention sink) is excluded. See Section F.1 for further plots.

Related work

Related work on worst-case space complexity of attention approximation. Prior work (Haris & Onak, [9]; Liberty et al., [13]; Chen et al., [4]) has established nearly tight asymptotic bounds on the space complexity of approximating attention in the worst case. The algorithmic landscape is diverse, with approaches drawing on sketching, random sampling, discrepancy theory, and kernel-density estimation. Provable attention approximation has also led to implemented KV cache compression methods. SubGen (Zandieh et al., [20]) combines online key clustering with ℓ2\ell_2 sampling of values to obtain approximation guarantees that exploit clustering structure, and evaluates its implementation on long-context question-answering tasks. BalanceKV Kochetkova et al. [11] develops a streaming compression algorithm based on geometric discrepancy and vector balancing, with both theoretical guarantees and empirical evaluations of attention approximation and end-to-end generation on long-context benchmarks. A comparison is given in Table 2. We note that the worst case setting is crucially different from our setup in that queries can be arbitrarily well aligned with key.

Related work on KV cache compression. We mention the lines of the most relevant work.

KV subset selection. A prominent approach to KV-cache compression retains a subset of the original key-value pairs. H2_2O combines accumulated-attention heavy hitters with recent tokens Zhang et al. [22], while Scissorhands uses token importance that persists across decoding steps Liu et al. [14]. StreamingLLM keeps initial attention sinks and a sliding window of recent tokens Xiao et al. [19]. SnapKV selects KV positions per head before generation using a window at the prompt’s end Li et al. [12]. PyramidKV splits a fixed cache budget across layers Cai et al. [2], while Ada-KV splits it across heads using an attention-output error bound Feng et al. [7]. These approaches exploit historical attention, prompt observations, or layer/head structure, rather than establishing optimal retained-token complexity under an explicit restriction on future key-query similarities.

Compressed KV representations. Another line of work reduces storage per cached vector. KIVI quantizes keys per channel and values per token Liu et al. [15]. KVQuant combines distribution-aware quantization, pre-RoPE key quantization, and separate outlier handling Hooper et al. [10]. TurboQuant uses random rotations for data-oblivious vector quantization, with guarantees on mean-squared and inner-product distortion Zandieh et al. [21]. Palu caches low-dimensional intermediate representations from low-rank factorizations of key/value projections Chang et al. [3]. Cartridges learns context representations through self-study Eyuboglu et al. [6]. These representations fall outside our weighted-subset model, so our retained-token lower bounds do not apply to arbitrary quantized or low-rank encodings.

Random KV eviction. Wang et al. [18] propose a method that reserves cache space for the input prompt and the most recent tokens, then fills the remaining slots by uniform random sampling, independently across KV heads at each eviction event. Their method is competitive with importance-based policies on reasoning benchmarks, providing further evidence that random sampling can be effective in practice.

Uniform sampling regime

Upper Bound

The upper bound in the small cosine similarities regime is shown by a simple approach: sampling tokens uniformly.

Consider the small cosine similarities regime of Theorem 1, where −1≤a<0<b≤1-1 \le a < 0 < b \le1 and b−a≤1+b2b-a \le\frac{1+b}{2}. Our assumptions are ∥ki∥≤rk\lVert k_i\rVert\le r_k, ∥q∥≤rq\lVert q\rVert\le r_q, and

a≤⟨ki,q⟩∥ki∥∥q∥≤b.a \le\frac{\langle k_i,q\rangle}{\lVert k_i\rVert\lVert q\rVert} \le b.

We write R2=rkrq/dR^2 = r_k r_q/\sqrt{d}. Set m=⌈96e(b−a)R2ε2⌉m = \left\lceil\frac{96e^{(b-a)R^2}}{\varepsilon^2} \right\rceil. If m≥nm \ge n, retain the full dataset. Otherwise, sample mm tokens independently and uniformly with replacement. Writing J1,…,JmJ_1,\ldots,J_m for their

Empirical bounds $a$ and $b$ for 8B models Llama 3.1, Qwen3, and Ministral 3

Figure 3. Empirical bounds aa and bb for 8B models Llama 3.1, Qwen3, and Ministral 3. Each point represents one context (from LongBench v2/InfiniteBench/SCBench)–context-length (8/32/128/256 k)–layer (4/8/16/24) configuration, with endpoints aa and bb computed as 0.001 and 0.999 quantiles of cosine similarities distribution. Initial-token (attention sink) is excluded. See Section F.1 for more plots.

Figure 6. Query–key cosine similarities across models and attention layers. Rows show Llama 3.1 8B, Qwen3 8B, Ministral 3 8B; columns show layers 4, 8, 16, 24. All panels use the same prepared LongBench v2 example. Each panel uses an input of 8,192 tokens and compares the final 256 queries from query head 0 against 7,935 earlier-context keys from the corresponding KV head 0. The initial key is excluded. Cosines are computed after model normalization and RoPE.

indices, return the estimate

Attn⁡^(K,V,q)=∑ℓ=1me⟨kJℓ,q⟩/dvJℓ∑ℓ=1me⟨kJℓ,q⟩/d.\widehat{\operatorname{Attn}}(K,V,q)=\frac{\sum_{\ell=1}^{m}e^{\langle k_{J_\ell},q\rangle/\sqrt{d}}v_{J_\ell}}{\sum_{\ell=1}^{m}e^{\langle k_{J_\ell},q\rangle/\sqrt{d}}}.

The intuition behind uniform sampling is that no individual token can account for too large a fraction of the attention mass. Indeed, for every ii and every admissible query qq,

e⟨ki,q⟩/d∈[eaR2,ebR2].(5)e^{\langle k_i,q\rangle/\sqrt{d}}\in\left[e^{aR^{2}},e^{bR^{2}}\right]. \tag*{(5)}

Thus, the attention denominator is at least neaR2ne^{aR^{2}}, whereas the contribution of any individual token is at most ebR2e^{bR^{2}}. Consequently, each token accounts for at most an e(b−a)R2/ne^{(b-a)R^{2}}/n fraction of the attention mass.

Lemma 1 (Upper bound, Item 1). The uniform sampling procedure described above retains at most

Oε(min⁡{n,e(b−a)R2})O_{\varepsilon}\left(\min\left\{n,e^{(b-a)R^{2}}\right\}\right)

tokens and gives an additive-ε\varepsilon approximation to attention with probability at least 2/3 for each fixed admissible query.

We defer the full proof of Lemma 1 to Section B. We use Chebyshev’s inequality to bound the attention denominator, and use Markov’s inequality to bound the numerator of the error.

Lower Bound

Recall that in our model (2), the token-eviction algorithm (randomly) selects tokens and assigns them nonnegative weights before seeing the query. We will prove lower bounds against such algorithms.

Theorem 3 (Lower bound, Item 1). Consider rk,rq>0r_k,r_q>0, ε∈(0,1/2]\varepsilon\in(0,1/2], and −1≤a<b≤1-1\le a<b\le1 in the uniform sampling regime (Theorem 1). Consider nn and d=ω(log⁡n)d=\omega(\log n), and let ξ=6log⁡(2n)d−3=o(1)\xi=\sqrt{\frac{6\log(2n)}{d-3}}=o(1). Pick any integer mm satisfying

2≤m≤n,m≤e(b−a)R2e−2ξR2/32.(6)2\le m\le n,\qquad m\le e^{(b-a)R^{2}}e^{-2\xi R^{2}}/32. \tag*{(6)}

There is a fixed dataset (K,V)(K,V) of nn key-value pairs, with keys of norm rkr_k and unit-norm values in Rd\mathbb{R}^{d}, together with queries q1,…,qmq_1,\ldots,q_m of norm rqr_q, such that every key k∈Kk\in K satisfies

a≤⟨k,qi⟩∥k∥∥q∥≤bfor all i∈[m].a\le\frac{\langle k,q_i\rangle}{\lVert k\rVert\lVert q\rVert}\le b\qquad\text{for all }i\in[m].

For this dataset, satisfying Equation (3) at each of these queries requires OPT⁡Attn≥2m/3\operatorname{OPT}_{\mathrm{Attn}}\ge2m/3.

Our lower bound constructs mm groups of identical key-value pairs, each paired with a different query. A visualization of the construction is given in Figure 4. For each group, we build the key and corresponding query from a set of nearly orthogonal vectors u1,…,umu_1,\ldots,u_m (Lemma 2):

Figure 4. A visualization of the hard instance in our lower bound construction. The keys and queries are shifted away from each other along direction e0e_0. Orthogonal to e0e_0, each key-query pair (ki,qi)(k_i, q_i) follows its own common direction uiu_i.

Lemma 2 (Nearly orthogonal vectors). Consider integer M≥2M \ge2 and ξ∈(0,1)\xi\in(0,1). Let DD be an integer such that D≥6log⁡(2M)/ξ2D \ge6\log(2M)/\xi^2. There exist MM unit vectors u1,…,uM∈RDu_1,\ldots,u_M \in\mathbb{R}^{D} such that ∣⟨ui,uj⟩∣≤ξ\lvert\langle u_i,u_j\rangle\rvert\le\xi for every i≠ji \ne j.

To see this, choose u1,…,uMu_1,\ldots,u_M independently and uniformly from {−D−1/2,D−1/2}D\{-D^{-1/2},D^{-1/2}\}^{D}, so that each vector has unit norm. Hoeffding’s inequality and a union bound show that the probability of any pair satisfying ∣⟨ui,uj⟩∣>ξ\lvert\langle u_i,u_j\rangle\rvert> \xi is at most M2e−Dξ2/2<1M^2e^{-D\xi^2/2} < 1 under the assumed bound on DD. We give the full proof in Section C.

In order to keep all key-query cosine similarities in [a,b][a,b], queries and keys are anisotropically shifted away from each other along a fixed direction e0e_0. A pair of keys and queries in the same group ki,qik_i,q_i are (a weighted version of) ui±e0u_i \pm e_0 where the sign on e0e_0 differs for the key and query (along with a normalization term to set their respective norms to rk,rqr_k,r_q).

Each query qiq_i has similarity bb with its own group’s key kik_i, while the near orthogonality caps its similarity close to aa with the other groups’ keys kjk_j. The exponential in attention amplifies this gap, giving the query’s own group almost all the attention mass. We also choose nearly orthogonal value vectors, so a convex combination of other groups’ value vectors cannot well-approximate attention. The algorithm must therefore retain a key-value pair from each group with constant probability, otherwise it would fail with probability more than 1/31/3 on some group’s query.

The resulting construction holds an intriguing connection to patterns in real data. In Figure 5, we see that queries and keys are separated along a common direction and otherwise hold a somewhat similar distribution though with different scales for queries and keys. These qualities also appear in our hard instance (Figure 4).

Lower bound construction

Goal. We construct keys and queries whose scaled inner products are bR2bR^2 for matching pairs (ki,qi)(k_i,q_i) and a(1−o(1))R2a(1-o(1))R^2 for nonmatching pairs (kj,qi)(k_j,q_i), where R2=rkrq/dR^2=r_kr_q/\sqrt{d}. In Section C.1, we use this gap to make each query concentrate its attention on copies of its matching key, forcing an accurate summary to retain many key groups.

Construction. Let e0,eK,eQe_0,e_K,e_Q be the first three standard basis vectors. Choose mm unit vectors satisfying Lemma 2 in dimension D=d−3D=d-3, with pairwise inner products bounded in magnitude by ξ=6log⁡(2n)D\xi=\sqrt{\frac{6\log(2n)}{D}}. Embed them into the last d−3d-3 coordinates of Rd\mathbb{R}^d, and denote the resulting vectors by u1,…,umu_1,\ldots,u_m. Define

ki=rk(αui+βe0+1−α−βeK),qi=rq(αui−βe0+1−α−βeQ).(7)\begin{aligned} k_i &= r_k\left(\sqrt{\alpha}u_i+\sqrt{\beta}e_0+\sqrt{1-\alpha-\beta}e_K\right),\\ q_i &= r_q\left(\sqrt{\alpha}u_i-\sqrt{\beta}e_0+\sqrt{1-\alpha-\beta}e_Q\right). \tag*{(7)} \end{aligned}

where α≈b−a\alpha\approx b-a and β≈−a\beta\approx-a. Specifically, we set

α=b−a1+ξ,β=−a−ξb1+ξ.(8)\alpha=\frac{b-a}{1+\xi},\qquad\beta=\frac{-a-\xi b}{1+\xi}. \tag*{(8)}

We have α≥0\alpha\ge0 since b≥ab\ge a. Since a<0a<0 and bb are fixed and ξ=o(1)\xi=o(1), for sufficiently large nn we have ξb<−a\xi b<-a, so β>0\beta>0. Moreover, α+β=2α−b≤b−2a≤1\alpha+\beta=2\alpha-b\le b-2a\le1. Therefore, 1−α−β≥01-\alpha-\beta\ge0 and the keys and queries are well defined with norms exactly equal to ∥ki∥=rk\lVert k_i\rVert=r_k and ∥qi∥=rq\lVert q_i\rVert=r_q. The components along uiu_i and e0e_0 serve the purpose of achieving the desired inner products while the padding along eKe_K and eQe_Q increases the norms of the keys/queries to fix the denominator of cosine similarity.

Verifying the inner products. For every i,j∈[m]i,j\in[m], ⟨kj,qi⟩d=(α⟨uj,ui⟩−β)R2\frac{\langle k_j,q_i\rangle}{\sqrt d}=(\alpha\langle u_j,u_i\rangle-\beta)R^2. For matching pairs, α−β=b\alpha-\beta=b gives

⟨ki,qi⟩d=bR2.(9)\frac{\langle k_i,q_i\rangle}{\sqrt d}=bR^2. \tag*{(9)}

For nonmatching pairs, ∣⟨uj,ui⟩∣≤ξ\lvert\langle u_j,u_i\rangle\rvert\le\xi gives

aR2≤⟨kj,qi⟩d≤(a+2αξ)R2=aR2+2ξ1+ξ(b−a)R2.(10)aR^2\le\frac{\langle k_j,q_i\rangle}{\sqrt d}\le(a+2\alpha\xi)R^2=aR^2+\frac{2\xi}{1+\xi}(b-a)R^2. \tag*{(10)}

Constructing the value vectors. Apply Lemma 2 a second time to obtain mm unit value vectors v1,…,vm∈Rdv_1,\ldots,v_m\in\mathbb{R}^d satisfying

∣⟨vi,vj⟩∣≤18for all i,j∈[m] with i≠j.(11)\lvert\langle v_i,v_j\rangle\rvert\le\frac{1}{8}\qquad\text{for all }i,j\in[m]\text{ with }i\ne j. \tag*{(11)}

Since m≤nm\le n, the assumption d=ω(log⁡n)d=\omega(\log n) ensures that this is possible. The final proof of the coreset size lower bound using these key, query and value vectors is given in Section C.

Importance sampling regime

Upper Bound

When the interval [a,b][a,b] is wide, the exponential in attention can make a few tokens much more influential than the rest. To account for this, uniform sampling would need to retain many tokens. We thus use importance sampling instead. Unlike uniform sampling, which treats all tokens equally, importance sampling gives higher sampling probabilities to tokens that can contribute more to attention. This is a standard idea in randomized linear algebra through leverage-score sampling Drineas et al. [5] and in coreset construction through sensitivity sampling Braverman et al. [1].

Since we sample before seeing the query, we want to sample a token with probability proportional to the largest possible attention it could receive. This quantity is its sensitivity: for a nonempty query set QQ containing all admissible queries, define

σi=sup⁡q∈Qe⟨ki,q⟩/d∑j=1ne⟨kj,q⟩/d.(12)\sigma_i=\sup_{q\in Q}\frac{e^{\langle k_i,q\rangle/\sqrt d}}{\sum_{j=1}^{n}e^{\langle k_j,q\rangle/\sqrt d}}. \tag*{(12)}

Unfortunately, these sensitivities may be difficult to compute exactly. Instead, it suffices to use sampling scores si≥σis_i\ge\sigma_i, i.e., upper bounds of each sensitivities. In the sampling procedure, we sample each token ii with probability πi=si/S\pi_i=s_i/S, where S=∑i=1nsiS=\sum_{i=1}^{n}s_i. We set the number of samples proportional to SS, so smaller sampling scores yield a smaller sample size. This leaves two tasks: compute valid sampling scores si≥σis_i \ge\sigma_i and show that their sum SS is small.

We formalize the sampling procedure in Algorithm 1. For each sampled token ii, we retain the corresponding key-value pair (ki,vi)(k_i,v_i) together with a positive weight. If we sample the same token more than once, we keep one copy and add the weights together.

Algorithm 1 Attention compression by score-based sampling and reweighting

Require: key-value pairs $(k_1,v_1),\ldots,(k_n,v_n)$, accuracy $0 < \varepsilon < 1$, and sampling scores $s_1,\ldots,s_n > 0$

1: $S \leftarrow \sum_{i=1}^{n} s_i,\quad m \leftarrow \lceil 96S/\varepsilon^2\rceil$
2: if $m \ge n$ then
3:   return $\{(k_i,v_i,1):i\in[n]\}$
4: end if
5: $\pi_i \leftarrow s_i/S$ for every $i\in[n]$
6: Subsample $m$ tokens using probabilities $\pi_i$ ▷ with replacement
7: $c_i \leftarrow$ number of times token $i$ was sampled
8: return $\{(k_i,v_i,c_i/(m\pi_i)):c_i>0\}$ ▷ one copy per token

We refer to the set returned by Algorithm 1 as the summary. Given a query qq, the summary produces an estimator

Attn⁡^(K,V,q)=∑i∈Iwie⟨ki,q⟩/dvi∑i∈Iwie⟨ki,q⟩/d,(13)\widehat{\operatorname{Attn}}(K,V,q)=\frac{\sum_{i\in I}w_i e^{\langle k_i,q\rangle/\sqrt{d}}v_i}{\sum_{i\in I}w_i e^{\langle k_i,q\rangle/\sqrt{d}}}, \tag*{(13)}

where I:={i:ci>0}I:=\{i:c_i>0\} denotes the set of retained token indices. The denominator is positive, since the summary is nonempty and all retained weights are positive.

We first state the approximation guarantee of Algorithm 1. Using a number of tokens proportional to SS, the estimator from Equation (13) approximates the attention with high probability.

Lemma 3 (Approximation guarantee). Suppose ∥vi∥≤1\lVert v_i\rVert\le1 and si≥σis_i\ge\sigma_i for every i∈[n]i\in[n]. Then Algorithm 1 returns a weighted attention summary of size at most

min⁡{n,⌈96Sε2⌉}.\min\left\{n,\left\lceil\frac{96S}{\varepsilon^2}\right\rceil\right\}.

For every fixed query q∈Qq\in Q, its estimate satisfies

Pr⁡[∥Attn⁡^(K,V,q)−Attn⁡(K,V,q)∥≤ε]≥23,\Pr\left[\left\lVert\widehat{\operatorname{Attn}}(K,V,q)-\operatorname{Attn}(K,V,q)\right\rVert\le\varepsilon\right]\ge\frac{2}{3},

where the probability is over the sampling in Algorithm 1.

We defer the full proof of Lemma 3 to Section D. Similar to the proof of Lemma 1, we use Chebyshev’s inequality to bound the attention denominator, and use Markov’s inequality to bound the numerator of the error.

Lemma 3 reduces the problem to constructing sampling scores sis_i whose sum SS is small. To this end, we first bound the total sensitivity ∑i=1nσi\sum_{i=1}^{n}\sigma_i of any query set for which all key-query inner products lie in a fixed interval. This condition is satisfied by our query set QQ. However, QQ need not be convex, making it difficult to compute sampling scores. We therefore partition the keys and possible query norms into small ranges and, for each pair of ranges, replace the cosine-similarity constraints by fixed inner-product bounds. This partitions the problem into a collection of smaller convex relaxations on which we can approximate the sensitivities. Applying the total-sensitivity bound to these relaxations allows us to control the sum SS. These two steps are formalized in Lemmas 4 and 5.

Lemma 4 (Total sensitivity bound). Suppose rk,rq>0r_k,r_q>0 and ∥ki∥≤rk\lVert k_i\rVert\le r_k for every ii, and let QQ be a nonempty compact query set such that

Q:={q∈Rd:∥q∥≤rq, ℓ≤⟨ki,q⟩d≤h  ∀i∈[n]}.Q:=\left\{q\in\mathbb{R}^{d}:\lVert q\rVert\le r_q,\ \ell\le\frac{\langle k_i,q\rangle}{\sqrt{d}}\le h\ \ \forall i\in[n]\right\}.

For sensitivities σi\sigma_i defined in Equation (12) with the supremum taken over q∈Qq\in Q, we have

∑i=1nσi≤exp⁡(min⁡{h−ℓ,R2+h2}).(14)\sum_{i=1}^{n}\sigma_i\le\exp\left(\min\left\{h-\ell,\frac{R^2+h}{2}\right\}\right). \tag*{(14)}

At a high level, the two terms in Equation (14) come from two different ways of controlling the total sensitivity. The first term h−ℓh-\ell follows from the fact that σi≤ehneℓ\sigma_i \le\frac{e^h}{ne^\ell}. For the second term, we pair each key kik_i with a query qiq_i attaining its sensitivity and assign weights to these pairs proportionally to their sensitivities. Writing kˉ,qˉ\bar{k},\bar{q} for the weighted mean key and query, using Jensen’s inequality, the proof gives

log⁡∑iσi≤h−⟨kˉ,qˉ⟩d,log⁡∑iσi≤R2+⟨kˉ,qˉ⟩d.\log\sum_i \sigma_i \le h-\frac{\langle\bar{k},\bar{q}\rangle}{\sqrt{d}}, \qquad\log\sum_i \sigma_i \le R^2+\frac{\langle\bar{k},\bar{q}\rangle}{\sqrt{d}}.

Averaging these two bounds yields log⁡∑iσi≤(R2+h)/2\log\sum_i \sigma_i \le(R^2+h)/2. The full proof is deferred to Section D.

It remains to construct the sampling scores.

Lemma 5 (Computing sampling scores). Let −1≤a<b≤1-1 \le a < b \le1 and rk,rq>0r_k,r_q > 0, and write R2=rkrqdR^2=\frac{r_k r_q}{\sqrt{d}}, κ=min⁡{b−a,1+b2}\kappa=\min\left\{b-a,\frac{1+b}{2}\right\}. Suppose ∥ki∥≤rk\lVert k_i\rVert\le r_k for every i∈[n]i \in[n], and

Q:={q∈Rd:∥q∥≤rq,a∥ki∥∥q∥≤⟨ki,q⟩≤b∥ki∥∥q∥∀i∈[n]}.Q := \left\{q \in\mathbb{R}^d : \lVert q\rVert\le r_q,\quad a\lVert k_i\rVert\lVert q\rVert\le\langle k_i,q\rangle\le b\lVert k_i\rVert\lVert q\rVert\quad\forall i \in[n]\right\}.

For sensitivities σi\sigma_i defined in Equation (12) with the supremum taken over q∈Qq \in Q, we can compute sampling scores sis_i satisfying si≥σis_i \ge\sigma_i for every i∈[n]i \in[n], and

∑i=1nsi≤128e2κ2eκR2.\sum_{i=1}^{n} s_i \le\frac{128e^2}{\kappa^2}e^{\kappa R^2}.

Moreover, such sampling scores can be obtained by solving n⋅max⁡{1,⌈R2⌉}n\cdot\max\{1,\lceil R^2\rceil\} convex optimization problems, using only the keys and the parameters rk,rq,a,br_k,r_q,a,b.

The full proof is deferred to Section D.

We now combine the approximation guarantee (Lemma 3) with the sampling score bound (Lemmas 4 and 5) to prove the upper bound in the importance sampling regime.

Corollary 1 (Upper bound, Item 2). Under the assumptions of Lemma 5, fix a,ba,b independently of nn, suppose ∥vi∥≤1\lVert v_i\rVert\le1 for every i∈[n]i \in[n], and let 0<ε<10 < \varepsilon< 1. Then Algorithm 1, with the scores constructed there, retains at most

Oε(min⁡{n,e(b−a)R2,e1+b2R2})O_\varepsilon\left(\min\left\{n,e^{(b-a)R^2},e^{\frac{1+b}{2}R^2}\right\}\right)

tokens and gives an additive-ε\varepsilon approximation to attention with probability at least 2/32/3 for each fixed admissible query.

Proof. By Lemma 5, the sampling scores satisfy si≥σis_i \ge\sigma_i and S≤128e2κ−2eκR2S \le128e^2\kappa^{-2}e^{\kappa R^2}, where κ=min⁡{b−a,(1+b)/2}\kappa=\min\{b-a,(1+b)/2\}. Since a,ba,b are fixed, κ−2\kappa^{-2} is a constant. Substituting into Lemma 3 and absorbing κ−2\kappa^{-2} into the implicit constant proves the upper bound.

Lower bound

The lower bound in the importance sampling regime uses the same construction and analysis as in the uniform sampling regime (§ 2.2). The only change in the theorem statement is that mm must satisfy

2≤m≤n,m≤min⁡{e1+b2R2,e(b−a)R2}⋅e−2ξR2/32.2 \le m \le n,\qquad m \le\min\left\{e^{\frac{1+b}{2}R^2},e^{(b-a)R^2}\right\}\cdot e^{-2\xi R^2}/32.

The full statement (Theorem 4) and proof are given in Section E.

Open Problems

The following questions naturally arise from our work:

  • Can we provably explain why transformers learn this geometry? In particular, under what assumptions on the data and training dynamics can we prove that small key–query cosine similarities and negative alignment between mean keys and queries emerge?

  • Do real KV caches have other structure that our model misses? Our hard instances share some geometric features with trained models, but real caches may have additional properties that make them easier to compress?

ACKNOWLEDGMENTS

JC,YF, PI, were supported in part by the NSF TRIPODS program (award DMS-2022448) and Wistron Corporation. Ekaterina Kochetkova and Boris Prokhorov were supported by the Swiss National Science Foundation grant 10004935 - Sublinear Algorithms for Non-linear Structures (Project MINT)

AI USE STATEMENT

In this work, we used generative AI tools to provide critical ingredients for proving mathematical claims in the importance sampling regime, assist in the writing of proofs, propose or refine hypotheses and implement methods.

We have not used generative AI tools to help formulate mathematical claims, develop theoretical models or conceptual frameworks, design or provide feedback on research methodology or experiments, interpret results, support qualitative and thematic data analysis. Generating synthetic data sets, cleaning and reformatting datasets and assisting with translation are not applicable to this work.

Additionally, we used generative AI tools for creating scientific figures, suggesting experimental parameters, creating software code, drafting parts of the paper, sourcing/searching for information, editing to improve readability, proposing a title for the paper.

We have reviewed all AI-assisted work. We checked LLM-generated parts of the proof and rewrote it ourselves. We take responsibility for the final content of this work, including text, claims or artifacts produced with the aid of generative AI.

Preliminaries

Standard Inequalities and Identities

We record several standard inequalities and identities used in the proofs.

Lemma 6 (Markov’s inequality). Let XX be a nonnegative random variable. Then, for every t>0t > 0,

Pr⁡[X≥t]≤E[X]t.\Pr[X \ge t] \le\frac{\mathbb{E}[X]}{t}.

In particular, for any random vector XX with finite second moment,

Pr⁡[∥X∥≥t]≤E∥X∥2t2.\Pr[\lVert X\rVert\ge t] \le\frac{\mathbb{E}\lVert X\rVert^2}{t^2}.

Lemma 7 (Chebyshev’s inequality). Let XX be a real-valued random variable with finite variance. Then, for every t>0t > 0,

Pr⁡[∣X−EX∣≥t]≤Var⁡(X)t2.\Pr[|X-\mathbb{E}X| \ge t] \le\frac{\operatorname{Var}(X)}{t^2}.

Lemma 8 (Hoeffding’s inequality). Let X1,…,XnX_1,\ldots,X_n be independent random variables such that Xi∈[a,b]X_i \in[a,b] for every ii. Define

Xˉ:=1n∑i=1nXi.\bar{X} := \frac{1}{n}\sum_{i=1}^{n} X_i.

Then, for every ε>0\varepsilon> 0,

Pr⁡(∣Xˉ−E[Xˉ]∣≥ε)≤2exp⁡(−2nε2(b−a)2).\Pr\left(|\bar{X}-\mathbb{E}[\bar{X}]| \ge\varepsilon\right) \le2\exp\left(-\frac{2n\varepsilon^2}{(b-a)^2}\right).

Lemma 9 (Jensen’s inequality). Let λ1,…,λn>0\lambda_1,\ldots,\lambda_n > 0 satisfy ∑i=1nλi=1\sum_{i=1}^{n}\lambda_i = 1, and let x1,…,xn>0x_1,\ldots,x_n > 0. Then

log⁡(∑i=1nxi)=log⁡(∑i=1nλixiλi)≥∑i=1nλilog⁡(xiλi).\log\left(\sum_{i=1}^{n}x_i\right) = \log\left(\sum_{i=1}^{n}\lambda_i\frac{x_i}{\lambda_i}\right) \ge\sum_{i=1}^{n}\lambda_i\log\left(\frac{x_i}{\lambda_i}\right).

Lemma 10 (Cauchy-Schwarz inequality). Let λ1,…,λn≥0\lambda_1,\ldots,\lambda_n \ge0, and let x1,…,xnx_1,\ldots,x_n and y1,…,yny_1,\ldots,y_n be vectors in a Euclidean space. Then

∣∑i=1nλi⟨xi,yi⟩∣≤(∑i=1nλi∥xi∥2)1/2(∑i=1nλi∥yi∥2)1/2.\left|\sum_{i=1}^{n}\lambda_i\langle x_i,y_i\rangle\right| \le\left(\sum_{i=1}^{n}\lambda_i\lVert x_i\rVert^2\right)^{1/2}\left(\sum_{i=1}^{n}\lambda_i\lVert y_i\rVert^2\right)^{1/2}.

Lemma 11 (Arithmetic-geometric mean inequality). For every x,y≥0x,y \ge0,

xy≤x+y2.\sqrt{xy} \le\frac{x+y}{2}.

Lemma 12 (Weighted centering). Let w1,…,wn≥0w_1,\ldots,w_n \ge0 and let x1,…,xnx_1,\ldots,x_n be vectors in a Euclidean space. Let

W=∑i=1nwi>0,xˉ=1W∑i=1nwixi.W=\sum_{i=1}^{n}w_i>0,\qquad\bar{x}=\frac{1}{W}\sum_{i=1}^{n}w_i x_i.

Then

∑i=1nwi∥xi−xˉ∥2=∑i=1nwi∥xi∥2−W∥xˉ∥2.\sum_{i=1}^{n}w_i\lVert x_i-\bar{x}\rVert^2=\sum_{i=1}^{n}w_i\lVert x_i\rVert^2-W\lVert\bar{x}\rVert^2.

In particular, if ∑iwi=1\sum_i w_i=1, then

∑i=1nwi∥xi−xˉ∥2=∑i=1nwi∥xi∥2−∥xˉ∥2.\sum_{i=1}^{n}w_i\lVert x_i-\bar{x}\rVert^2=\sum_{i=1}^{n}w_i\lVert x_i\rVert^2-\lVert\bar{x}\rVert^2.

Convex Optimization

We record the convex optimization facts used to compute the sampling scores. The optimization guarantee below is stated in the oracle model.

Lemma 13. Let u1,…,uN∈Rdu_1,\ldots,u_N \in\mathbb{R}^d and c1,…,cN∈Rc_1,\ldots,c_N \in\mathbb{R}. The function

f(x)=log⁡(∑j=1Ne⟨uj,x⟩+cj)f(x) = \log\left(\sum_{j=1}^{N} e^{\langle u_j,x\rangle+c_j}\right)

is convex and continuously differentiable, with

∇f(x)=∑j=1Ne⟨uj,x⟩+cjuj∑j=1Ne⟨uj,x⟩+cj.\nabla f(x) = \frac{\sum_{j=1}^{N}e^{\langle u_j,x\rangle+c_j}u_j}{\sum_{j=1}^{N}e^{\langle u_j,x\rangle+c_j}}.

The convexity statement follows from convexity of log-sum-exp and composition with an affine map; see Vandenberghe & Boyd [17]. The gradient formula follows by differentiation.

Lemma 14. A set defined by finitely many affine inequalities and constraints of the form

∥Ax+c∥≤⟨u,x⟩+β\lVert Ax+c\rVert\le\langle u,x\rangle+\beta

is closed and convex. If it is bounded, it is compact.

Proof. The function x↦∥Ax+c∥−⟨u,x⟩−βx\mapsto\lVert Ax+c\rVert-\langle u,x\rangle-\beta is continuous and convex. Thus its non-positive sublevel set is closed and convex, and these properties are preserved by intersection. Compactness follows from closedness and boundedness.

Lemma 15 (Additive-accuracy convex minimization). Let C⊆RdC\subseteq\mathbb{R}^d be a nonempty compact convex set, and let f:C→Rf:C\to\mathbb{R} be continuous and convex. Then, for every η>0\eta>0, the convex optimization problem

min⁡x∈Cf(x)\min_{x\in C} f(x)

admits an additive-η\eta solution; that is, there exists x^∈C\hat{x}\in C satisfying

min⁡x∈Cf(x)≤f(x^)≤min⁡x∈Cf(x)+η.\min_{x\in C}f(x)\le f(\hat{x})\le\min_{x\in C}f(x)+\eta.

Proof. Since CC is compact and ff is continuous, ff attains its minimum on CC. An exact minimizer is, in particular, an additive-η\eta solution.

Proofs from sec:upper-uniform

Lemma 1 (Upper bound, Item 1). The uniform sampling procedure described above retains at most

Oε(min⁡{n,e(b−a)R2})O_{\varepsilon}\left(\min\left\{n,e^{(b-a)R^2}\right\}\right)

tokens and gives an additive-ε\varepsilon approximation to attention with probability at least 2/32/3 for each fixed admissible query.

Proof. If the algorithm retains all tokens, the estimate is exact. Otherwise, fix an admissible query qq, we write the true average and the empirical average of kernels as

D=1n∑iexp⁡(⟨ki,q⟩d)andD^=1m∑ℓ=1mexp⁡(⟨kJℓ,q⟩d).D=\frac{1}{n}\sum_i\exp\left(\frac{\langle k_i,q\rangle}{\sqrt{d}}\right) \qquad\text{and}\qquad \widehat{D}=\frac{1}{m}\sum_{\ell=1}^{m}\exp\left(\frac{\langle k_{J_\ell},q\rangle}{\sqrt{d}}\right).

We will show that

Pr⁡[∥Attn⁡^(K,V,q)−Attn⁡(K,V,q)∥≤ε]≥23,\Pr\left[\left\lVert\widehat{\operatorname{Attn}}(K,V,q)-\operatorname{Attn}(K,V,q)\right\rVert\le\varepsilon\right]\ge\frac{2}{3},

where

Attn⁡^(K,V,q):=∑ℓ=1me⟨kJℓ,q⟩/dvJℓ∑ℓ=1me⟨kJℓ,q⟩/d.\widehat{\operatorname{Attn}}(K,V,q):=\frac{\sum_{\ell=1}^{m}e^{\langle k_{J_\ell},q\rangle/\sqrt{d}}v_{J_\ell}}{\sum_{\ell=1}^{m}e^{\langle k_{J_\ell},q\rangle/\sqrt{d}}}.

for uniform samples J1,…,JmJ_1,\ldots,J_m. We write the attention error vector as

Attn⁡^(K,V,q)−Attn⁡(K,V,q)=1m∑ℓ=1mexp⁡(⟨kJℓ,q⟩/d)(vJℓ−Attn⁡(K,V,q))D^\widehat{\operatorname{Attn}}(K,V,q)-\operatorname{Attn}(K,V,q)=\frac{\frac{1}{m}\sum_{\ell=1}^{m}\exp(\langle k_{J_\ell},q\rangle/\sqrt{d})(v_{J_\ell}-\operatorname{Attn}(K,V,q))}{\widehat{D}}

We will use Chebyshev’s inequality to bound the denominator, and use Markov’s inequality to bound the norm of the numerator. By Equation (5), we have D≥ebR2D\ge e^{bR^2}. Moreover, since J1,…,JmJ_1,\ldots,J_m are independent,

Var⁡(D^)=1mVar⁡(e⟨kJ,q⟩/d)≤1mE[e2⟨kJ,q⟩/d]≤ebR2Dm,\operatorname{Var}(\widehat{D})=\frac{1}{m}\operatorname{Var}\left(e^{\langle k_J,q\rangle/\sqrt{d}}\right)\le\frac{1}{m}\mathbb{E}\left[e^{2\langle k_J,q\rangle/\sqrt{d}}\right]\le\frac{e^{bR^2}D}{m},

where JJ is uniform on [n][n]. Thus, by Chebyshev’s inequality (Lemma 7),

Pr⁡[D^<D/2]≤4ebR2/(mD)≤4e(b−a)R2/m≤ε2/24≤1/96.\Pr[\widehat{D}<D/2]\le4e^{bR^2}/(mD)\le4e^{(b-a)R^2}/m\le\varepsilon^2/24\le1/96.

On the other hand, we can bound the expected squared norm of the numerator as

E[∥1m∑ℓ=1mexp⁡(⟨kJℓ,q⟩/d)(vJℓ−Attn⁡(K,V,q))∥2]=1mn∑iexp⁡(⟨ki,q⟩/d)∥vi−Attn⁡(K,V,q)∥2≤ebR2m⋅1n∑iexp⁡(⟨ki,q⟩/d)∥vi−Attn⁡(K,V,q)∥2=ebR2m(1n∑iexp⁡(⟨ki,q⟩/d)∥vi∥2−D∥Attn⁡(K,V,q)∥2)≤ebR2Dm.\begin{aligned} \mathbb{E}\left[\left\|\frac{1}{m}\sum_{\ell=1}^{m}\exp(\langle k_{J_\ell},q\rangle/\sqrt{d})(v_{J_\ell}-\operatorname{Attn}(K,V,q))\right\|^2\right] \\ &=\frac{1}{mn}\sum_i\exp(\langle k_i,q\rangle/\sqrt{d})\|v_i-\operatorname{Attn}(K,V,q)\|^2 \\ &\le\frac{e^{bR^2}}{m}\cdot\frac{1}{n}\sum_i\exp(\langle k_i,q\rangle/\sqrt{d})\|v_i-\operatorname{Attn}(K,V,q)\|^2 \\ &=\frac{e^{bR^2}}{m}\left(\frac{1}{n}\sum_i\exp(\langle k_i,q\rangle/\sqrt{d})\|v_i\|^2-D\|\operatorname{Attn}(K,V,q)\|^2\right) \\ &\le\frac{e^{bR^2}D}{m}. \end{aligned}

Hence, by Markov’s inequality (Lemma 6), the probability that the numerator has norm larger than εD/2\varepsilon D/2 is at most 4ebR2/(mε2D)≤1/244e^{bR^2}/(m\varepsilon^2D)\le1/24.

Therefore, with probability at least 1−1/96−1/24>2/31-1/96-1/24>2/3, we have simultaneously D^≥D/2\widehat{D}\ge D/2 and numerator norm at most εD/2\varepsilon D/2, which implies ∥Attn⁡^(K,V,q)−Attn⁡(K,V,q)∥≤ε\|\widehat{\operatorname{Attn}}(K,V,q)-\operatorname{Attn}(K,V,q)\|\le\varepsilon.

Proofs from Section 2.2

Here we prove a standard lemma which is used in the lower bound about packing nearly orthogonal vectors in high dimensions.

Lemma 2 (Nearly orthogonal vectors). Consider integer M≥2M\ge2 and ξ∈(0,1)\xi\in(0,1). Let DD be an integer such that D≥6log⁡(2M)/ξ2D\ge6\log(2M)/\xi^2. There exist MM unit vectors u1,…,uM∈RDu_1,\ldots,u_M\in\mathbb{R}^D such that ∣⟨ui,uj⟩∣≤ξ|\langle u_i,u_j\rangle|\le\xi for every i≠ji\ne j.

Proof. We will prove the result by a standard application of the probabilistic method. For all i∈[M]i\in[M], choose each coordinate of each vector uiu_i independently and uniformly from {−D−1/2,D−1/2}\{-D^{-1/2},D^{-1/2}\}. Then, uiu_i is a unit vector. Note that for any i≠ji\ne j, ⟨ui,uj⟩\langle u_i,u_j\rangle is the sum of DD independent random variables with mean zero and bounded in magnitude by 1/D1/D. Hoeffding’s inequality (Lemma 8) gives Pr⁡[∣⟨ui,uj⟩∣>ξ]≤2e−Dξ2/2\Pr[|\langle u_i,u_j\rangle|>\xi]\le2e^{-D\xi^2/2}. A union bound over the (M2)\binom{M}{2} pairs upper bounds the failure probability by

M2e−Dξ2/2≤M2e−6log⁡(2M)/2=M2(2M)−3=18M<1.M^2e^{-D\xi^2/2}\le M^2e^{-6\log(2M)/2}=M^2(2M)^{-3}=\frac{1}{8M}<1.

Therefore, such a set of vectors must exist.

Proof of thm:lb-attn

Here we present the proof of the lower bound in the uniform sampling regime. Refer to the main body in § 2.2 for the construction of key, query, and value vectors.

Proof. Each group will contain t=⌊n/m⌋≥1t=\lfloor n/m\rfloor\geq1 copies of the same key-value pair, with one additional copy in the first ss groups, so that n=tm+sn=tm+s and 0≤s<m0\leq s<m. For i∈[m]i\in[m], let Ni=t+1N_i=t+1 if i≤si\leq s and Ni=tN_i=t if i>si>s. The attention instance K,VK,V will have NiN_i copies of the key-value pair (ki,vi)(k_i,v_i). By the setting of t,s,Nit,s,N_i, there will be exactly nn key-value pairs. As t≥1t\geq1, Nj/Ni≤2N_j/N_i\leq2 for all i,j∈[m]i,j\in[m].

At distinct query qiq_i, let αi\alpha_i be the attention mass on the copies of (ki,vi)(k_i,v_i). Bounding ⟨kj,qi⟩−⟨ki,qi⟩\langle k_j,q_i\rangle-\langle k_i,q_i\rangle by Equation (9) and Equation (10), we get

αi=Nie⟨ki,qi⟩/d∑j=1mNje⟨kj,qi⟩/d=11+∑j≠iNjNie(⟨kj,qi⟩−⟨ki,qi⟩)/d≥11+2(m−1)e−(1−2ξ)(b−a)R2.\alpha_i=\frac{N_i e^{\langle k_i,q_i\rangle/\sqrt{d}}}{\sum_{j=1}^{m}N_j e^{\langle k_j,q_i\rangle/\sqrt{d}}} =\frac{1}{1+\sum_{j\neq i}\frac{N_j}{N_i}e^{(\langle k_j,q_i\rangle-\langle k_i,q_i\rangle)/\sqrt{d}}} \geq\frac{1}{1+2(m-1)e^{-(1-2\xi)(b-a)R^2}}.

Recall the condition m≤e(1−2ξ)(b−a)R2/32m\leq e^{(1-2\xi)(b-a)R^2}/32. Then, 1−αi≤2me−(1−2ξ)(b−a)R2≤1161-\alpha_i\leq2me^{-(1-2\xi)(b-a)R^2}\leq\frac{1}{16}.

The attention output assigns mass αi\alpha_i to viv_i and total mass 1−αi1-\alpha_i to the other value vectors. Since all value vectors have unit norm, the triangle inequality gives

∥Attn⁡(K,V,qi)−vi∥≤(1−αi)max⁡j≠i∥vj−vi∥≤2(1−αi)≤18.(15)\lVert\operatorname{Attn}(K,V,q_i)-v_i\rVert\leq(1-\alpha_i)\max_{j\neq i}\lVert v_j-v_i\rVert\leq2(1-\alpha_i)\leq\frac{1}{8}. \tag*{(15)}

Let HiH_i be the event that the coreset retains at least one copy of (ki,vi)(k_i,v_i). On HicH_i^c, the nonnegative coreset weights imply that

Attn⁡^(K,V,qi)=∑j≠iλjvj,λj≥0,∑j≠iλj=1.\widehat{\operatorname{Attn}}(K,V,q_i)=\sum_{j\neq i}\lambda_jv_j,\qquad\lambda_j\geq0,\qquad\sum_{j\neq i}\lambda_j=1.

Since ∣⟨vi,vj⟩∣≤1/8|\langle v_i,v_j\rangle|\leq1/8 by Equation (11) for every j≠ij\neq i, we obtain

⟨vi,Attn⁡^(K,V,qi)⟩=∑j≠iλj⟨vi,vj⟩≤18∑j≠iλj=18.\left\langle v_i,\widehat{\operatorname{Attn}}(K,V,q_i)\right\rangle =\sum_{j\neq i}\lambda_j\langle v_i,v_j\rangle \leq\frac{1}{8}\sum_{j\neq i}\lambda_j =\frac{1}{8}.

Since ∥vi∥=1\lVert v_i\rVert=1, the Cauchy-Schwarz inequality and Equation (15) give

⟨vi,Attn⁡(K,V,qi)⟩=1+⟨vi,Attn⁡(K,V,qi)−vi⟩≥1−∥Attn⁡(K,V,qi)−vi∥≥78.\langle v_i,\operatorname{Attn}(K,V,q_i)\rangle =1+\langle v_i,\operatorname{Attn}(K,V,q_i)-v_i\rangle \geq1-\lVert\operatorname{Attn}(K,V,q_i)-v_i\rVert \geq\frac{7}{8}.

On HicH_i^c, we have already shown that ⟨vi,Attn⁡^(K,V,qi)⟩≤1/8\langle v_i,\widehat{\operatorname{Attn}}(K,V,q_i)\rangle\leq1/8. Since viv_i is a unit vector, another application of the Cauchy-Schwarz inequality gives

∥Attn⁡^(K,V,qi)−Attn⁡(K,V,qi)∥≥⟨vi,Attn⁡(K,V,qi)⟩−⟨vi,Attn⁡^(K,V,qi)⟩≥78−18=34>ε.\left\lVert\widehat{\operatorname{Attn}}(K,V,q_i)-\operatorname{Attn}(K,V,q_i)\right\rVert \geq\langle v_i,\operatorname{Attn}(K,V,q_i)\rangle-\langle v_i,\widehat{\operatorname{Attn}}(K,V,q_i)\rangle \geq\frac{7}{8}-\frac{1}{8}=\frac{3}{4}>\varepsilon.

Hence success at the fixed query qiq_i implies HiH_i. Since answering qiq_i accurately requires retaining a copy of (ki,vi)(k_i,v_i), the success guarantee Equation (3) implies Pr⁡[Hi]≥2/3\Pr[H_i]\geq2/3 for every i∈[m]i\in[m]. Since each retained pair represents at most one group,

E∣I∣≥∑i=1mPr⁡[Hi]≥2m3.\mathbb{E}|I|\geq\sum_{i=1}^{m}\Pr[H_i]\geq\frac{2m}{3}.

By definition, OPT⁡Attn\operatorname{OPT}_{\mathrm{Attn}} is the optimal worst-case number of tokens retained by an algorithm, so, from above, OPT⁡Attn≥2m/3\operatorname{OPT}_{\mathrm{Attn}}\geq2m/3.

Proofs from sec:upperimportance

Lemma 3 (Approximation guarantee). Suppose ∥vi∥≤1\lVert v_i\rVert\leq1 and si≥σis_i\geq\sigma_i for every i∈[n]i\in[n]. Then Algorithm 1 returns a weighted attention summary of size at most

min⁡{n,⌈96S2ε2⌉}.\min\left\{n,\left\lceil\frac{96S^2}{\varepsilon^2}\right\rceil\right\}.

For every fixed query q∈Qq \in Q, its estimate satisfies

Pr⁡[∥Attn⁡^(K,V,q)−Attn⁡(K,V,q)∥≤ε]≥23.\Pr\left[\left\|\widehat{\operatorname{Attn}}(K,V,q)-\operatorname{Attn}(K,V,q)\right\|\le\varepsilon\right]\ge\frac{2}{3}.

where the probability is over the sampling in Algorithm 1.

Proof. If the algorithm retains all tokens, the estimate is exact. Otherwise, fix q∈Qq \in Q and write

Z=∑i=1ne⟨ki,q⟩/d,Y=∑i=1ne⟨ki,q⟩/dvi.Z=\sum_{i=1}^{n}e^{\langle k_i,q\rangle/\sqrt{d}},\qquad Y=\sum_{i=1}^{n}e^{\langle k_i,q\rangle/\sqrt{d}}v_i.

Thus Attn⁡(K,V,q)=Y/Z\operatorname{Attn}(K,V,q)=Y/Z. The sampled denominator and numerator in (13) are

Z^=1m∑ℓ=1me⟨kJℓ,q⟩/dπJℓ,Y^=1m∑ℓ=1me⟨kJℓ,q⟩/dvJℓπJℓ.\widehat{Z}=\frac{1}{m}\sum_{\ell=1}^{m}\frac{e^{\langle k_{J_\ell},q\rangle/\sqrt{d}}}{\pi_{J_\ell}},\qquad\widehat{Y}=\frac{1}{m}\sum_{\ell=1}^{m}\frac{e^{\langle k_{J_\ell},q\rangle/\sqrt{d}}v_{J_\ell}}{\pi_{J_\ell}}.

Since each index ii is sampled with probability πi\pi_i, we have EZ^=Z\mathbb{E}\widehat{Z}=Z and EY^=Y\mathbb{E}\widehat{Y}=Y. The sensitivity upper bound gives

e⟨ki,q⟩/d≤σiZ≤siZfor every i∈[n].(16)e^{\langle k_i,q\rangle/\sqrt{d}}\le\sigma_i Z\le s_iZ\qquad\text{for every }i\in[n]. \tag*{(16)}

Using πi=si/S\pi_i=s_i/S,

Var⁡Z^≤1m∑i=1ne2⟨ki,q⟩/dπi≤SZm∑i=1ne⟨ki,q⟩/d=SmZ2.\operatorname{Var}\widehat{Z}\le\frac{1}{m}\sum_{i=1}^{n}\frac{e^{2\langle k_i,q\rangle/\sqrt{d}}}{\pi_i}\le\frac{SZ}{m}\sum_{i=1}^{n}e^{\langle k_i,q\rangle/\sqrt{d}}=\frac{S}{m}Z^2.

Similarly, using independence and applying Lemma 12 to a centered sample, we obtain

E∥Y^−Y∥2=1m(∑i=1ne2⟨ki,q⟩/d∥vi∥2πi−∥Y∥2)≤1m∑i=1ne2⟨ki,q⟩/dπi≤SmZ2,\mathbb{E}\left\|\widehat{Y}-Y\right\|^2=\frac{1}{m}\left(\sum_{i=1}^{n}\frac{e^{2\langle k_i,q\rangle/\sqrt{d}}\|v_i\|^2}{\pi_i}-\|Y\|^2\right)\le\frac{1}{m}\sum_{i=1}^{n}\frac{e^{2\langle k_i,q\rangle/\sqrt{d}}}{\pi_i}\le\frac{S}{m}Z^2,

where we used ∥vi∥≤1\|v_i\|\le1 and (16).

Using Chebyshev’s inequality (Lemma 7) for Z^\widehat{Z} and Markov’s inequality (Lemma 6) for ∥Y^−Y∥2\|\widehat{Y}-Y\|^2, followed by a union bound, we obtain

∣Z^−Z∣≤ε4Z,∥Y^−Y∥≤ε4Z\left|\widehat{Z}-Z\right|\le\frac{\varepsilon}{4}Z,\qquad\left\|\widehat{Y}-Y\right\|\le\frac{\varepsilon}{4}Z

hold together with probability at least 1−32Smε2≥231-\frac{32S}{m\varepsilon^2}\ge\frac{2}{3}, since m=⌈96S/ε2⌉m=\lceil96S/\varepsilon^2\rceil.

On this event, Z^≥(1−ε/4)Z\widehat{Z}\ge(1-\varepsilon/4)Z. Also, ∥Y∥≤Z\|Y\|\le Z because ∥vi∥≤1\|v_i\|\le1. Therefore,

∥Y^Z^−YZ∥≤∥Y^−Y∥Z^+∥Y∥∣Z^−Z∣ZZ^≤ε/21−ε/4≤ε,\left\|\frac{\widehat{Y}}{\widehat{Z}}-\frac{Y}{Z}\right\|\le\frac{\|\widehat{Y}-Y\|}{\widehat{Z}}+\frac{\|Y\||\widehat{Z}-Z|}{Z\widehat{Z}}\le\frac{\varepsilon/2}{1-\varepsilon/4}\le\varepsilon,

where the last inequality uses 0<ε<10<\varepsilon<1. The algorithm retains at most min⁡{n,m}\min\{n,m\} tokens, which gives the stated size bound. □\square

Lemma 4 (Total sensitivity bound). Suppose rk,rq>0r_k,r_q>0 and ∥ki∥≤rk\|k_i\|\le r_k for every ii, and let QQ be a nonempty compact query set such that

Q:={q∈Rd:∥q∥≤rq, ℓ≤⟨ki,q⟩d≤h  ∀i∈[n]}.Q:=\left\{q\in\mathbb{R}^d:\|q\|\le r_q,\ \ell\le\frac{\langle k_i,q\rangle}{\sqrt{d}}\le h\ \ \forall i\in[n]\right\}.

For sensitivities σi\sigma_i defined in Equation (12) with the supremum taken over q∈Qq\in Q, we have

∑i=1nσi≤exp⁡(min⁡{h−ℓ,R2+h2}).(17)\sum_{i=1}^{n}\sigma_i\le\exp\left(\min\left\{h-\ell,\frac{R^2+h}{2}\right\}\right). \tag*{(17)}

Proof. In this proof, we replace each key kik_i by rq/rk ki\sqrt{r_q/r_k}\,k_i and each query qq by rk/rq q\sqrt{r_k/r_q}\,q. This preserves all inner products and hence all sensitivities, while giving both keys and queries the common norm bound rkrq=Rd1/4\sqrt{r_k r_q}=R d^{1/4}. We use the same notation for the rescaled keys and query set.

Since Q\mathcal{Q} is compact and the attention weights are continuous, for each i∈[n]i \in[n] there exists a query qi∈Qq_i \in\mathcal{Q} attaining the sensitivity of token ii. We let qiq_i be a maximizing query for token ii; these q1,…,qnq_1,\ldots,q_n need not be the same.

Define

λi=σi/∑j=1nσj,kˉ=∑i=1nλiki,qˉ=∑i=1nλiqi.\lambda_i=\sigma_i\bigg/\sum_{j=1}^{n}\sigma_j,\qquad\bar{k}=\sum_{i=1}^{n}\lambda_i k_i,\qquad\bar{q}=\sum_{i=1}^{n}\lambda_i q_i.

For each ii, applying Jensen’s inequality (Lemma 9, with each xjx_j set to e⟨kj,qi⟩/de^{\langle k_j,q_i\rangle/\sqrt{d}}) gives

log⁡(∑j=1ne⟨kj,qi⟩/d)=log⁡(∑j=1nλje⟨kj,qi⟩/dλj)≥∑j=1nλjlog⁡e⟨kj,qi⟩/dλj=⟨kˉ,qi⟩d−∑j=1nλjlog⁡λj.(18)\log\left(\sum_{j=1}^{n}e^{\langle k_j,q_i\rangle/\sqrt{d}}\right) =\log\left(\sum_{j=1}^{n}\lambda_j\frac{e^{\langle k_j,q_i\rangle/\sqrt{d}}}{\lambda_j}\right) \geq\sum_{j=1}^{n}\lambda_j\log\frac{e^{\langle k_j,q_i\rangle/\sqrt{d}}}{\lambda_j} =\frac{\langle\bar{k},q_i\rangle}{\sqrt{d}}-\sum_{j=1}^{n}\lambda_j\log\lambda_j. \tag*{(18)}

By the definition of qiq_i, σi=e⟨ki,qi⟩/d/∑j=1ne⟨kj,qi⟩/d\sigma_i=e^{\langle k_i,q_i\rangle/\sqrt{d}}\big/\sum_{j=1}^{n}e^{\langle k_j,q_i\rangle/\sqrt{d}}. Combining this with σi/λi=∑j=1nσj\sigma_i/\lambda_i=\sum_{j=1}^{n}\sigma_j, we have

log⁡(∑i=1nσi)=∑i=1nλi(⟨ki,qi⟩d−log⁡(∑j=1ne⟨kj,qi⟩/d)−log⁡λi).\log\left(\sum_{i=1}^{n}\sigma_i\right)=\sum_{i=1}^{n}\lambda_i\left(\frac{\langle k_i,q_i\rangle}{\sqrt{d}}-\log\left(\sum_{j=1}^{n}e^{\langle k_j,q_i\rangle/\sqrt{d}}\right)-\log\lambda_i\right).

Applying Equation (18) to the right-hand side,

log⁡(∑i=1nσi)≤∑i=1nλi⟨ki,qi⟩d−⟨kˉ,qˉ⟩d=∑i=1nλi⟨ki−kˉ,qi−qˉ⟩d.(19)\log\left(\sum_{i=1}^{n}\sigma_i\right) \leq\sum_{i=1}^{n}\lambda_i\frac{\langle k_i,q_i\rangle}{\sqrt{d}}-\frac{\langle\bar{k},\bar{q}\rangle}{\sqrt{d}} =\sum_{i=1}^{n}\lambda_i\frac{\langle k_i-\bar{k},q_i-\bar{q}\rangle}{\sqrt{d}}. \tag*{(19)}

We bound this expression in two ways. First, ∑iλi⟨ki,qi⟩/d≤h\sum_i\lambda_i\langle k_i,q_i\rangle/\sqrt{d}\leq h. Also, ⟨kˉ,qˉ⟩/d=∑i,jλiλj⟨ki,qj⟩/d≥ℓ\langle\bar{k},\bar{q}\rangle/\sqrt{d}=\sum_{i,j}\lambda_i\lambda_j\langle k_i,q_j\rangle/\sqrt{d}\geq\ell, since every qjq_j belongs to Q\mathcal{Q}. Hence

log⁡(∑i=1nσi)≤h−⟨kˉ,qˉ⟩d≤h−ℓ.(20)\log\left(\sum_{i=1}^{n}\sigma_i\right)\leq h-\frac{\langle\bar{k},\bar{q}\rangle}{\sqrt{d}}\leq h-\ell. \tag*{(20)}

Second, centering the vectors (Lemma 12) gives ∑iλi∥ki−kˉ∥2=∑iλi∥ki∥2−∥kˉ∥2≤R2d−∥kˉ∥2\sum_i\lambda_i\lVert k_i-\bar{k}\rVert^2=\sum_i\lambda_i\lVert k_i\rVert^2-\lVert\bar{k}\rVert^2\leq R^2\sqrt{d}-\lVert\bar{k}\rVert^2, and the same bound holds for the queries. Applying Cauchy–Schwarz (Lemma 10) to (19), we obtain

log⁡(∑i=1nσi)≤1d(∑iλi∥ki−kˉ∥2)(∑iλi∥qi−qˉ∥2)≤1d(R2d−∥kˉ∥2)(R2d−∥qˉ∥2)≤R2−∥kˉ∥2+∥qˉ∥22d≤R2+⟨kˉ,qˉ⟩d.\begin{aligned} \log\left(\sum_{i=1}^{n}\sigma_i\right) \leq\frac{1}{\sqrt{d}}\sqrt{\left(\sum_i\lambda_i\lVert k_i-\bar{k}\rVert^2\right)\left(\sum_i\lambda_i\lVert q_i-\bar{q}\rVert^2\right)} \\ &\leq\frac{1}{\sqrt{d}}\sqrt{(R^2\sqrt{d}-\lVert\bar{k}\rVert^2)(R^2\sqrt{d}-\lVert\bar{q}\rVert^2)} \leq R^2-\frac{\lVert\bar{k}\rVert^2+\lVert\bar{q}\rVert^2}{2\sqrt{d}} \leq R^2+\frac{\langle\bar{k},\bar{q}\rangle}{\sqrt{d}}. \end{aligned}

The last two inequalities follow from the arithmetic-geometric mean inequality (Lemma 11) and Young’s inequality for inner products, 2⟨kˉ,qˉ⟩≥−∥kˉ∥2−∥qˉ∥22\langle\bar{k},\bar{q}\rangle\geq-\lVert\bar{k}\rVert^2-\lVert\bar{q}\rVert^2, respectively. Averaging this bound with log⁡(∑i=1nσi)≤h−⟨kˉ,qˉ⟩/d\log(\sum_{i=1}^{n}\sigma_i)\leq h-\langle\bar{k},\bar{q}\rangle/\sqrt{d} from (20) gives

log⁡(∑i=1nσi)≤R2+h2.\log\left(\sum_{i=1}^{n}\sigma_i\right)\leq\frac{R^2+h}{2}.

Together with log⁡(∑i=1nσi)≤h−ℓ\log(\sum_{i=1}^{n}\sigma_i)\leq h-\ell, this proves the lemma.

Lemma 5 (Computing sampling scores). Let −1≤a<b≤1-1\leq a<b\leq1 and rk,rq>0r_k,r_q>0, and write R2=rkrqdR^2=\frac{r_k r_q}{\sqrt{d}}, κ=min⁡{b−a,1+b2}\kappa=\min\left\{b-a,\frac{1+b}{2}\right\}. Suppose ∥ki∥≤rk\lVert k_i\rVert\leq r_k for every i∈[n]i\in[n], and let

Q:={q∈Rd:∥q∥≤rq,a∥ki∥∥q∥≤⟨ki,q⟩≤b∥ki∥∥q∥∀i∈[n]}.\mathcal{Q}:=\left\{q\in\mathbb{R}^d:\lVert q\rVert\leq r_q,\quad a\lVert k_i\rVert\lVert q\rVert\leq\langle k_i,q\rangle\leq b\lVert k_i\rVert\lVert q\rVert\quad\forall i\in[n]\right\}.

For sensitivities σi\sigma_i defined in Equation (12) with the supremum taken over q∈Qq \in\mathcal{Q}, we can compute sampling scores sis_i satisfying si≥σis_i \ge\sigma_i for every i∈[n]i \in[n], and

∑i=1nsi≤128e2κ2eκR2.\sum_{i=1}^{n} s_i \le\frac{128e^2}{\kappa^2}e^{\kappa R^2}.

Moreover, such sampling scores can be obtained by solving n⋅max⁡{1,⌈R2⌉}n \cdot\max\{1,\lceil R^2\rceil\} convex optimization problems, using only the keys and the parameters rkr_k, rqr_q, aa, bb.

Proof. We group keys and queries by norm, compute sampling scores within each pair of groups by convex optimization, and then bound the sum of these scores using Lemma 4.

Partitioning by norm. Set M=max⁡{1,⌈R2⌉}M = \max\{1,\lceil R^2\rceil\}. Partition the keys into norm bins

I1={i∈[n]:∥ki∥≤rkM},Iu={i∈[n]:(u−1)rkM<∥ki∥≤urkM}(u=2,…,M).I_1 = \left\{i \in[n] : \lVert k_i\rVert\le\frac{r_k}{M}\right\}, \qquad I_u = \left\{i \in[n] : \frac{(u-1)r_k}{M} < \lVert k_i\rVert\le\frac{ur_k}{M}\right\} \quad(u=2,\ldots,M).

Similarly, partition the possible query norms into MM intervals of width rq/Mr_q/M, assigning each endpoint to the interval on its left and including zero in the first interval.

For u,v∈[M]u,v \in[M], denote

Auv=R2(u−1)(v−1)M2,Buv=R2uvM2,ℓuv=min⁡{aAuv,aBuv},huv=max⁡{bAuv,bBuv}.A_{uv} = \frac{R^2(u-1)(v-1)}{M^2}, \qquad B_{uv} = \frac{R^2uv}{M^2}, \qquad\ell_{uv} = \min\{aA_{uv},aB_{uv}\}, \qquad h_{uv} = \max\{bA_{uv},bB_{uv}\}.

If i∈Iui \in I_u and an admissible query qq has norm in the vv-th interval, then

Auv≤∥ki∥∥q∥d≤Buv,ℓuv≤⟨ki,q⟩d≤huv.A_{uv} \le\frac{\lVert k_i\rVert\lVert q\rVert}{\sqrt{d}} \le B_{uv}, \qquad\ell_{uv} \le\frac{\langle k_i,q\rangle}{\sqrt{d}} \le h_{uv}.

Thus, for each nonempty IuI_u, the compact convex domain

Q~uv={z∈Rd:∥z∥≤vrqM, ℓuv≤⟨kj,z⟩d≤huv  ∀j∈Iu}\widetilde{\mathcal{Q}}_{uv} = \left\{z \in\mathbb{R}^d : \lVert z\rVert\le\frac{vr_q}{M},\ \ell_{uv} \le\frac{\langle k_j,z\rangle}{\sqrt{d}} \le h_{uv}\ \ \forall j \in I_u\right\}

contains every admissible query whose norm lies in the vv-th interval.

Bounding sensitivities locally. For i∈Iui \in I_u, define the local sensitivity

σiuv=max⁡z∈Q~uve⟨ki,z⟩/d∑j∈Iue⟨kj,z⟩/d,\sigma_i^{uv} = \max_{z\in\widetilde{\mathcal{Q}}_{uv}} \frac{e^{\langle k_i,z\rangle/\sqrt{d}}}{\sum_{j\in I_u} e^{\langle k_j,z\rangle/\sqrt{d}}},

with σiuv=0\sigma_i^{uv}=0 when Q~uv\widetilde{\mathcal{Q}}_{uv} is empty. For an admissible query qq whose norm lies in the vv-th interval,

e⟨ki,q⟩/d∑j=1ne⟨kj,q⟩/d≤e⟨ki,q⟩/d∑j∈Iue⟨kj,q⟩/d≤σiuv.\frac{e^{\langle k_i,q\rangle/\sqrt{d}}}{\sum_{j=1}^{n}e^{\langle k_j,q\rangle/\sqrt{d}}} \le \frac{e^{\langle k_i,q\rangle/\sqrt{d}}}{\sum_{j\in I_u}e^{\langle k_j,q\rangle/\sqrt{d}}} \le\sigma_i^{uv}.

Consequently, σi≤∑v=1Mσiuv\sigma_i \le\sum_{v=1}^{M}\sigma_i^{uv}.

Computing the sampling scores. For i∈Iui \in I_u, define

fiu(z):=log⁡(∑j∈Iue⟨kj−ki,z⟩/d).f_i^u(z) := \log\left(\sum_{j\in I_u}e^{\langle k_j-k_i,z\rangle/\sqrt{d}}\right).

By Lemma 13, this objective is convex and continuously differentiable, with an explicit gradient. Whenever Q~uv\widetilde{\mathcal{Q}}_{uv} is nonempty, it is the logarithm of the reciprocal of token ii’s attention weight within IuI_u, so

min⁡z∈Q~uvfiu(z)=−log⁡σiuv.\min_{z\in\widetilde{\mathcal{Q}}_{uv}} f_i^u(z) = -\log\sigma_i^{uv}.

Moreover, for every z∈Q~uvz \in\widetilde{\mathcal{Q}}_{uv}, 0≤fiu(z)≤log⁡∣Iu∣+huv−ℓuv0 \le f_i^u(z) \le\log|I_u| + h_{uv} - \ell_{uv}. The lower bound follows from the term j=ij=i, and the upper bound follows from the defining inner-product bounds of Q~uv\widetilde{\mathcal{Q}}_{uv}.

By Lemma 14 and the definition of Q~uv\widetilde{Q}_{uv}, each nonempty domain is compact and convex. Applying Lemma 15 with η=log⁡2\eta= \log2, we obtain ziuv∈Q~uvz_i^{uv} \in\widetilde{Q}_{uv} satisfying

−log⁡σiuv≤fiu(ziuv)≤−log⁡σiuv+log⁡2.(21)-\log\sigma_i^{uv} \le f_i^{u}(z_i^{uv}) \le-\log\sigma_i^{uv}+\log2. \tag*{(21)}

Set siuv:=2e−fiu(ziuv)s_i^{uv} := 2e^{-f_i^{u}(z_i^{uv})}. Exponentiating Equation (21) gives σiuv≤siuv≤2σiuv\sigma_i^{uv} \le s_i^{uv} \le2\sigma_i^{uv}. For empty domains, set siuv:=0s_i^{uv} := 0, so the same inequalities hold under the convention σiuv=0\sigma_i^{uv}=0. We are now ready to describe the sampling scores sis_i. For i∈Iui \in I_u, define

si:=∑v=1Msiuv.s_i := \sum_{v=1}^{M}s_i^{uv}.

Together with the local sensitivity bound, this gives σi≤∑v=1Mσiuv≤si≤2∑v=1Mσiuv\sigma_i \le\sum_{v=1}^{M}\sigma_i^{uv} \le s_i \le2\sum_{v=1}^{M}\sigma_i^{uv}. Since 0∈Q0 \in Q, we have σi≥1/n\sigma_i \ge1/n, so the scores are positive.

Bounding the sum within each pair of bins. Write Duv=Buv−Auv=R2(u+v−1)M2≤2R2M≤2D_{uv}=B_{uv}-A_{uv}=\frac{R^2(u+v-1)}{M^2}\le\frac{2R^2}{M}\le2. For x+=max⁡{x,0}x_+=\max\{x,0\}, the endpoint definitions give

ℓuv=aBuv−a+Duv,huv=bBuv+(−b)+Duv.\ell_{uv}=aB_{uv}-a_+D_{uv}, \qquad h_{uv}=bB_{uv}+(-b)_+D_{uv}.

Since a++(−b)+≤1a_+ + (-b)_+ \le1,

huv−ℓuv≤(b−a)Buv+2,Buv+huv2≤1+b2Buv+1.h_{uv}-\ell_{uv}\le(b-a)B_{uv}+2,\qquad\frac{B_{uv}+h_{uv}}{2}\le\frac{1+b}{2}B_{uv}+1.

The keys in IuI_u have norm at most urk/Mur_k/M, and queries in Q~uv\widetilde{Q}_{uv} have norm at most vrq/Mvr_q/M. The product of these bounds, divided by d\sqrt{d}, is BuvB_{uv}. For each nonempty domain, Lemma 4 therefore gives

∑i∈Iuσiuv≤exp⁡(min⁡{huv−ℓuv,Buv+huv2})≤eκBuv+2.\sum_{i\in I_u}\sigma_i^{uv}\le\exp\left(\min\left\{h_{uv}-\ell_{uv},\frac{B_{uv}+h_{uv}}{2}\right\}\right)\le e^{\kappa B_{uv}+2}.

The same bound holds trivially for empty domains. Hence

∑i=1nsi≤2e2∑u=1M∑v=1MeκBuv.\sum_{i=1}^{n}s_i\le2e^2\sum_{u=1}^{M}\sum_{v=1}^{M}e^{\kappa B_{uv}}.

Summing over the bins. If R2<1R^2<1, then M=1M=1, and the desired bound follows immediately. Otherwise, M=⌈R2⌉≤2R2M=\lceil R^2\rceil\le2R^2. Since u,v≤Mu,v\le M,

Buv≤R2(u+v)2M=R2−R22M((M−u)+(M−v)).B_{uv}\le\frac{R^2(u+v)}{2M}=R^2-\frac{R^2}{2M}\bigl((M-u)+(M-v)\bigr).

Using R2/(2M)≥1/4R^2/(2M)\ge1/4, we obtain

∑u=1M∑v=1MeκBuv≤eκR2(∑t=0M−1e−κt/4)2≤eκR2(1−e−κ/4)2.\sum_{u=1}^{M}\sum_{v=1}^{M}e^{\kappa B_{uv}}\le e^{\kappa R^2}\left(\sum_{t=0}^{M-1}e^{-\kappa t/4}\right)^2\le\frac{e^{\kappa R^2}}{(1-e^{-\kappa/4})^2}.

Finally, 0<κ≤10<\kappa\le1 and 1−e−κ/4≥κ/81-e^{-\kappa/4}\ge\kappa/8, so

∑i=1nsi≤128e2κ2eκR2.\sum_{i=1}^{n}s_i\le\frac{128e^2}{\kappa^2}e^{\kappa R^2}.

Each key participates in at most MM optimization problems, giving at most nMnM such problems in total. ∎

Proofs from Section 3.2

In this section, we give the proof of Theorem 4, the lower bound in the importance sampling regime.

Theorem 4 (Lower bound, Item 2). Consider rk,rq>0r_k,r_q > 0, ϵ∈(0,1/2]\epsilon\in(0,1/2], and −1≤a<b≤1-1 \le a < b \le1 in the importance sampling regime (Theorem 1). Consider nn and d=ω(log⁡n)d = \omega(\log n), and let ξ=6log⁡(2n)d−3=o(1)\xi= \sqrt{\frac{6\log(2n)}{d-3}} = o(1). Pick any integer mm satisfying

2≤m≤n,m≤min⁡{e1+b2R2,e(b−a)R2}⋅e−2ξR2/32.(22)2 \le m \le n,\qquad m \le\min\left\{e^{\frac{1+b}{2}R^2},e^{(b-a)R^2}\right\}\cdot e^{-2\xi R^2}/32. \tag*{(22)}

There is a fixed dataset (K,V)(K,V) of nn key-value pairs, with keys of norm rkr_k and unit-norm values in Rd\mathbb{R}^d, together with queries q1,…,qmq_1,\ldots,q_m of norm rqr_q, such that every key k∈Kk \in K satisfies

a≤⟨k,qi⟩∥k∥∥qi∥≤bfor all i∈[m].a \le\frac{\langle k,q_i\rangle}{\lVert k\rVert\lVert q_i\rVert} \le b \qquad\text{for all }i \in[m].

For this dataset, satisfying Equation (3) at each of these queries requires OPTAttn≥2m/3\mathrm{OPT}_{\mathrm{Attn}} \ge2m/3.

The construction and analysis are essentially the same as that in the uniform sampling regime § 2.2 with slightly more complicated parameter settings in order to capture all possible values of a,ba,b.

Goal. We construct keys and queries such that each matching pair (ki,qi)(k_i,q_i) has scaled inner product bR2bR^2, exceeding that of every nonmatching pair (kj,qi)(k_j,q_i), j≠ij \ne i, by at least (1−o(1))min⁡{b−a,(1+b)/2}R2(1-o(1))\min\{b-a,(1+b)/2\}R^2, where R2=rkrq/dR^2 = r_kr_q/\sqrt{d}. We will then use this gap to make each query concentrate its attention on copies of its matching key, forcing an accurate summary to retain many key groups.

Construction. Let e0,eK,eQe_0,e_K,e_Q be the first three standard basis vectors. Choose mm unit vectors satisfying Lemma 2 in dimension D=d−3D=d-3, with pairwise inner products bounded in magnitude by ξ=6log⁡(2n)D\xi=\sqrt{\frac{6\log(2n)}{D}}. Embed them into the last d−3d-3 coordinates of Rd\mathbb{R}^d, and denote the resulting vectors by u1,…,umu_1,\ldots,u_m. Define

ki=rk(α ui+∣β∣ e0+1−α−∣β∣ eK),k_i=r_k\left(\sqrt{\alpha}\,u_i+\sqrt{|\beta|}\,e_0+\sqrt{1-\alpha-|\beta|}\,e_K\right),
qi=rq(α ui−sgn⁡(β)∣β∣ e0+1−α−∣β∣ eQ).(23)q_i=r_q\left(\sqrt{\alpha}\,u_i-\operatorname{sgn}(\beta)\sqrt{|\beta|}\,e_0+\sqrt{1-\alpha-|\beta|}\,e_Q\right). \tag*{(23)}

where we set

α=min⁡{1+b2,b−a1+ξ},β=α−b=min⁡{1−b2,−a−ξb1+ξ}.(24)\alpha=\min\left\{\frac{1+b}{2},\frac{b-a}{1+\xi}\right\},\qquad \beta=\alpha-b=\min\left\{\frac{1-b}{2},\frac{-a-\xi b}{1+\xi}\right\}. \tag*{(24)}

Note that α≥0\alpha\ge0 as b≥−1b \ge-1 and b≥ab \ge a. Note that α+∣β∣≤1\alpha+|\beta| \le1 as α+β=2α−b≤2(1+b2)−b=1\alpha+\beta=2\alpha-b \le2\left(\frac{1+b}{2}\right)-b=1 and α−β=b≤1\alpha-\beta=b \le1. Therefore, 1−α−∣β∣≥01-\alpha-|\beta| \ge0 and the keys and queries are well defined with norms exactly equal to ∥ki∥=rk\lVert k_i\rVert=r_k and ∥qi∥=rq\lVert q_i\rVert=r_q. The components along uiu_i and e0e_0 serve the purpose of achieving the desired inner products while the padding along eKe_K and eQe_Q increases the norms of the keys/queries to fix the denominator of cosine similarity.

Verifying the inner products. It remains to bound the scaled inner products between queries and keys. For any i∈[m]i \in[m], the inner product between the matching pair is:

⟨ki,qi⟩d=(α−β)R2=bR2.\frac{\langle k_i,q_i\rangle}{\sqrt{d}}=(\alpha-\beta)R^2=bR^2.

For any non-matching pair i≠ji\ne j,

(b−α(1+ξ))R2≤⟨kj,qi⟩d=(α⟨ui,uj⟩−β)R2≤bR2.(b-\alpha(1+\xi))R^2\le\frac{\langle k_j,q_i\rangle}{\sqrt{d}}=(\alpha\langle u_i,u_j\rangle-\beta)R^2\le bR^2.

The second choice in the minimum defining α\alpha ensures b−α(1+ξ)≥ab-\alpha(1+\xi)\ge a. Thus, every key-query cosine similarity belongs to [a,b][a,b], since R2d=rkrq=∥ki∥∥qi∥R^2\sqrt{d}=r_kr_q=\lVert k_i\rVert\lVert q_i\rVert.

For any i≠ji \ne j, the scaled inner product between key-query pairs at the same index exceeds that of any other key-query pair by

⟨ki,qi⟩−⟨kj,qi⟩d≥bR2−(αξ−β)R2=α(1−ξ)R2.\frac{\langle k_i,q_i\rangle-\langle k_j,q_i\rangle}{\sqrt{d}} \ge bR^2-(\alpha\xi-\beta)R^2=\alpha(1-\xi)R^2.

By the definition of α\alpha,

⟨ki,qi⟩−⟨kj,qi⟩d≥min⁡{b−a,1+b2}R21−ξ1+ξ≥(1−2ξ)min⁡{b−a,1+b2}R2.(25)\frac{\langle k_i,q_i\rangle-\langle k_j,q_i\rangle}{\sqrt{d}} \ge\min\left\{b-a,\frac{1+b}{2}\right\}R^2\frac{1-\xi}{1+\xi}\ge(1-2\xi)\min\left\{b-a,\frac{1+b}{2}\right\}R^2. \tag*{(25)}

The last inequality uses (1−x)/(1+x)≥1−2x(1-x)/(1+x)\ge1-2x for x≥0x\ge0.

Constructing the value vectors. Apply Lemma 2 a second time to obtain mm unit value vectors v1,…,vm∈Rdv_1,\ldots,v_m\in\mathbb{R}^d satisfying

∣⟨vi,vj⟩∣≤18for all i,j∈[m] with i≠j.(26)\lvert\langle v_i,v_j\rangle\rvert\le\frac{1}{8}\qquad\text{for all }i,j\in[m]\text{ with }i\ne j. \tag*{(26)}

Since m≤nm\le n, the assumption d=ω(log⁡n)d=\omega(\log n) ensures that this is possible.

Full construction

Proof of Theorem 4. Choose t=⌊n/m⌋≥1t=\lfloor n/m\rfloor\ge1 and 0≤s<m0\le s<m such that n=tm+sn=tm+s. For i∈[m]i\in[m], let Ni=t+1N_i=t+1 if i≤si\le s and Ni=tN_i=t if i>si>s. The attention instance K,VK,V will have NiN_i copies of the key-value pair (ki,vi)(k_i,v_i). By the setting of t,s,Nit,s,N_i, there will be exactly nn key-value pairs. As t≥1t\ge1, Nj/Ni≤2N_j/N_i\le2 for all i,j∈[m]i,j\in[m].

At distinct query qiq_i, let αi\alpha_i be the attention mass on the copies of (ki,vi)(k_i,v_i). By Equation (25),

αi=Nie⟨ki,qi⟩/d∑j=1mNje⟨kj,qi⟩/d=11+∑j≠iNjNie(⟨kj,qi⟩−⟨ki,qi⟩)/d≥11+2(m−1)e−(1−2ξ)min⁡{b−a,(1+b)/2}R2.\alpha_i=\frac{N_i e^{\langle k_i,q_i\rangle/\sqrt{d}}}{\sum_{j=1}^{m}N_j e^{\langle k_j,q_i\rangle/\sqrt{d}}} =\frac{1}{1+\sum_{j\ne i}\frac{N_j}{N_i}e^{(\langle k_j,q_i\rangle-\langle k_i,q_i\rangle)/\sqrt{d}}} \ge\frac{1}{1+2(m-1)e^{-(1-2\xi)\min\{b-a,(1+b)/2\}R^2}}.

Recall the condition m≤e(1−2ξ)min⁡{b−a,(1+b)/2}R2/32m\le e^{(1-2\xi)\min\{b-a,(1+b)/2\}R^2/32}. Then,

1−αi≤2me−(1−2ξ)min⁡{b−a,(1+b)/2}R2≤116.1-\alpha_i\le2m e^{-(1-2\xi)\min\{b-a,(1+b)/2\}R^2}\le\frac{1}{16}.

So, attention focuses significant mass on viv_i:

∥Attn⁡(K,V,qi)−vi∥≤2(1−αi)≤18.(27)\lVert\operatorname{Attn}(K,V,q_i)-v_i\rVert\le2(1-\alpha_i)\le\frac{1}{8}. \tag*{(27)}

The first inequality follows because all value vectors have norm one, so their distance from viv_i is at most two.

Let HiH_i be the event that the coreset retains at least one copy of (ki,vi)(k_i,v_i). On the complementary event, the approximation at qiq_i is a convex combination of the value vectors vjv_j with j≠ij\ne i. This follows directly from the nonnegative weights in the definition of query-oblivious weighted token-eviction. Therefore

⟨vi,Attn⁡^(K,V,qi)⟩≤18\langle v_i,\widehat{\operatorname{Attn}}(K,V,q_i)\rangle\le\frac{1}{8}

as all distinct value vectors are nearly orthogonal.

On the other hand, Equation (27) gives ⟨vi,Attn⁡(K,V,qi)⟩≥1−1/8\langle v_i,\operatorname{Attn}(K,V,q_i)\rangle\ge1-1/8. Projecting the error onto the unit vector viv_i yields, whenever HiH_i does not hold,

∥Attn⁡^(K,V,qi)−Attn⁡(K,V,qi)∥≥∣⟨vi,Attn⁡^(K,V,qi)⟩−⟨vi,Attn⁡(K,V,qi)⟩∣\left\lVert\widehat{\operatorname{Attn}}(K,V,q_i)-\operatorname{Attn}(K,V,q_i)\right\rVert\ge\left\lvert\langle v_i,\widehat{\operatorname{Attn}}(K,V,q_i)\rangle-\langle v_i,\operatorname{Attn}(K,V,q_i)\rangle\right\rvert
≥1−18−18=34>ε.\ge1-\frac{1}{8}-\frac{1}{8}=\frac{3}{4}>\varepsilon.

Hence success at the fixed query qiq_i implies HiH_i.

The per-query guarantee of a query-oblivious weighted token-eviction policy now gives Pr⁡[Hi]≥2/3\Pr[H_i]\ge2/3 for each ii separately. Since each retained pair represents at most one group,

E∣I∣≥∑i=1mPr⁡[Hi]≥2m3.\mathbb{E}|I|\ge\sum_{i=1}^{m}\Pr[H_i]\ge\frac{2m}{3}.

By definition, OPTAttn\mathrm{OPT}_{\mathrm{Attn}} is the optimal worst-case number of tokens retained by an algorithm, so, from above, OPTAttn≥2m/3\mathrm{OPT}_{\mathrm{Attn}}\ge2m/3.

Experiments

Q/K Cosine similarity

Figure 7. Query–key cosine similarities across inputs. The plot uses Qwen3 8B at layer 8 on (a) LongBench v2, (b) InfiniteBench, (c) SCBench. Each panel uses an input of 8,192 tokens and compares the final 256 queries from query head 0 against 7,935 earlier-context keys from the corresponding KV head 0. The initial key (attention sink) is excluded. Cosines are computed after model normalization and RoPE.

Figure 8. Query–key cosine similarities with initial token (attention sink) Qwen3 8B at layer 8 on LongBench v2 example input of 8,192 tokens and compares the final 256 queries from query head 0 against a sample of 16 earlier-context keys from the corresponding KV head 0 and the initial key (attention sink). Cosines are computed after model normalization and RoPE.

Key/Query norms

References

  1. [1]Vladimir Braverman, Dan Feldman, Harry Lang, Adiel Statman, and Samson Zhou. Efficient coreset constructions via sensitivity sampling. In Vineeth N. Balasubramanian and Ivor Tsang (eds.), Proceedings of The 13th Asian Conference on Machine Learning, volume 157 of Proceedings of Machine Learning Research, pp. 948–963. PMLR, 17–19 Nov 2021. URL https://proceedings.mlr.press/v157/braverman21a.html.
  2. [2]Zefan Cai, Yichi Zhang, Bofei Gao, Yuliang Liu, Yucheng Li, Tianyu Liu, Keming Lu, Wayne Xiong, Yue Dong, Junjie Hu, and Wen Xiao. PyramidKV: Dynamic KV cache compression based on pyramidal information funneling. In Second Conference on Language Modeling, 2025. URL https://openreview.net/forum?id=ayi7qezU87.arxiv.org/abs/2406.02069
  3. [3]Chi-Chih Chang, Wei-Cheng Lin, Chien-Yu Lin, Chong-Yan Chen, Yu-Fang Hu, Pei-Shuo Wang, Ning-Chi Huang, Luis Ceze, Mohamed Abdelfattah, and Kai-Chiang Wu. Palu: KV-cache compression with low-rank projection. In The Thirteenth International Conference on Learning Representations, 2025. URL https://proceedings.iclr.cc/paper_files/paper/2025/hash/7da6e0e00702c60607a6ae05c802ef85-Abstract-Conference.html.arxiv.org/abs/2407.21118
  4. [4]Justin Y. Chen, Ying Feng, Piotr Indyk, Michael Kapralov, Ekaterina Kochetkova, and Boris Prokhorov. Towards tight bounds for streaming attention, 2026. URL https://arxiv.org/abs/2606.07205.
  5. [5]Petros Drineas, Malik Magdon-Ismail, Michael W. Mahoney, and David P. Woodruff. Fast approximation of matrix coherence and statistical leverage. Journal of Machine Learning Research, 13 (111):3475–3506, 2012. URL https://www.jmlr.org/papers/v13/drineas12a.html.
  6. [6]Sabri Eyuboglu, Ryan Ehrlich, Simran Arora, Neel Guha, Dylan Zinsley, Emily Liu, Will Tennien, Atri Rudra, James Zou, Azalia Mirhoseini, and Christopher Re. Cartridges: Lightweight and general-purpose long context representations via self-study, 2025. URL https://arxiv.org/abs/2506.06266.
  7. [7]Yuan Feng, Junlin Lv, Yukun Cao, Xike Xie, and S. Kevin Zhou. Ada-KV: Optimizing KV cache eviction by adaptive budget allocation for efficient LLM inference. In Advances in Neural Information Processing Systems, volume 38, 2025. URL https://openreview.net/forum?id=tcisuhGsQZ.arxiv.org/abs/2407.11550
  8. [8]Nathan Godey, Éric Villemonte de la Clergerie, and Benoît Sagot. Anisotropy is inherent to self-attention in transformers. In Yvette Graham and Matthew Purver (eds.), Proceedings of the 18th Conference of the European Chapter of the Association for Computational Linguistics, EACL 2024 - Volume 1: Long Papers, St. Julian’s, Malta, March 17-22, 2024, pp. 35–48. Association for Computational Linguistics, 2024. DOI: 10.18653/v1/2024.eacl-long.3. URL https://doi.org/10.18653/v1/2024.eacl-long.3.
  9. [9]Themistoklis Haris and Krzysztof Onak. Compression barriers in autoregressive transformers. In Nika Haghtalab and Ankur Moitra (eds.), The Thirty Eighth Annual Conference on Learning Theory, June 30 - July 4, 2025, Lyon, France, volume 291 of Proceedings of Machine Learning Research, pp. 2577–2875. PMLR, 2025. URL https://proceedings.mlr.press/v291/haris25a.html.arxiv.org/abs/2502.15955
  10. [10]Coleman Hooper, Sehoon Kim, Hiva Mohammadzadeh, Michael W. Mahoney, Yakun Sophia Shao, Kurt Keutzer, and Amir Gholami. KVQuant: Towards 10 million context length LLM inference with KV cache quantization. In Advances in Neural Information Processing Systems, volume 37, 2024. URL https://proceedings.neurips.cc/paper_files/paper/2024/hash/028f8c3d95339a40c461b42c99a4-Abstract-Conference.html.arxiv.org/abs/2401.18079
  11. [11]Ekaterina Kochetkova, Kshiteej Jitesh Sheth, Insu Han, Amir Zandieh, and Michael Kapralov. Streaming attention approximation via discrepancy theory. In Advances in Neural Information Processing Systems, volume 38, 2025. URL https://papers.neurips.cc/paper_files/paper/2025/hash/1de510838fadd72f79a7a90e9c564f0c-Abstract-Conference.html.arxiv.org/abs/2502.07861
  12. [12]Yuhong Li, Yingbing Huang, Bowen Yang, Bharat Venkitesh, Acyr Locatelli, Hanchen Ye, Tianle Cai, Patrick Lewis, and Deming Chen. SnapKV: LLM knows what you are looking for before generation. In Advances in Neural Information Processing Systems, volume 37, 2024. URL https://proceedings.neurips.cc/paper_files/paper/2024/hash/28ab41824260e0f7323e54185d19bde-Abstract-Conference.html.arxiv.org/abs/2404.14469
  13. [13]Edo Liberty, Alexandr Andoni, and Eldar Kleiner. Nearly optimal attention coresets. CoRR, abs/2605.05602, 2026. doi: 10.48550/ARXIV.2605.05602. URL https://doi.org/10.48550/arXiv.2605.05602.
  14. [14]Zichang Liu, Aditya Desai, Fangshuo Liao, Weitao Wang, Victor Xie, Zhaozhuo Xu, Anastasios Kyrillidis, and Anshumali Shrivastava. Scissorhands: Exploiting the persistence of importance hypothesis for LLM KV cache compression at test time. In Advances in Neural Information Processing Systems, volume 36, 2023. URL https://proceedings.neurips.cc/paper_files/paper/2023/hash/a452a7c6c463e4ae8fbdc614c6e983e6-Abstract-Conference.html.arxiv.org/abs/2305.17118
  15. [15]Zirui Liu, Jiayi Yuan, Hongye Jin, Shaochen Zhong, Zhaozhuo Xu, Vladimir Braverman, Beidi Chen, and Xia Hu. KIVI: A tuning-free asymmetric 2bit quantization for KV cache. In Proceedings of the 41st International Conference on Machine Learning, volume 235 of Proceedings of Machine Learning Research, pp. 32332–32344. PMLR, 2024. URL https://proceedings.mlr.press/v235/liu24bz.html.DOI
  16. [16]Pierre-Emmanuel Mazaré, Gergely Szilvasy, Maria Lomeli, Francisco Massa, Naila Murray, Hervé Jégou, and Matthijs Douze. Inference-time sparse attention with asymmetric indexing. arXiv preprint arXiv:2502.08246, 2025. URL https://arxiv.org/abs/2502.08246.
  17. [17]Lieven Vandenberghe and Stephen Boyd. Convex optimization, volume 1. Cambridge university press Cambridge, 2004.
  18. [18]Heng Wang, Jielin Qiu, Wenting Zhao, Cheng Qian, Liangwei Yang, Jiawei Han, Heng Ji, Silvio Savarese, Shelby Heinecke, and Huan Wang. Random attention: Rethinking KV cache eviction for efficient reasoning. arXiv preprint arXiv:2609.03430, 2026. URL https://arxiv.org/abs/2609.03430.
  19. [19]Guangxuan Xiao, Yuandong Tian, Beidi Chen, Song Han, and Mike Lewis. Efficient streaming language models with attention sinks. In The Twelfth International Conference on Learning Representations, 2024. URL https://openreview.net/forum?id=NG7sS51zVF.arxiv.org/abs/2309.17453
  20. [20]Amir Zandieh, Insu Han, Vahab Mirrokni, and Amin Karbasi. SubGen: Token generation in sublinear time and memory. arXiv preprint arXiv:2402.06082, 2024. URL https://arxiv.org/abs/2402.06082.
  21. [21]Amir Zandieh, Majid Daliri, Majid Hadian, and Vahab Mirrokni. TurboQuant: Online vector quantization with near-optimal distortion rate. In The Fourteenth International Conference on Learning Representations, 2026. URL https://proceedings.iclr.cc/paper_files/paper/2026/hash/5c802ef38ab6e366c2ea06eee554c088-Abstract-Conference.html.arxiv.org/abs/2504.19874
  22. [22]Zhenyu Zhang, Ying Sheng, Tianyi Zhou, Tianlong Chen, Lianmin Zheng, Ruisi Cai, Zhao Song, Yuandong Tian, Christopher Ré, Clark Barrett, Zhangyang Wang, and Beidi Chen. H2O: Heavy-hitter oracle for efficient generative inference of large language models. In Advances in Neural Information Processing Systems, volume 36, 2023. URL https://proceedings.neurips.cc/paper_files/paper/2023/hash/6ceefa7b15572587b78ecfcebb2827f8-Abstract-Conference.html.DOI

Paper details

vlnc:W_84x4trpk
v1 · latestHistory (1)

published · Fresh — added to the Hub within the last 30 days

added ·

Usage

views · 2

downloads · 0

A view counts once per browser per day, a download each time the PDF is requested.

CC BY 4.0

Original source

  • Computer Science

generative AI tools · View statement →

Looking for related papers…
Contents