Manuscript Offprint
arXiv:2610.40943Kernel-based Interpolatory Methods for Context Compression of Attention Mechanisms
Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.
ABSTRACT
The bottleneck of attention mechanisms, which are the fundamental building block of modern language models, is their quadratic complexity in terms of context size. There has thus been an increasing interest in the compression of the context, also called KV-cache compression. In this article, we consider the problem of compressing the context of attention mechanisms by first formulating it in the Hilbert space associated with its kernel. In this formalism, attention can be represented as the ratio of two linear maps whose interpolant is also the ratio of interpolants, this allows us to consider the interpolation of the linear maps directly. We thus introduce two novel KV-cache compression methods which we call GAIM and Q-DAIM, based on the Generalized Empirical Interpolation Method (GEIM) and the Q-Discrete Empirical Interpolation Method (Q-DEIM), respectively. As the cost of these methods is quadratic in terms of context length, we propose surrogate models based on the Taylor series, the Performer and the Random Fourier Features method which allow the compression to be done in linear time. Finally, we extend this result to the streaming attention setting, providing new methods which allow one to penalize the selection of interpolation nodes based on the previously interpolated context and to update the previous interpolation based on new information. We then provide numerical results on the convergence of the residuals and the output error in future queries and preliminary results on the LongBench-E benchmark showing performance comparable to the state-of-the-art methods. These experiments suggest that the range revealed by our Q-DAIM method could help identify where information is concentrated in the KV cache, thus enabling an efficient compression.
1 Introduction
The attention mechanism, one of the main building blocks of the Transformer architecture [Vas+23], is based on functions that involve pairwise interactions of its inputs. Indeed, attention mechanisms are used to construct functions that can change depending on the context¹, given by their key and value matrices with . They are applied to an input known as a query vector . In the context of Large Language Models, this context corresponds to a set of tokens, sets of characters, and their associated query, key, and value vectors. The attention mechanism allows the models to encode the semantic information contained in the relationships of the input token with the context tokens. To do so, the rows of the key matrices, , are used to calculate a similarity between the input token's query vector and each contextual key, via a kernel function . This distribution of similarities over the keys is then normalised resulting in the normalised attention scores given by
¹For a more detailed description of attention in the context of LLMs, see [Ser26].
the softmax function
For each context token , the associated value row is weighted by the attention score associated with its key. The attention on a single query is then given by
where is the exponential kernel of the scaled dot-product.
However, computing the attention has a quadratic cost in the sequence length and, at inference time, requires caching the key and value embeddings of all past tokens. Attention is hence the main computational and memory bottleneck of modern Large Language Models (LLMs). Implementations such as FlashAttention [Dao+22; Dao23] compute attention exactly while reducing memory traffic; however, it still has a quadratic scaling. Ever since the rise of LLMs in the last few years, there has been heightened interest in the development of sub-quadratic approximations of the attention mechanism. The methods proposed come from several fields of research, ranging from clustering and sparsity [KKL20; Zan+23; Han+23; Hoo+25] to low-rank and subspace projection-based methods [Wan+20; Sin+24]. Recent works also used sketching and tensor decompositions [PP25] as well as kernel-based approximations, which replace the exponential kernel of attention with finite-dimensional features [Cho+22; KMZ24] or by Nyström approximations [Che+21; LLS24; SM26] of the attention scores. A classification of these methods through the lens of numerical analysis can be found in [Ser+26]. Other methods attempt to compress the KV cache of a pretrained model directly, removing tokens from the KV cache depending on their associated attention-score statistics, discrepancy measures, or following heuristics based on the norm of the key and value vectors [Zha+23; Li+24; Xia+24; Yan+24; Han+25b; Che+26]. The observation at the basis of our method is shared with the WildCat method [SM26], attention can be written as the ratio of two linear maps, and the orthogonal projections of these maps onto a well-chosen subspace provide an approximation of the attention mechanism. Indeed, formulated in the Reproducing Kernel Hilbert Space (RKHS), , of the exponential kernel underlying scaled dot-product attention, attention becomes a ratio of linear maps in the query feature ,
where denotes the linear map whose rows are the features . The numerator is given by the feature-value operator and the denominator by the feature-normalization operator . As they share their left factor , both are generated by the same key features and have ranges in the same -dimensional subspace of . They can thus be approximated jointly through the augmented operator , with the augmented value matrix.
Given a matrix of keys, let be the orthogonal projector onto and let be the weights such that . Projecting both linear maps yields the approximation
which WildCat [SM26] interprets as a Nyström-based approximation of the attention mechanism.
In this article, we adopt instead the point of view of interpolation. The rows of are the interpolation nodes, which play the role of the magic points of the generalized empirical interpolation method (GEIM) [MM13], is the basis space onto which we interpolate, and is the projection of onto , expressed in the node features. The pair then replaces as the compressed KV cache. Since and are interpolated on the same basis space, the ratio of their interpolants is the interpolant of their ratio: it reproduces attention exactly whenever the query is one of the interpolation nodes. The compression of attention thus divides into two tasks: the selection of nodes , which determines , and the projection of onto , which determines . The selection phase, described in §3.1.2 and §3.1.3, uses the information contained in the keys and the values, through , to choose the interpolation nodes that minimize a given residual norm. The natural residual is the worst-case attention error in the -norm, . However, this residual is nonlinear and very sensitive to small errors in the denominator. We therefore consider five variants of the attention residual, based on different approximations of . The projection phase, described in §3.2, is formalized as a Petrov-Galerkin problem: it computes the weights for which best approximates on a given test space , the orthogonal projection above being the Galerkin case .
However, classical empirical interpolation methods such as GEIM [MM13] or Q-DEIM [DG16; DS18] cannot be applied directly to this problem for three reasons. First, due to the infinite-dimensional nature of the RKHS, operators such as and features such as the rows of cannot be constructed explicitly, and hence the usual pivot-based matrix factorizations cannot, in general, be applied. We have to resort instead to methods relying on kernel evaluations rather than on the elements of . Second, the kernel norms of the keys, , span several orders of magnitude, so that the exponential kernel Gram matrices involved in the projection are ill-conditioned. Third, evaluating the exact residual and its updates through kernel evaluations has a cost quadratic in the number of keys, which defeats the purpose of compression.
Our main contribution is to introduce two KV-cache compression methods for attention interpolation that overcome these obstacles, being numerically stable and scaling linearly with the context size :
-
GAIM, a greedy selection in the style of GEIM [MM13; Mad+07], which greedily picks the interpolation nodes minimizing the -norm of the chosen residual, by selecting at each step the node with the largest current residual. It evaluates the augmented residual operator on the key features, and selects the row with the largest -norm as the next interpolation node and updates the residual through a rank-one update.
-
Q-DAIM, a Q-DEIM-based selection [DG16; DS18], which minimizes the -norm of the residual in the metric induced by the map using the orthogonal basis obtained through a CholeskyQR / Cholesky whitening of the augmented operator. It relies on a QR-like factorization , where is an orthonormal basis in of the range of , of rank , and . As cannot be constructed explicitly, we instead compute a Cholesky factorization of its Gram matrix, which only requires kernel evaluations, to obtain . The orthogonal operator onto the range of is then given by . By evaluating on the keys, , we obtain a matrix whose rows are the coordinates of the key features in the revealed range, then we select the nodes to be the pivots of a column-pivoted QR factorization of , which greedily maximizes the norm of the reconstructed basis of the revealed range. Additionally, the Q-DEIM interpolation operator then provides us with an alternative Petrov-Galerkin projection whose test space is given by the revealed range of .
In practice, both selections are carried out in the Gaussian reformulation described below. Both methods are designed for streaming attention, where the interpolation is applied on successive segments of the context as they come in, and where each interpolation can be improved by using information from previously interpolated segments. In §4, we decompose the interpolation over a stream into a four-stage process. An orthogonalization of the residual against a basis constructed from previously selected interpolation nodes, which we call deflation for brevity, the selection of new interpolation nodes, the projection of the values, and an optional update of the previously interpolated weights.
The contributions that make these methods numerically stable and computationally feasible are threefold.
(i.) A Gaussian-kernel and scaled key norm reformulation. §2 develops attention interpolation in the RKHS of the exponential kernel. To address the ill-conditioning of this formulation, we provide an exact Gaussian reformulation of the attention mechanism and highlight several of its invariants, namely query norm scaling, global key norm scaling, and global key translation. Combined, they separate the RKHS interpolation problem into two parts, a well-conditioned linear problem in translation-invariant Gaussian features and a kernel norm rescaling, which stabilizes our methods.
(ii.) Kernel-based selection and Petrov-Galerkin projections. Splitting the compression into selection and projection allows both phases to be carried out through kernel evaluations only. For the projection, we provide several alternative Petrov-Galerkin methods, which differ by their test space , and hence by the metric, based on the interpolation nodes , in which approximates .
(iii.) Finite-dimensional surrogate residuals. The exact residual and its update are costly, , to evaluate directly, where denotes the size of a segment. We therefore introduce finite-dimensional surrogate residuals based on finite-dimensional approximations of the exponential kernel's feature map. We namely consider feature maps constructed using the first-order Taylor approximation, Random Fourier Features [RR07] or from the Performer FAVOR+ features [Cho+22]. Due to the finite-dimensional nature of these maps, key features can be represented as matrices and this allows for a change in the order of operations that reduces the cost of selection and residual updates to . These surrogate residuals are used as alternative selection criterion for our magic points. However, to limit the approximation error, the projection step is still obtained through an exact Petrov-Galerkin projection of the operator on the chosen nodes, which costs on the order of for a single segment of size with a number of interpolation nodes proportional to , .
We provide a complexity analysis for segments of size with interpolation nodes per segment of our streaming interpolation methods in §4.3. We also provide a numerical study of our proposed interpolation methods in §5 on Qwen2.5-7B-Instruct [Qwe+25], in terms of the convergence of the residuals, of the attention error on future queries of the same text, and of the performance on the LongBench-E benchmark [Bai+24]. Overall, in a preliminary LongBench-E evaluation at 25% context compression, Q-DAIM obtains the best average score of all the methods we evaluated, retaining 87.1% of the score of the uncompressed model and slightly outperforming both GAIM and the RP-Cholesky selection of WildCat [SM26] implemented in the same framework. For this benchmark, we computed several variants of the model to isolate the impact of the different parameters of the methods on the result. We observe that a lower attention error does not necessarily translate into better benchmark scores, the selection of the interpolation nodes having a more decisive impact on performance than the projection. Interestingly, it appears that the revealed range of Q-DAIM provides both better selection and better projection performance than the GAIM or RP-Cholesky methods. Indeed, by looking at the variants where no projection is used, i.e. , Q-DAIM selection appears to outperform all other methods, and on the other hand the best performing variant on the most tasks for Q-DAIM is the one using the revealed-range projection, i.e. the Q-DEIM interpolation operator. This suggests that the range of the augmented operator revealed by Q-DAIM is a better indicator of the information retained by a method than the residuals and that the revealed range provides additional information which seems to not be accessible to the other methods. As the revealed range is only approximately reconstructed in this setting, being limited to vectors for its reconstruction but requiring the complete set of keys for a perfect reconstruction, this motivates future research for the direct reconstruction of .
The present work belongs to the kernel-based family of attention approximation methods and is most closely related to the WildCat method [SM26], which also approximates the augmented linear map similarly but whose selection uses a Randomly Pivoted Cholesky (RP-Cholesky) on the Gram matrix of the keys for a rescaled kernel. WildCat was also recently combined with the Thinformer approximation inside the causal Express wrapper of [Gon+26]. Compared to the WildCat [SM26] method, whose random selection is optimal to reconstruct the span of the keys in the Hilbert space , our method takes into account the value matrix and focuses on minimizing the residual of attention.
Notation
In the paper, we use the following notation. We write for the set of non-negative integers, , and for . We denote arbitrary vectors using and . We set and to denote the inner product and norm, and to be the vector of ones for any . For any matrix , we denote by its transpose and by the vector corresponding to its -th row, and we also set to be the pseudo-inverse. denotes the Frobenius norm and the trace of the matrix . Given a Hilbert space , we denote by and its associated inner product and norm. We denote using the notation the orthogonal projector onto a closed subspace , with . We also use by abuse of notation for a linear map to denote the orthogonal projector onto its row-space . For any feature map , we denote for any the mapped feature as . Occasionally, for clarity, we use Python notation to identify the matrix rows, columns and elements: is used to denote the entry in row and column , denotes the -th row and the -th column. More generally, given index sets and , we set to be the submatrix of composed of the rows indexed by and columns indexed by . We also set, when used in python notation, , for any with . For any , we set to be the diagonal matrix whose diagonal is given by the elements of . On the other hand, when used with a matrix , it corresponds to the diagonal of the matrix in . The Hadamard, or elementwise, product is denoted by . The exp and log functions are considered to be applied elementwise to vectors and matrices.
2.1 Attention as a ratio of two linear maps
As described in the context of the Nyström approximation used in WildCat method [SM26], the above formulation of attention (1) can be rewritten as the ratio of two linear maps through the kernel function . In our case, it is more useful to describe attention as a ratio of linear maps in the Reproducing Kernel Hilbert Space, , of by its explicit feature map, . Indeed, let , the RKHS associated to is given by , the direct sum of the Hilbert spaces of symmetric tensors [Com+08] of powers of . Its associated feature map, , relies on the Taylor expansion, given, for any , as
For any and any , we set . Then the feature map satisfying (2), is .
We remark here that any sum of features generated by is a direct sum of symmetric tensors of degree , one for each . We denote by the linear map whose rows are the vectors . Being bounded and of finite rank, is a Hilbert-Schmidt operator, which allows us to manipulate it as we would with a matrix. Attention can then be expressed as
where is the orthogonal projector onto in . As already mentioned in the introduction, the attention is thus a ratio of two linear maps of , both of which act on the same -dimensional subspace of , determined by the key vectors. Consider the two following sets of elements of constructed from , the elements of the first consists in the feature map of a sum of vectors while those of the second consists of a sum of feature maps.
The first set is a submanifold while the second is a vector subspace, and they only match on the feature maps of the keys themselves. Indeed, is differentiable, injective, and a homeomorphism over using the restriction of the feature map to .
Proposition 1. Let , with distinct and nonzero rows. Then the intersection of the two sets is given by
The proof, given in Appendix A, relies on the following lemma.
Lemma 1. For any and any , . Furthermore, let , , and for , with pairwise distinct . Then, for every , the truncated features , , are linearly independent and thus .
The proof of Lemma 1 is also given in Appendix A.
The consequence we shall use is that the only elements of which coincide with the actual feature map of a vector of are in the keys themselves.
2.2 Interpolating attention
We are interested in interpolating attention on a given reduced set of key vectors. Let with be a matrix formed by a set of key vectors, whose rows we call the interpolation nodes, or magic points, onto which we wish to interpolate the map , and let be the operator with rows . The reduced set of key features then span the basis space onto which we interpolate, i.e.
With the convention that and
We now discuss an approach for interpolating the attention on this reduced set of keys. For any with , we can insert , the orthogonal projector onto , into (3) without changing its value,
and by Proposition 1 the nodes are the only queries for which . The interpolation equality thus holds exactly at the nodes, although it may also hold at other queries, as attention only depends on through its projection onto , which may lie in even when does not. For any two matrices and , we define
where the element of the matrix in the i-th row and the j-th column is denoted using square brackets and where the exponential is applied entrywise, we obtain,
Hence, for a given , we have (using a similar method to the one used in [SM26]) that the associated interpolated value vector and the normalization weight are the solutions to the following equations
Setting , and assuming is invertible, we can write, for simplicity, the solution to be
Indeed, as the numerator and denominator share their left factor , we use a single basis space for the interpolation of both the numerator and denominator by considering the joint augmented interpolation problem given by
The interpolant of attention on is then given by
Hence, the interpolant of the attention mechanism is the ratio of the interpolants of the two linear maps.
The residual we ideally want to minimise in the context of interpolation is the maximum error in norm over all possible queries ,
We note that, contrary to the exact denominator, the interpolated denominator is not guaranteed to be positive and may be equal to zero for some queries. In that case has a pole and is infinite, we introduce a mean vector approximation in § 4.1.1 to reduce the impact of this problem.
Remark 1. To identify the sources of the interpolation error between and , we first decompose onto the and its orthogonal complement by writing . Next, we look at the projection onto and its complement given by
The first terms of both equations, (6) and (7), correspond to the part of the vector in that is correctly reconstructed for the respective projections onto and its complement, and their sum is equal to . On the other hand, the second terms correspond to the part of the vector in which is sent onto by the projections and their sum equals zero, i.e. one is the correction to the other. As (7) corresponds to , its terms represent how aligned or misaligned the two subspaces are. When is formed from the rows of , we have that . In that case, we have the inclusion and the misalignment terms vanish leaving the remaining first terms in (6) and respectively (7) to represent the projectors onto the intersection and the orthogonal difference . We are thus left with
In the context of this article, we restrict the selection to vectors based on the rows of for the interpolation nodes.
2.3 Invariants of attention
However, the linear problem (4) is extremely ill-conditioned and computing its numerical solution is therefore very unstable. Indeed, the RKHS norms of the keys vary by orders of magnitude, resulting in ill-conditioned and matrices. However, using the invariants of the attention mechanism, we can solve an equivalent but better-conditioned problem through a Gaussian kernel formulation.
In this subsection, we consider three invariants of the attention mechanism and describe a Gaussian kernel reformulation of the attention mechanism (§2.4). We then show that recentering the keys (13), also used in WildCat [SM26], gives us an additional degree of freedom and finally combine these results in §2.4.1 to improve the conditioning of the interpolation procedure.
Proposition 2 (Invariants of attention). Consider , and .
(i.) Query kernel-norm scaling: Given , the attention as defined in (3) is invariant under the transform . Attention thus depends only on the direction of in , not on its magnitude.
(ii.) Global key mass scaling: Given , the attention output is invariant under the rescaling of every key feature by the same , i.e. for all .
(iii.) Global key translation: For any , the attention output is invariant under the translation for all , i.e. .
The proof is given in Appendix A. Each of these properties of attention allows us to consider for our interpolation a chosen representative of the 'equivalence' class they create.
I. Kernel-normalized queries. As we approximate the ratio of linear maps by a ratio of two interpolated linear maps, we can restrict ourselves to kernel-normalized query vectors to reproduce the effect of attention, simplifying our Gaussian kernel reformulation in §2.4.
II. Key normalization gauge. As attention is invariant by a global rescaling of the kernel norms of the keys, , only their ratios as defined later in equation (15) carry information. In §2.4 we use this to define the max-normalised gauge which allows us to restrict the numerical range of all kernel norms ( to , and hence their logarithms, the shifted scaled squared norms ()/(2), to .
III. Key centering gauge. As attention is invariant to the translation of the keys by a same vector, the keys can be recentered. In (14), we consider the mean of the key vectors as the origin, allowing us to reduce the spread of the mass ratios.
Query translation, on the other hand, does change the output of attention (otherwise, it would be constant).
Proposition 3 (Query translation). Given , the effect of a translation of on the output of attention is given by
where we set .
2.4 Gaussian formulation and centering of the keys
The main tool that allows us to make use of these invariants is the reformulation of attention using the Gaussian kernel. We denote the Gaussian kernel (or Radial Basis Function kernel) by ; we denote with the breve symbol the objects attached to this Gaussian kernel. For any , the exponential kernel can be rewritten as
³Note however that this does not imply any restriction on the norm of . Indeed, the only kernel-normalized vector of is . In the Gaussian rewriting §2.4, this corresponds to restricting ourselves to the directional vectors given by the Gaussian feature map .
This can equivalently be expressed by defining the Gaussian feature map , such that, for any , we have . As discussed later, a useful property of this reformulation is that it separates the norm , and direction , of the exponential kernel features . Then, for any Gaussian kernel evaluations on the matrices and , we set
where we denote the element of the matrix in the i-th row and j-th column using square brackets. The Gaussian gram matrix can hence be related to the exponential kernel one as
where we set, for any , , abbreviated when no ambiguity arises. With the operator with rows for any , we obtain
We also obtain for the interpolation,
Hence, the interpolated weights (5) are given as
Furthermore, due to invariant (ii.) and Gaussian formulation, we can replace in Equation (10) by its -normalisation, which we denote as
The global key translation invariance (iii) of Proposition 2 represents an additional degree of freedom for interpolation. As we have seen before, the Gaussian formulation allows us to separate into its norm from the direction given by the feature map , i.e. the normalised vector in the RKHS. Due to the translation invariance of the Gaussian kernel, only the norm of the keys depends on the recentering.
Proposition 4 (Gram matrices for translated keys). For any , and any , we have and hence
where is defined as in Proposition 3 and we set
The proof is given in Appendix A. In our case, this leads to the following,
Comparing and , we see that the effect of recentering on the ratio of norms is given by
We note that instead of being exact at the chosen keys, the interpolation is exact at the translated nodes .
Proposition 5 (Interpolation with translated keys). Given , the interpolation of attention on -translated keys gives
The interpolation is hence exact at the translated nodes , , whose features are the only points of in the interpolation basis, and the interpolation basis is
Translation invariance is in particular recovered when .
The proof is given in Appendix A. Let us now consider which point of origin we want to choose. As we have seen above, the selection of the centering point only affects the distribution of the scaled squared norms, for . Therefore, for stability, our choice is to minimize the sum of the scaled squared norms, in general improving the conditioning of the problem while making the norms of the vectors more comparable by concentrating the distribution of the norm of the keys. Indeed, as the Gaussian Gram matrix is constructed from normalised vectors and the Gaussian scalar product decreases exponentially fast with distance, the conditioning of the problem depends mainly on the matrices. Similarly to [SM26], we choose to recenter the key vectors on the mean vector
This choice of the center is motivated by the fact that, as the mean of the key distribution, it minimizes the sum of squared distances , and thus the sum of the scaled squared norms, . We note however that this does not in general minimize the spread of these norms, which may increase after centering for particular distributions of the keys.
2.4.1 Stabilizing interpolation through the Gaussian formulation and centering of the keys
The Gaussian reformulation described in §2.4 and the centering of the key vectors with respect to the mean described in equation (14) now allow us to construct a better conditioned linear system equivalent to equation (4). As discussed above, the Gaussian kernel matrices and are in general much better conditioned than their exponential counterparts (as shown in Appendix D). This means that the ill-conditioning is almost entirely due to the matrices and , whose conditioning depends only on the spread of the scaled squared norms of the keys, for . We now look at how the invariants allow us to stabilize the problem. Let and be the gauged norms, which we will refer to as masses, of the centered interpolation nodes and keys,
both evaluated in log space. Then, the augmented Galerkin weights (11) can be obtained by the two-step solve and scale method
Then, the interpolated attention on is given by
where we note that the second equality uses and not . The masses of the nodes are kept bounded in thanks to the formulation, the Gaussian kernel matrix has in general a moderate condition number (see Appendix D) and the right hand side's rescaling is controlled thanks to the mean recentering. From now on, unless otherwise specified, we will consider the problems in the -centered context and drop the . Note also that is remultiplied by after the solve, rescaling it to be in the same gauge as . Indeed, as the two terms in Eq.(15) share their denominators, the gauge is cancelled by construction. While having different denominators would have no impact on the interpolated attention output, it would affect the scaling of the resulting interpolated value matrix. We choose to keep it comparable to , notably for range correction which is described in §4.1.1.
Remark 2 (Clustering the data). When the data is distributed in clusters, even for example as a mixture of Gaussians, the conditioning of the problem can then be heavily impacted through the renormalised masses . Partitioning the nodes into clusters and anchoring each at its own mean combined with a separate solve on each cluster would provide a way to take this issue into account. As we shall see in §4, the recombination is similar to what we already do in the context of streaming attention for each successive segment, the content-based clustering is left as future work.
Hence, while the key centering can be seen as a hyperparameter which allows us to select our exactness set through , it also affects our capacity to solve the interpolation problem and we will restrict ourselves to the -centering in the rest of this article. Indeed, while equivalent in exact arithmetic, the origin centering would require too much precision due to the redundant linear term while the mean centering keeps every direction resolvable (14). Furthermore, the mean centering allows to have an interpolation basis which may be more representative of the future queries as they tend to not align exactly with the keys.
3 Empirical interpolation in infinite-dimensional spaces
As discussed in the previous section, interpolation can be divided into two distinct but connected tasks, the Selection of the basis keys, i.e. constructing a basis space , and the Projection of the augmented linear map onto it, i.e. approximating through a Petrov-Galerkin Projection by minimising the residual on a test space that is potentially different from .
3.1 Basis selection
The selection chooses the basis space of the RKHS, as previously described in §2.2. Projection determines the linear operator that maps the input (projected onto the basis), and thus the output space. In this section, we first define the residual operators and error terms (§3.1.1), and present two selectors:
-
The GAIM selector in §3.1.2 is based on greedily selecting one after the other the interpolation nodes with the highest residuals in the norm, iteratively removing the components with the highest error in any output dimension, following the GEIM method [MM13]. We also provide an norm alternative that chooses the directions that minimize the sum of squared errors.
-
The Q-DAIM selector in §3.1.3 is based on the Q-DEIM [DS18; DG16] method which reframes the formulation of the residual minimization problem in the metric induced by the linear map. This is done by constructing an orthogonal basis for the linear map through either a CholeskyQR [SW02] or through the Singular Value Decomposition, a method known in the data-science literature as Cholesky or PCA whitening respectively [KLS18]. The algorithm then selects nodes to maximise the volume of the approximation in the obtained basis.
We also present an approach for taking into account multiple query heads in norm using a multi-head scoring metric in §3.1.4. Finally, we present approximate finite-dimensional surrogates for the computation of the residuals that allow a linear complexity in terms of context size in §3.1.5 and thus allow for the compression of longer contexts. Let us now take a look at the residuals we want to minimize.
3.1.1 Approximation of the residual error
Consider the numerator and denominator of the attention output that we denote and , where we set and . The ratio is therefore determined by applying the combined augmented linear operator to , this operator is defined as
For interpolated attention, we denote and similarly, where . We can then write that
Using and the weights (5), the decomposition (8) splits into its component in the basis space and its orthogonal complement in ,
We call the augmented residual operator. Indeed, the residual error of g and h due to the interpolation method are given by the first d columns and the last column of respectively. The residual error is then given by
The residual error on the attention output is then obtained as
This admits the closed form
This formulation allows the usage of the residual given in (19) for interpolation. Indeed, each of the three terms depends only on the query through the prefactor and is linear in , and , respectively. Hence, for any new node , we can update the residual to the new set using rank-1 updates of and . Indeed, let be the projection of the new node on and set , the scalar product in restricted to . The norm of is given by the norm of . Then the projection onto is given by and we have
At a query , the updates to the three blocks are then obtained through the scalar
where we note that the values that need to be computed are the evaluations of
Hence, , and can be updated separately for each rank-one extension of , which is what makes our GEIM-based greedy selection computationally feasible. We note that the above quantities cannot be computed through , which lives in . They are thus obtained through kernel evaluations and projected through either the inverse of the node or using a solve from its Cholesky factorization. Thus, we keep in memory either the inverse or a Cholesky factorization of the Gram matrix for the projection step. With the addition of a new node , we therefore use a rank-1 update for the addition of the new border
Setting and the Cholesky factorization, we can write
both at cost in memory per node. We note that in practice, the computations are done using the Gaussian formulation from equation (9), which gives the following.
Thus, we can compute using the same formulae as the evaluations replaced by their Gaussian counterparts and . A useful corollary is that the term can then be used to determine the collinearity of a new node in the selection loop.
The residual is composed of three terms, associated with the linear residual of the numerator , corresponding to the linear effect of the residual of the denominator on the error and the prefactor that corresponds to the multiplicative effect related to the interpolated denominator. For our method, we consider five variants of the residual combining these terms:
(v1.) The value residual ,
(v2.) the unnormalised error residual ,
(v3.) the full residual ,
(v4.) the -normalised full residual , replacing the denominator by its exact value,
(v5.) and the augmented-moment residual , which corresponds to the residual of the interpolation map itself.
We also consider two possible norms, and , the first one more suited to the GEIM-inspired method and the second one to the Q-DEIM method of the next subsection.
3.1.2 Greedy selection of the magic points by GEIM
Following the generalized empirical interpolation method [MM13] (and the original empirical interpolation method), we construct by greedily selecting the nodes from a dictionary of vectors that iteratively best minimize one of the residual variants v1-v5, evaluated at the Gaussian directions of the keys, . We name this the greedy attention interpolation method (GAIM). In this paper, we restrict the dictionary to the rows of , which allows the error to be restricted to , as mentioned in § 2.2.
In practice, while we choose our dictionary of possible directions as the set of keys itself, it should be noted that any arbitrary set of vectors of may be chosen for this method. Furthermore, one might ideally want to obtain the vector in maximizing the residual. However, constructing such a vector often requires access to all the keys as we can only reconstruct it through the feature map .
Let , where are the gauged masses defined in (12). We consider the -gauged augmented operator and residual operator equivalent to (18),
Thus, in the following proposition, every residual score is expressed in the gauge.
Proposition 6 (Residual scores). Let be the projection onto the orthogonal complement of of the Gaussian Gram matrix . Then and for every , the residual of the linear map evaluated on the keys is given by
The proof is given in Appendix A. Then every residual variant can be assembled from , and from , the evaluation of the augmented operator on the keys. Indeed, the row of these matrices gives us
Hence, we can update , and , at a cost per pick.
Let be the matrix of the chosen residual variant and the norm , the next node is obtained using
where for simplicity, we denote, for any and , by the concatenation of the vector at the end of . We note that, similarly to GEIM, this is a greedy method which selects the node with the largest current residual, which is not guaranteed to be the optimal selection to reduce the residual. Indeed, for the Galerkin residual, adding the key decreases by .
In practice, we note that for the pairing the addition of the denominator column does not seem to work well with the infinity norm.
Algorithm 1 Exact-kernel greedy GAIM selection
Require: keys , values , budget , residual variant , norm , collinearity floor
1:
2: and residual rows at
3: for do
4: Update from \quad chosen residual variant, §3.1.2
5: \quad selection in chosen norm
6: \quad Schur complement column, collinearity check
7: \quad Orthogonalisation
8: Grow by the border of with pivot \quad rank-1 bordered update, §3.1.1
9: end for
10: return nodes , inverse
The exact-kernel selection loop is summarized in Algorithm 1. The rank-1 residual updates, computed for using (20), have only a linear cost in . The overall complexity is therefore of order . Indeed, we only maintain the residual rows and , although at the cost of keeping the matrix in memory. The quadratic cost of the method comes from the initialization of which requires computing and hence the scalar product between each pair of keys for a total of kernel evaluations.
3.1.3 Greedy selection by rank-revealed Q-DEIM
While the GAIM method greedily minimizes the residual for any given norm, the Q-DEIM-based Attention Interpolation Method (Q-DAIM) only targets the residual in the norm , similar to Q-DEIM [DG16]. To do so, instead of considering the residual in its original space, we consider the Cholesky-whitened [KLS18] counterpart of the augmented operator, i.e. the orthogonal projector onto the range of obtained through a CholeskyQR. Then we follow the Q-DEIM methodology and iteratively choose our nodes greedily to maximize the volume spanned in the orthogonal basis, i.e. we choose the keys having the highest overlap with the basis vectors via the pivots of a greedily pivoted QR (or for more stability a rank-revealing pivoted QR with theoretical guarantees). Furthermore, as we have the projection of the keys in an orthogonal basis, compared to the GAIM method, there is no need to compute for the orthogonalisation procedure of the operator and all nodes can be selected sequentially without having to update a factorisation of the Gram matrix . However, this comes at the cost of only being able to consider linear residuals, thus being restricted to v1 and v5. Note that we use this method on the Gaussian formulation of the problem from (10), allowing it to take into account the metric induced by both and by the mass ratios , resulting in a better conditioned problem.
Let us now look at how we implement this in the context of attention. As mentioned before, we wish to find the orthogonal projector onto the range of . As the augmented operator has rank bounded by , the range of is a subspace of of dimension and there exists a decomposition
where is an isometry whose columns span the range of , and . Ideally, we would obtain this decomposition from a rank-revealing QR decomposition of . However, due to the infinite-dimensional nature of the problem, we will need to resort to alternative formulations to use .
To obtain the factorisation, we consider a method known as whitening [KLS18], which groups CholeskyQR-like [Hig90] methods where, given the Gram matrix
we compute a factorization with permutations and apply the (pseudo)-inverse of to to obtain . Indeed, is symmetric and positive semi-definite as the Gram of the column 'vectors' of , furthermore its rank is upper bounded by . To obtain , we thus consider a rank-revealing diagonally pivoted Cholesky [Hig90] where we pivot on the largest remaining element on the diagonal of the residual, and stop when it falls below times the largest diagonal entry of . Then, the whitened coefficient matrix is given by
This then gives us the orthogonal operator
We note that the identities and hold when the Cholesky factorization reveals the exact rank of . When the factorization is stopped earlier, we instead have with , such that . In this case is only approximately orthonormal. An exactly orthonormal basis can then be recovered from the pivoted columns only, , where denotes the leading block of . An error is then introduced due to the truncation procedure, it corresponds to .
In practice, since is of size , the rank revealed by the Cholesky factorization always satisfies . When the budget is small and we have , for a chosen oversampling , we stop the Cholesky factorization at , even if the threshold has not yet been reached, in which case is only approximately orthonormal, as noted above. Furthermore, while it might seem reasonable to take small thresholds, this can sometimes amplify noise as each vector in the revealed range provides an equal weight in the selection criterion. We also note that any alternative square-root of may be used for the whitening, the most relevant alternative consisting in directly computing the counterpart to obtained from the eigendecomposition of .
Compared to the unwhitened selection of GAIM. Q-DAIM appears to be less sensitive to the keys with the largest kernel norms which tend to monopolize the pivots in GAIM. In the same manner, applying the method with the augmented value matrix (i.e. v5.) is also impactful, as it allows the map of the denominator to be taken into account in the metric.
For the selection procedure, we consider the projection of the key vectors onto the range of ,
and a column-pivoted QR (Businger-Golub [BG65]) is applied to . We set to be the indices of the selected pivots such that . However, when the node budget , the column-pivoted QR described above only gives us at most informative pivots, the remaining selections being chosen on numerical noise. Hence, for budgets , we consider optional restart procedures, as described in Appendix E.
An alternative to the fixed number of selected nodes for interpolation is to instead consider keeping pivots as long as the addition of a new pivot improves the reconstruction above a certain threshold, i.e. keep pivots only while , where denotes the remaining norm of the -th pivot of the QR-CP of , or alternatively while the relative operator energy missed by the nodes remains above a threshold.
Finally, our Q-DAIM interpolant is then given by the oblique projection
where we use for the pseudo-inverse. We note that has rank at most . Hence, when , it does not project onto the whole basis space but only onto a subspace of of dimension at most , the pseudo-inverse selecting the minimum-norm coefficients. Furthermore, as its test space differs from , this projection is in general not exact at the interpolation nodes, but instead at the projections of their features onto , i.e. for all .
We note that an improvement to our implementation would be the use of randomisation-based QR methods suited to the case . Such methods include randomised methods preserving rank-revealing properties such as [FG26] and recent methods specifically suitable for the Q-DEIM method such as [CK26].
The full Q-DAIM batch selector is summarised in Algorithm 2. Similarly to the GAIM method, the Q-DAIM selector also has a complexity in due to the construction of the Gram matrix .
3.1.4 Multi-headed weighted residuals
One issue that arises in the context of multi-headed attention is that the attention residual for a key head does not take into account the attention residual summed over the query heads. Given query heads, we set
Note that, writing for the usual DEIM operator on , the operator we use for the interpolation is thus the adjoint of the usual DEIM operator, i.e. . Indeed, this arises because in the classical DEIM method the convention is for multiplication to occur on the right, i.e. given , the transposed equivalent to our operator , and a pivoting matrix , Q-DEIM approximates as . Whereas we apply multiplication on the left, , but the method is the same in both cases, we project the input, in our case, onto the reduced basis determined by the pivots.
Algorithm 2 Batch Q-DAIM selection
Require: keys (centered), values , budget , oversampling , Cholesky tolerance , linear residual variant (v1. or v5. of §3.1.2)
1:
2: (v1.), or (v5.)
3: operator Gram (22)
4: rank-revealing factorisation
5: whitened coefficients (23)
6: evaluation matrix (24)
7: or volume-thresholded stop, see the remark above
8: weights: any projection of §3.2
to be the output of query head and the associated output projection matrix . The output of a single layer of attention is given by . Under grouped-query attention (GQA) [Ain+23] the query heads share key-value heads through a surjection such that
In practice, as we shall see in § 4, we interpolate on different nodes for each head, hence the output error of -th head is given by the sum of query heads of its group, i.e. heads such that .
For an norm residual, we can take this into account by weighting the output dimensions of through the Cholesky factor
given an error term shared by the group. We note that, as the query heads of a group have different errors and the output error contains cross terms between heads, this weighting is a proxy for the error of the layer output rather than its exact value. We thus reweight the value columns of the residual by , scoring in place of (21). Two things to note, first is that this method can only be applied to the norm, and that as it does not change the range, it is only applicable to GAIM. Second, each only needs to be computed once at initialisation as it only depends on the head and the model being used.
3.1.5 The finite-dimensional surrogate
The main bottleneck of both the GAIM and Q-DAIM methods resides in the quadratic cost of the computation of the Gram matrix . As we multiply it by afterwards, if the attention was linear, a simple matrix product reordering would allow us to go from . To enable this re-ordering, we resort to approximating using finite feature maps , with . Indeed, as we know that carries some important information for the selection of key nodes, we choose to preserve it. Set and the feature matrices and , and then, our method consists in replacing
and equivalently for their transposes. In practice we consider three main methods to obtain such a :
-
The linear Taylor map , corresponding to the first order Taylor approximation of ,
-
the Performer FAVOR+ randomised feature map [Cho+22] approximating ,
-
and the Random Fourier Features [RR07] which approximates the Gaussian kernel directly.
For the GAIM method, we consider the linear-Taylor map and the Performer method, whereas for the Q-DAIM method, we use the random Fourier features for the Gaussian matrix which approximate the Gaussian gram directly. For clarity, we denote by , these features, and the approximation thus reads .
We use for both dimensions for simplicity, see [Ser+26] for more details on multi-headed attention
Algorithm 3 Surrogate greedy GAIM selection : GAIM-LIN
Require: keys , values , budget , feature map , residual variant , norm
1:
2: \quad \triangleright normalised features and moment
3: \quad \triangleright evaluations and residual rows at
4: for do
5: Update from \quad \triangleright chosen variant, §3.1.2
6: \quad \triangleright deflation of the moment, updated residual rows
7: end for
8: return \quad \triangleright weights: any projection of §3.2
GAIM linear-complexity surrogates. For each residual operator described in §3.1.1, we write for their finite-dimensional surrogate operator, obtained through substitution as in (25), thus we obtain
We introduce a first variant GAIM-LIN-O, where we compute the residual operators using the -orthogonal projection of the map, and substitute in the same way as above,
where is the gauged Galerkin solution of (16). However, this -orthogonal surrogate requires the computation of the cross-Gram and Gram matrices, and , as well as the inverse of the latter. To avoid this, we define a second variant whose residual operators are given as
where is the orthogonal projector onto . To approximate this, we consider a Matching Pursuit approach similar to [PRK93; Dav97; TGS06], which we call GAIM-LIN, where after each greedy selection indexed by for the chosen residual, we set instead
orthogonalizing the residual only with respect to the last selection.
Q-DAIM Random Fourier Features linear complexity surrogate. We tackle the quadratic cost of Q-DAIM by building a surrogate Gram matrix which allows changing the order of multiplication and computing first. We use the notation for the Random Fourier Feature map to highlight the fact that the feature map approximates the Gaussian features directly and thus does not require renormalization through . This then gives us
G_{\check{\psi}} := M_{\psi}^{\top} M_{\check{\psi}} = V_{\eta}^{\mathrm{aug}}^{\top} \check{K}_{\check{\psi}}^{\top} V_{\eta}^{\mathrm{aug}} \in \mathbb{R}^{(d+1) \times (d+1)}.The surrogate Gram is still positive semi-definite regardless of , and the remaining Q-DAIM procedure, whitening followed by selection of nodes based on QRCP pivots, remains unchanged. In particular, the rank-revealing pivoted Cholesky factorization used for whitening (23) is now applied to instead of . The evaluation matrix (24) is formed similarly through as
with and . Hence, the overall complexity is reduced from to , the second term coming from the surrogate Gram .
3.2 Alternative projections
The methods we have developed above all possess a natural associated projection, i.e., a way to construct , used to actually select the nodes. As we shall see, each of these methods can be classified as a specific case of a Petrov-Galerkin projection. Indeed, Petrov-Galerkin methods approximate a continuous operator in a space by an
| Projection method | |||
|---|---|---|---|
| GAIM | |||
| PG least squares | |||
| Q-DAIM revealed-range | |||
| Least squares | - | ||
| WildCat scaling |
Table 1: Matrices and projectors associated with the different projection methods.
operator defined in a finite-dimensional subspace, , of functions called the trial space, which corresponds to our basis space . The approximated operator is then obtained by choosing a set of functions , called the test space, and its associated norm in which the residual is minimized.
In the case of direct interpolation/GAIM, the approximated linear map is obtained by setting the residual to zero at the interpolation nodes. This corresponds to a Bubnov-Galerkin method, as we test the function on the basis space and consider the orthogonal projection of our linear maps onto the basis space. For Q-DAIM, the test space corresponds to the projection of on the revealed range of the operator, i.e., , which coincides with only if , which requires .
The above methods can equivalently be seen as orthogonality constraints. On the other hand, the least-square approximation consists in a case where the test space contains directions orthogonal to the trial space, i.e. , and where the dimensions of and may not match. In our case, it is overdetermined. To handle this as an orthogonality constraint, we consider the least-square Petrov-Galerkin consisting in solving the orthogonality constraints arising from the normal equations instead.
Finally, we also consider the projection obtained by a direct minimization of the overdetermined system's residual. We note that, while this projection and the least-square Petrov-Galerkin coincide in exact arithmetic, their numerical solutions need not be the same, the normal equations squaring the condition number of the system. In the following we describe in more detail these different types of projection. We now formalise how these methods can be framed as Galerkin approximations of , the gauged augmented operator, on the trial space .
Let be a symmetric positive semi-definite operator acting on . The Petrov-Galerkin projection finds such that the residual is -orthogonal to , i.e.
where we set . The solution is obtained by solving the linear system,
The projected weights are then obtained by
The projection methods correspond to the following choices of , where we set and the projector onto . We provide the equivalent linear systems for each projection method in Table 1, as well as the formulation of the WildCat [SM26] temperature-scaled projection in the context of Petrov-Galerkin, more details can be found in Appendix B. We note that, for the Q-DAIM and WildCat rows of the table, the column gives the associated oblique projectors and , which are not symmetric. These projections correspond to Petrov-Galerkin methods with distinct trial and test spaces rather than to a symmetric positive semi-definite . Furthermore, the solution of (26) is unique only when is nonsingular.
3.3 Positioning with respect to kernel-based selection methods
We now discuss how our two selectors relate to WildCat [SM26] and, more generally, to greedy kernel interpolation methods [WSH21; WSH23]. WildCat selects its nodes through a randomly pivoted Cholesky [ETW25] of the key Gram matrix alone, i.e. the next node is sampled with probability . Hence, it aims at reconstructing the span of and does not take into account the effect of on the interpolated output. In the context of kernel interpolation methods [DSW05; SH17], this corresponds to a randomized version of a -greedy method, setting the power function . Similarly, Q-DAIM can be seen as a -greedy method for the revealed-range projection norm , which to our knowledge has not been studied in the context of kernel interpolation. GAIM, on the other hand, corresponds to what is referred to as an -greedy method in the case of linear variants based on and . Note, however, that the convergence theory of the greedy kernel methods concerns the interpolation of functions of the native space, here and , whereas the error on attention itself is only related to them through (19). As our method consists in considering the ratio of two such interpolants, we have the following rudimentary bound
where we set to be the Hilbert-Schmidt norm of the numerator residual operator. We leave a more detailed analysis of the error bounds for future work.
4 Interpolation for streaming attention
The interpolation methods we have defined above consider a fixed number of tokens and associated and matrices to be compressed. In modern attention-based language models, each layer of the model contains a multi-headed attention mechanism. For each of these heads of attention, the key and value vectors for the text that has been seen until a given moment in time are stored in memory to allow faster computation once a new sentence is provided to, or generated by, the model. This is known as KV caching. Once the input context is read, the key and value vectors of a given token impact the construction of the query, key and values of subsequent tokens in the same head. Additionally, as the layers are sequential, a given token's key and value vector also affects all the layers that follow.
We therefore choose to read the context in segments of tokens and alternate two steps. First, the model is computed on the new segment using the compressed cache. Then, we compress the keys and values produced by the model using one of our methods. Beyond the first layer, the keys and values of a segment thus depend on the compressed attention of the previous layers and the errors due to the interpolation of the previous segments propagate both to the generation and compression of the vectors of the layers that follow. Only the first segment's key and value matrices are generated using exact attention. For each layer and head, the cache thus holds, after tokens have been read and compressed:
-
fixed sink tokens at the beginning of the context, kept uncompressed;
-
recent tokens, corresponding to the last tokens read, kept uncompressed;
-
the key nodes and associated weights corresponding to the compressed tokens in between.
After a new sentence's key and values vectors are computed, its keys and values are appended to the cache. The last of these new vectors form the new recent window and the other remaining vectors correspond to the segment which, once it reaches a given size , is then compressed into nodes, for every layer and head at once. Once the context has been read, the generated tokens are appended raw to , and are not compressed.
Although the compression of the first segment is done using the exact same process as before, once a set and have been instantiated, we slightly modify the interpolation process to take into account the compressed data. In order to preserve the coherence of the interpolation between the different segments, i.e. the impact of the previous segments on the compression of a new one, we consider two additional steps to the interpolation's selection and projection, an orthogonalisation step based on the compressed cache which we call the deflation step, and an associated weight update step on previous nodes after projection which we call the refit step. Additionally, the centering of the keys needs to be refined, since the mean of the keys changes as new segments are added.
4.1 Bridging the gap between global and local interpolation
Let be the key and value matrices of a given segment that we will compress into nodes and associated weights and let , with , be the previously compressed nodes and weights . Then, we can interpolate the segment using the selection and projection techniques
Table 2: Modified matrices for each deflation type.
| Deflation | ||||
|---|---|---|---|---|
| None | V_{\mathrm{seg}}^{\mathrm{aug}}^{\top} \check{E}_{K_{\mathrm{seg}}K_{\mathrm{seg}}} V_{\mathrm{seg}}^{\mathrm{aug}} | |||
| Basis | V_{\mathrm{seg}}^{\mathrm{aug}}^{\top} \check{S}_{L} V_{\mathrm{seg}}^{\mathrm{aug}} | |||
| Range | V_{\mathrm{seg}}^{\mathrm{aug}}^{\top} \check{S}_{U} V_{\mathrm{seg}}^{\mathrm{aug}} |
defined in the fixed context case, with some optional modifications, based on the previously selected nodes, which allow to reduce the gap between the global and segment interpolation. The first consideration to take into account is the centering of the keys. Indeed, the mean key vector is not fixed in the context of the streaming attention, and we thus define two alternatives for the interpolation centering:
-
Global centering: Set the mean of the current global, sinkless, context.
-
Segment centering: Set the mean of the current segment.
Once this is fixed, along with the choice of selection and projection method, we modify the selection method to remove the redundancy with the historical nodes through a deflation method. In the same way as the basis deflation that is used after the selection of a node, this consists in considering only the part of the residual orthogonal to a given span in . We consider either the revealed span, through , or the selected nodes, via , subtracting the part of the residual explained by the historical nodes/linear map. Note that, in the rest of this section, every object (masses, values and weights) is handled in the gauge of (12); we drop the subscripts for simplicity. This results in two types of deflation which can be obtained as
- Basis deflation : For any selection method, we consider the projection onto the orthogonal complement of the basis space , obtained as
The Gram matrix is then replaced by its orthogonal projection, the deflated Gram matrix given by
- Range deflation : For any selection method, we consider its projection onto the orthogonal complement of , obtained as
where G_{L} = W^{\mathrm{aug}}^{\top} \check{E}_{LL} W^{\mathrm{aug}} \in \mathbb{R}^{(d+1) \times (d+1)}. This gives us the deflated Gram matrix,
\check{S}_{U} = \check{K}_{\mathrm{seg},\phi} \Pi_{U}^{\perp} \check{K}_{\mathrm{seg},\phi}^{\top} = \check{E}_{K_{\mathrm{seg}} K_{\mathrm{seg}}} - \check{E}_{K_{\mathrm{seg}}} W^{\mathrm{aug}} G_{L}^{\dagger} W^{\mathrm{aug}}^{\top} \check{E}_{LK_{\mathrm{seg}}},In practice, the range deflation may also be computed using the Cholesky/eigendecomposition of in the same way as the Q-DAIM deflation, i.e. through with . Furthermore, instead of being recomputed from and , the matrix can be updated for each new segment as,
G_{[L \cup L_{\mathrm{seg}}]} = G_L + G_{L_{\mathrm{seg}}} + W^{\mathrm{aug}}^{\top} \check{E}_{LL_{\mathrm{seg}}} W_{\mathrm{seg}}^{\mathrm{aug}} + W_{\mathrm{seg}}^{\mathrm{aug}}^{\top} \check{E}_{L_{\mathrm{seg}}} L W^{\mathrm{aug}},which requires computing only the matrix coupling the previously and newly selected nodes, at a cost of , the products with the weights adding . We note that this update assumes that the historical weights are unchanged. When a refit replaces them by , the first term becomes and the cross terms must be computed with the refitted weights.
The modified operators for each deflation method are described in table 2.
We also note that for the finite-dimensional surrogate methods, we replace by
and by
\Pi_{\tilde{U},\psi}^{\perp} \check{K}_{\mathrm{seg},\psi}^{\top}:=\check{K}_{\mathrm{seg},\psi}^{\top}-\check{L}_{\psi}^{\top}W^{\mathrm{aug}}G_{L}^{\dagger}W^{\mathrm{aug}}^{\top}\check{E}_{L K_{\mathrm{seg}}}.After the selection, the projection is done on the undeflated operator, as in fixed context interpolation, and the resulting residual operator is used to update the weights of the historical nodes. To do so, although any projection method may be used for the refit, the machinery used for the deflation allows a refit counterpart consisting in updating with the weights associated to the orthogonal projection used for the deflation, making it less costly. Thus, denoting the update to the weights of the historical nodes, we obtain the updates
Thanks to the linearity of the attention's numerator and denominator, we can directly append the new segments nodes and weights, and , to and . Indeed, once all the segments have been compressed into and , we can approximate, denoting by and the key and values associated with the sink and recent tokens, the attention's output as
In practice, an issue that may arise due to the interpolation is the ill-conditioning of the ratio due to the interpolated denominator. To mitigate this, we introduce a mean vector approximation of the remaining keys and values which allows us to better approximate the range of the operator, we hence call this method range correction.
4.1.1 Mean vector approximation and range correction
Given , its associated compressed set of nodes , and their weights . Range correction then consists in completing the 'missing weights' at origin associated to using a 'mean-node' approximation of the remaining nodes. To do so, we consider the average of the remaining nodes and weights, given by
Given the raw tokens corresponding to the sink and recent windows. The range correction procedure consists in computing
where we set . Using this, we can approximate each unselected node by the average of the unselected nodes, giving us at the origin
4.1.2 Positional encoding removal
Additionally, for sufficiently distant tokens, an issue that arises is that it appears that the RoPE positional encoding [Su+23] of tokens adversely affects the selection of interpolation nodes. To reduce this effect, we also consider a 'RoPE Stripping' method, wherein we consider the RoPE-less key vectors for selection only. Alternatively, we also consider stripping only the rotation matrices with frequencies such that their period is higher than the size of the segment.
4.2 Streaming interpolation methods
Our streaming compression techniques are hence completely defined by the choice of the key centers and of the method used at each of the four stages, summarised in table 3. One thing to note is that deflation and refit both require keeping, or recomputing, information on the previously compressed nodes. Indeed, the basis variants require the cached inverse, or Cholesky factorisation, of at a memory cost of or a recomputation cost in . The range variants on the other hand require the Gram and its Cholesky factorisation or inverse, at a memory cost of , or a recomputation cost in . Furthermore, not all combinations of choices are possible, Q-DAIM only admits the linear residuals v1 and v5. We thus define our two main strategies:
Table 3: Parameters for interpolation of streaming attention.
| Choice | Options | |
|---|---|---|
| Key centering | Segment (c) / Global (g) | $4 |
| (1) Deflation | None / Basis () / Range () | $4 |
| (2) Selection features | GAIM / Q-DAIM | $3.1.2 |
| Exact / Linear-Taylor / Performer / RFF | $3.1.5 | |
| residual | v1(T_1) / v2(T_1-T_2) / v3((T_1-T_2)/T_3) / v4((T_1-T_2)/v5(φ[q]^T M_Δ)) | $3.1.2 |
| (3) Projection | Basis (Galerkin) / Range / PG least squares / least squares | $3.2 |
| (4) Refit | None / any projection method on | $4 |
| Additional parameters | ||
| Range correction | None / Mean vector (§4.1.1) | $4 |
| RoPE Stripping | All frequencies/ frequency truncation | $4 |
-
Streaming interpolation: The sequential application of the above methods to successive segments, the deflation and refit of each segment being based on the nodes and weights accumulated so far.
-
Block interpolation: A fully parallelizable strategy in which, given a block consisting of multiple segments, each segment is interpolated in parallel, the deflation and refit being based on the and of the previous blocks only, and not on the segments of the current block.
Algorithm 4 Compression of one segment, for one layer and one KV head. The four stages are given as input functions, chosen among the combinations of Table 3; the range correction (§4.1.1) is omitted.
Require: segment (, ); nodes and weights (, ); budget ; stage functions DEFLATE, SELECT, PROJECT, REFIT 1: (, , cache) ← DEFLATE(, , , ) ▷ (1): deflated Gram and residual, cached factorisations 2: ▷ (2): at most nodes of 3: ▷ (3): on the undeflated operator 4: ; ▷ (4): refit on the residual of the projected segment 5: ▷ append the new nodes and weights 6: return
4.3 Complexity and memory
Let us now discuss the complexity and memory requirements of the different interpolation strategies, to do so, we first recall the following notation:
Notation reminder
| Pre-compression context size | segment size | ||
|---|---|---|---|
| Historical/interpolation nodes | Per-segment node budget | ||
| Head dimension | Surrogate feature dimension | ||
| sink and recent window sizes | compression ratio | ||
| revealed rank (§3.1.3) |
In Tables 4 and 5 we list the memory and computational complexity associated to each step of the streaming interpolation methods defined above. Here, the advantage of the surrogate methods is clear, while the cost of exact GAIM and Q-DAIM selection are dominated by the construction of the Gram matrix, the surrogate methods are able to reduce it to , making them usable even when segment sizes become prohibitive for the exact methods. We recall that, as stated in the introduction, we consider a number of interpolation nodes per segment proportional to the head dimension, , so that these costs are linear in . For a fixed compression ratio, i.e. , the terms in would instead be quadratic in the segment size. Furthermore, a new issue arises with basis deflation and refit, indeed the requirement to keep in memory the matrix associated to the Gram's Cholesky factorisation (or its inverse) can quickly become prohibitive and grow beyond the initial KV cache's footprint. The computation of the historical Gram itself is also a bottleneck as it costs per segment for a total cost. These increased costs make the basis deflation and refit unusable in practice. Their Range-revealed counterparts however, represent a less costly and more memory-preserving alternative. Their computational cost and memory requirements are more manageable, scaling linearly in the number of historical nodes. We now look at some numerical results which will enable us to shed some light on the performance of our interpolation methods, the impact of deflation and refit and a look into how the variants compare with each other.
| Matrix | Size | |
|---|---|---|
| Post-Compression | ||
| Nodes | ||
| Weights | ||
| Running mean | ||
| Range-correction weights | ||
| Sink | ||
| Recent | ||
| Deflation/Refit | ||
| Basis projection | or | |
| Range projection | ||
| Post-Compression: | ||
| Compression Ratio: | ||
Table 4: Data in memory per head and per layer kept throughout the context compression.
Table 5: Computational cost of each step, for a single head, per segment. The selection and residual update costs are summed over the picks, and the surrogate costs assume .
| Selection | Residual instantiation | Selection | Residual update | Total |
|---|---|---|---|---|
| Exact kernel | ||||
| GAIM | ||||
| Q-DAIM | ||||
| Surrogate | ||||
| GAIM-LIN | ||||
| GAIM-LIN-O | ||||
| Q-DAIM RFF | ||||
| Projection | Matrix construction | Solve | Total |
|---|---|---|---|
| Galerkin | |||
| Revealed-range | |||
| Least squares |
| Deflation and refit | From scratch | Cached factorisations | Surrogate |
|---|---|---|---|
| Basis deflation | |||
| Range deflation, update | |||
| Bordered update of | — | — | |
| Basis refit | — | ||
| Range refit | — | ||
| Least-squares refit | — |
- Galerkin coefficients updated by bordering at each pick, so that each residual update is rank-1.
† Single pass of Algorithm 2, . The restarts of Appendix E () add to the exact selector.
‡ Absorbed when is maintained by bordered updates (exact GAIM, GAIM-LIN-O, streaming basis variants).
§ costs unless reused from an exact selection, as assumed for the refit.
5 Numerical results
In this section, we discuss the efficiency of our method by considering two different aspects. First, we focus on the convergence of the interpolation method in terms of the norm of the different residuals considered in this work and in terms of the downstream exact attention error for queries that appear after the context is compressed. Second, we focus on the score of the methods on a set of benchmarks, LongBench-E [Bai+24], used in the literature to determine the performance of compression methods. Our method uses the following setting:
- Model: Qwen2.5-7B-Instruct [Qwe+25]: 28 layers, query heads, KV heads, with bf16 weights.
- Library: Huggingface Transformers Library [Wol+20] with PyTorch 2.12 backend.
- Backend: Model forward: bf16 on Metal(MPS), Compression: float64 on CPU.
- Hardware: Apple M4 Pro with 48GB of Unified Memory.
5.1 Interpolation Residuals
To study the convergence of the GAIM and Q-DAIM approaches described in §3.1.2 and §3.1.3, we use a single long document from the Wiki-40b [Guo+20] dataset: the English Wikipedia article on the American Civil War (Wikidata Q8676, index 449 of the English-language train split). After the sink tokens, as introduced in § 4 this corresponds to the first tokens of the context, we compress the key and value vectors of the next tokens and evaluate the query vectors of the following 4096 tokens, which we call future queries. Unless stated otherwise, every metric is the median over all KV heads of the layers . Recall that Q-DAIM only admits the linear residuals v1 and v5, which explains the missing Q-DAIM curves for v2, v3 and v4 in the following figures.
5.1.1 Direct Interpolation residuals
As a first experiment, we look at the interpolation of the complete context () using our different methods and their variants. We look at three metrics which depend only on the keys and values, all expressed with the basis deflated Gram matrix of §4 and the Hilbert–Schmidt norm:
- relative norm of the augmented residual operator: .
- relative norm of the numerator residual operator: .
- relative norm of the denominator residual operator: .
Figure 1 displays the median squared norms of the augmented and denominator operators, the numerator being indistinguishable from the augmented one. We observe that, as expected, variants v1 and v5, which directly optimize these residuals, perform better than the other variants in these metrics. A surprising result is the fact that the residual norm of is also minimised by the selection of the un-augmented variant v1.
Figures 2 and 3 display the median error for the numerator, denominator, and exact attention on future queries. To make heads comparable, we divide the errors by the mean output norm over the 10% of future queries with the largest attention on the same head, which illustrates how the error compares with the heavy hitters of that head, i.e. the set of queries with high attention output norms relative to the rest of the queries. We define this as the median heavy-hitter relative error, given the future queries matrix ,
where denotes the 10% of queries on which is largest.
The dash-dotted line indicates the mean-vector approximation, i.e. the range-corrected estimate (described in §4.1.1) with nodes, and the dotted line indicates the median output norm, i.e. the zero-prediction error. As expected, the
In certain types of attention called Grouped Query Attention (GQA), multiple heads of attention share the same set of key and value vectors but possess different query vectors, this shared head of attention is what we refer to here as a KV head. In MHA every head of attention is a KV head.

Figure 1: Residual operator convergence for the different methods. Relative squared norm of the augmented residual operator (top) and of the denominator residual operator (bottom) against the number of nodes , median over the 16 KV heads. Each panel shows the variants of one method in colour and the curves of the other methods in grey. The norm of the numerator residual operator stays within about 3% of that of the augmented one and is not shown.
v2, v3 and v4 variants outperform v1 and v5 in terms of attention error for all GAIM-based methods while, by design, the opposite is true for the residual norms, as can be expected given that v1 and v5 directly minimise the residual norms.
5.1.2 Impact of range-correction on a long context example
Table 6: Number of query heads per layer (out of 28) on which range correction lowers the maximum error in norm, . GAIM exact v2, nodes selected in the score norm, . In parentheses we give the heads for which the error decreases by more than 10%. Last column: heads improved under every variant and every budget.
| Layer | Variant | n = 32 | n = 128 | n = 512 | All |
|---|---|---|---|---|---|
| 0 | v2 | 23 (17) | 22 (16) | 20 (7) | 17 |
| 7 | v2 | 27 (10) | 26 (10) | 24 (8) | 18 |
| 14 | v2 | 28 (6) | 28 (6) | 26 (2) | 23 |
| 21 | v2 | 28 (7) | 28 (8) | 28 (4) | 26 |
Table 6 shows the number of heads of each layer that were improved by range correction in terms of attention error in future queries. The decisive advantage of the range-corrected estimators on the median error observed in Figure 3 is less clear once we look at specific heads. Indeed, as can be seen from Table 6, while most heads are improved, few of them are improved by more than 10%. To illustrate this, Figure 4 and Figure 5 show two failure modes for the interpolation, one for the range-corrected case and one for the raw interpolation. Each figure plots the norm of the attention error for each future query, ordered according to the norm of the attention of the query; the solid black line indicates the norm of the attention output vector while the dotted line corresponds to the mean vector approximation. As can be seen from Figure 4, for some heads range correction adversely affects the performance of the interpolation. Indeed, as the mean vector approximation has a high error, range-corrected interpolation performs poorly.

Figure 2: Heavy hitter relative error (27) in numerator and denominator with and without range correction. Top: ; bottom: ; both on the future queries. Each curve is the median of this ratio over the 112 query heads; each panel shows the variants of one method in colour and the curves of the other methods in grey. The interquartile range over the heads is shown in Figure 11 of Appendix C.
until a sufficient number of interpolation nodes are chosen, compensating the mean value approximation, whereas the uncorrected interpolation performs well even with few nodes. It is thus not a panacea but a parameter which may improve performance in certain cases, and for certain tasks as we shall see on the benchmarks. On the other hand, we can see in Figure 5 a case where, when the chosen interpolation nodes are not able to represent attention at the queries correctly, range correction allows to mitigate the failure of interpolation and, given a sufficient number of nodes, to extract some additional performance from the interpolation.
5.2 Alternative projection comparison
Figures 6 and 7 illustrate the impact of alternative projections described in §3.2 on the residual error of the GAIM v4 and Q-DAIM v5 selection methods described above. These show that on future queries, the oblique projections of Q-DAIM (in the case of Q-DAIM selection) and of WildCat provide a definite improvement in terms of residual attention error. As we will see in the LongBench-E benchmarks, this reduction in attention error with respect to the uncompressed attention does not correlate one-to-one with better performance on tasks in practice. Although it is worth noting that very poor attention reconstruction error correlates with poor task results, generally because they result in garbled nonsensical text. Table 7 displays the number of heads for which WildCat temperature scaling improves the attention error on future queries. For the rest of the residual-based experiments, we will consider the Galerkin, i.e. the orthogonal projection, onto the interpolation nodes.
5.2.1 Block solve with global projection
We focus now on the same document on the effect of a projection restricted to a segment versus a global projection on a complete interpolation basis. To do so, we select the nodes with the best-performing methods on the above metrics, in a per-segment interpolation without deflation or refit. For each of these methods, we compare the projection restricted to each segment with the projection against all interpolation nodes. In Figure 8, we plot, for each method, the ratio of the error obtained with the global projection to the error obtained with the segment-local one, computed head by head.

Figure 3: Attention error in norm on future queries with and . Heavy hitter relative attention error without (top) and with (bottom) range correction. Each curve is the median of this ratio over the 112 query heads; each panel shows the variants of one method in colour and the curves of the other methods in grey. For both rows, the zero-readout errors are at least 3 times higher and have thus not been drawn in the figures. The interquartile range over the heads is shown in Figure 12 of Appendix C.

Figure 4: Worst-case error for range-corrected GAIM interpolation in norm. Layer 0, query head 4. GAIM exact with the nodes selected in the score norm; each curve is a sliding mean over 205 consecutive queries.

Figure 5: Worst-case GAIM interpolation error and its improvement with range-correction in norm. Layer 1, query head 16; this layer lies outside the layers used for the median curves. GAIM exact with the nodes selected in the score norm; each curve is a sliding mean over 205 consecutive queries. Range correction enables some of the variants to improve their error levels, especially on the tokens with higher attention scores.
Table 7: Number of query heads per layer (out of 28) on which the temperature-scaled projection lowers the maximum error in norm, . GAIM exact v4 with the nodes selected in the score norm, and Q-DAIM exact v5, , RC on, the projection is solved in the kernel rescaled as in [SM26], . In parentheses we give the heads for which the error decreases by more than 10%. The last column is the number of heads that improved for all .
| Layer | GAIM exact v4 | Q-DAIM exact v5 | ||||||
|---|---|---|---|---|---|---|---|---|
| n = 32 | n = 128 | n = 512 | All | n = 32 | n = 128 | n = 512 | All | |
| 0 | 9 (4) | 9 (8) | 8 (4) | 6 | 25 (19) | 25 (19) | 16 (14) | 15 |
| 7 | 20 (6) | 22 (11) | 24 (14) | 18 | 21 (5) | 24 (12) | 25 (20) | 19 |
| 14 | 25 (9) | 24 (17) | 21 (17) | 19 | 25 (0) | 28 (7) | 28 (16) | 25 |
| 21 | 25 (4) | 21 (15) | 22 (17) | 17 | 28 (1) | 28 (10) | 26 (19) | 26 |

Figure 6: Heavy-hitter relative attention error (27) using GAIM exact v4 interpolation nodes for the different projection methods described in Table 1, and without projection, i.e. keeping the values of the selected keys, . Median over the 112 query heads; the interquartile range over the heads is shown in Figure 13 of Appendix C. The methodology used is the same as the experiments in §5.1.

Figure 7: Heavy-hitter relative attention error (27) using Q-DAIM exact v5 interpolation nodes for the different projection methods described in Table 1, and without projection, i.e. keeping the values of the selected keys, . Median over the 112 query heads; the interquartile range over the heads is shown in Figure 14 of Appendix C. The methodology used is the same as the experiments in §5.1.
Interestingly, in most cases the residual error of the segment local interpolation is within 5% of the global interpolation.

Figure 8: Comparison of segment-local projection versus global interpolation node projection on attention residual. Ratio, head by head, of the error obtained with the global projection to the error obtained with the segment-local one, where the error is the median attention error over the future queries (left, centre) or the fit residual at the keys (right). The dot is the median over the heads, the thick bar spans the quartiles and the thin line the 10th to 90th percentiles; a ratio below 1 favours the global projection, and “worse in” gives the share of heads on which it has the larger error. 112 query heads for the future queries and 16 KV heads for the fit at the keys, with , and .
5.2.2 Comparison between streaming and block methods
Finally, we compare the streaming method described in §4 with range deflation and refit to block methods without deflation or refit. In order for the comparison to reflect the interpolation methods as used in practice, we proceed as follows. First, we keep the raw keys and values of the sink tokens , then we compress the key and value vectors of the subsequent tokens and keep the key and value vectors of the next tokens . Then, for each query after the tokens, we compute the attention with the additional raw keys and values of the tokens up to the query token, as would occur in practice if one were to compress only the tokens. Some

Figure 9: Norm of the augmented residual operator for segmented interpolation. Top: relative squared norm of the block method, in percent and shaded on a logarithmic scale (median over the heads). Bottom: difference of this norm between the streaming (with range deflation and refit) and the block method, streaming minus block, in percentage points (blue: lower with streaming, red: higher). Range correction on, .
| GAIM exact[v3, L^∞] | GAIM-LIN[v1, L^∞] | GAIM-LIN-O[v1, L^∞] | Q-DAIM exact[v5] | Q-DAIM RFF[v5] | ||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| blocksegment size N_seg | 2048 | 1.7 | 1.6 | 1.5 | 1.2 | 0.8 | 1.7 | 1.6 | 1.4 | 1.1 | 0.8 | 1.7 | 1.6 | 1.4 | 1.2 | 0.9 | 1.8 | 1.7 | 1.5 | 1.2 | 1.0 | 1.8 | 1.6 | 1.4 | 1.1 | 0.9 |
| 1024 | 1.7 | 1.6 | 1.4 | 1.2 | 0.8 | 1.7 | 1.6 | 1.4 | 1.1 | 0.8 | 1.7 | 1.6 | 1.4 | 1.2 | 0.9 | 1.8 | 1.7 | 1.5 | 1.2 | 0.9 | 1.8 | 1.7 | 1.5 | 1.1 | 0.8 | |
| 512 | 1.7 | 1.6 | 1.4 | 1.2 | 0.7 | 1.7 | 1.6 | 1.4 | 1.1 | 0.8 | 1.7 | 1.6 | 1.4 | 1.2 | 0.9 | 1.7 | 1.7 | 1.5 | 1.2 | 0.8 | 1.7 | 1.7 | 1.5 | 1.1 | 0.8 | |
| 256 | 1.7 | 1.6 | 1.4 | 1.2 | 0.7 | 1.7 | 1.6 | 1.4 | 1.1 | 0.8 | 1.7 | 1.6 | 1.4 | 1.1 | 0.8 | 1.7 | 1.6 | 1.4 | 1.1 | 0.8 | 1.7 | 1.6 | 1.4 | 1.1 | 0.8 | |
| streaming — blocksegment size N_seg | 128 | 1.7 | 1.6 | 1.3 | 1.1 | 0.7 | 1.7 | 1.6 | 1.4 | 1.1 | 0.8 | 1.7 | 1.6 | 1.4 | 1.1 | 0.8 | 1.7 | 1.6 | 1.4 | 1.1 | 0.9 | 1.7 | 1.6 | 1.4 | 1.2 | 0.9 |
| 2048 | -1.5e-4 | -2.0e-3 | +3.5e-3 | +2.0e-3 | -7.2e-3 | -1.8e-4 | -2.6e-3 | -8.9e-3 | +2.1e-3 | -1.9e-3 | -9.4e-10 | -3.5e-4 | +4.8e-5 | -3.2e-7 | -1.8e-13 | -2.5e-6 | +1.4e-3 | -1.3e-3 | -6.3e-3 | -2.2e-3 | -1.4e-5 | +8.4e-5 | +4.0e-2 | +1.2e-2 | +1.4e-2 | |
| 1024 | -0.9e-3 | -6.4e-3 | +3.6e-3 | +3.9e-3 | -8.3e-3 | +2.3e-3 | +4.9e-4 | -4.9e-3 | +5.9e-3 | +3.4e-3 | -2.5e-7 | -6.6e-4 | +1.3e-3 | +1.5e-3 | +3.3e-3 | +1.3e-6 | +4.7e-5 | -7.2e-3 | +4.2e-2 | -1.6e-3 | -2.5e-7 | +5.1e-5 | -1.4e-3 | +2.7e-2 | +1.2e-2 | |
| 512 | -1.1e-3 | -6.3e-3 | -4.5e-3 | +5.4e-3 | +2.3e-2 | -2.2e-3 | -1.5e-4 | -4.6e-3 | -7.0e-7 | -1.8e-6 | -2.3e-6 | -1.9e-4 | +1.4e-4 | +1.1e-3 | -1.7e-3 | -8.9e-6 | -1.7e-6 | -4.7e-6 | +7.8e-3 | -1.3e-2 | -3.6e-4 | -6.0e-7 | +9.7e-3 | +4.2e-3 | +1.3e-4 | |
| streaming — blocksegment size N_seg | 256 | -5.0e-3 | -2.7e-3 | -4.8e-3 | -3.5e-3 | +1.4e-2 | -1.7e-5 | -6.7e-8 | -6.1e-8 | -4.5e-8 | -6.7e-6 | -9.7e-8 | -5.7e-5 | -8.6e-6 | -4.8e-6 | -2.8e-4 | -7.6e-9 | +3.8e-4 | -6.5e-4 | -4.9e-5 | -2.3e-5 | +9.0e-7 | +3.7e-4 | -2.0e-5 | +9.7e-4 | -3.5e-6 |
| 128 | -1.0e-2 | -4.2e-3 | -1.8e-2 | -2.4e-2 | -6.5e-3 | +5.4e-4 | -1.2e-7 | -4.5e-7 | -4.1e-7 | -3.6e-5 | -6.1e-6 | -3.5e-5 | -2.4e-5 | -9.6e-6 | -1.8e-6 | +4.6e-3 | -7.6e-3 | +1.5e-2 | -4.4e-3 | -4.1e-4 | -1.0e-3 | -1.4e-4 | -3.8e-4 | +1.1e-3 | +4.3e-4 | |
nodes per segment (%)
Figure 10: Impact of segment-interpolation parameters on best-performing GAIM and Q-DAIM variants. Top: relative attention error on the future queries for the block method, in percent (median over the heads). Bottom: difference of this error between the streaming (with range deflation and refit) and the block method, streaming minus block, in percentage points (blue: lower with streaming, red: higher). Range correction on, , .
observations are in order. First, the impact of the streaming configuration on the norm of the augmented residuals in Figure 9 is small in most cells (for the variants v1 or v5 that converge on the operator norms). For future queries attention residual, it appears to be a small but net positive for the smaller segment-size and smaller compression ratio cells of the GAIM-exact method, while its effect on the other methods is unclear. All in all, it appears that while the impact of range deflation and refit is small, it is nonetheless there. And as we shall see in the next experiments, the relationship between the performance in language processing tasks and the remaining residual norm/future query attention error is unclear. Indeed, while a high residual norm or future query error implies a poor performance, the lowest residual does not imply the best performance, which indicates that further investigations into a better metric to optimise might be necessary.
5.3 LongBench-E experiments
Indeed, while the residual error allows us to compare the output of the interpolated attention with the exact attention, this does not necessarily correlate with actual performance on natural language processing tasks. In order to illustrate the impact of the compression on the performance of the LLM on given tasks, we provide in Table 8 a preliminary result on the LongBench-E [Bai+24] benchmark. For a few variants of our GAIM and Q-DAIM methods, we report, for each LongBench-E task, the mean score over 25 samples per task. The bold scores correspond to the best-performing compression method, and their distribution illustrates that the different parameters introduced in the article favour different types of tasks. While the exact GAIM and Q-DAIM methods were restricted to segment sizes on the order of due to their quadratic scaling, we observe that the surrogate methods perform on par with the exact ones even though they scale linearly with . For comparison, we include the performance of CompressKV, the WildCat-based compression technique reported in [SM26] on the complete benchmark and for one-to-one comparison we also show RP-Cholesky, a Randomly-Pivoted Cholesky selection in the WildCat -scaled kernel, similar to WildCat but using our segment-based numerical framework. Additionally, we also computed GAIM-LIN and Q-DAIM exact in the WildCat -scaled kernel formulation, for both projection and selection, which provided a considerable improvement in residual error experiments. In these benchmarks, it appears to mostly reduce the performance of GAIM while slightly improving Q-DAIM on some specific tasks. Most notably, some question answering tasks, MFQA and HotpotQA, scores seem to be positively impacted by the temperature scaling both in terms of selection and projection.
5.4 Observations
As the experiments above show, the attention residual does not seem to be correlated to the benchmark scores directly. Indeed, as we have seen in Figure 6 and Figure 7 the temperature-scaled projection lowers the attention error, yet loses 12 to 14 points on qasper for the GAIM-LIN selection and 3 points for the Q-DAIM selection. The selection metric
Table 8: LongBench-E - 25 prompts per task at 25% context compression. Key centers are given as the tuple (selection, solve), c = segment mean, g = global mean. The Exact and COMPRESSKV rows are the values reported in Table 4 of [SM26] (25% compression) on the complete benchmark (compared to our 25 samples/task). For comparison, the percentages rows give, per task, our best method on average (Q-DAIM exact, ) and the best score per task relative to Dense, and COMPRESSKV relative to Exact. Proj.: Galerkin/basis projection (Gal.), none (each node keeps its own value with a unit weight, ), or Q-DAIM's revealed-range projection restricted to the revealed rank (range). Methods optionally use the temperature scaled kernel for comparison with WildCat [SM26]. RP-Cholesky corresponds to an implementation of the WildCat selection and projection on our harness. : run on PyTorch 2.14, whose GPU (MPS) attention kernels round differently.
| Selection method | Deflation | RoPE Strip. | Centering | RC | Proj. | Qasper | MFQA | HotpotQA | Wiki | GovRep | MultiNews | TREC | TriviaQA | SAMsum | PRecum | PRer | LCC | RepBp | Mean | % dense | ||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Dense | - | - | - | - | - | - | - | 54.9 | 61.8 | 57.1 | 60.8 | 34.7 | 26.9 | 72.0 | 86.7 | 46.7 | 16.0 | 100.0 | 68.6 | 65.6 | 57.84 | 100.0 |
| GAIM exact [v3, L~] | 128 | range | off | (c,c) | 1 | on | Gal. | 45.8 | 58.4 | 48.2 | 36.0 | 31.1 | 23.2 | 64.0 | 85.5 | 41.3 | 4.0 | 80.0 | 52.7 | 56.1 | 48.18 | 83.3 |
| GAIM-LIN [v1, L~] | 128† | none | off | (c,c) | 1 | on | Gal. | 48.8 | 59.3 | 52.2 | 36.4 | 30.0 | 22.7 | 64.0 | 88.8 | 41.2 | 8.0 | 84.0 | 47.2 | 53.0 | 48.88 | 84.5 |
| 128† | none | off | (c,c) | 1 | on | none | 40.5 | 57.7 | 49.2 | 47.3 | 30.9 | 23.6 | 68.0 | 85.0 | 37.5 | 8.0 | 92.0 | 44.2 | 56.6 | 49.27 | 85.2 | |
| 128† | none | off | (c,c) | 1 | off | Gal. | 43.9 | 52.3 | 48.0 | 43.7 | 30.3 | 23.1 | 60.0 | 86.8 | 39.0 | 8.0 | 92.0 | 52.5 | 55.3 | 48.84 | 84.4 | |
| 128† | none | off | (c,c) | 1 | off | none | 46.5 | 54.3 | 45.8 | 38.5 | 31.1 | 23.2 | 68.0 | 84.9 | 37.8 | 4.0 | 80.0 | 51.4 | 61.4 | 48.23 | 83.4 | |
| 128 | none | off | (c,c) | on | Gal. | 35.5 | 49.8 | 54.8 | 47.6 | 29.9 | 23.2 | 64.0 | 89.3 | 38.6 | 12.0 | 80.0 | 51.1 | 56.0 | 48.60 | 84.0 | ||
| 512 | none | on | (c,c) | 1 | on | Gal. | 37.1 | 49.5 | 50.6 | 36.5 | 29.1 | 22.9 | 64.0 | 90.2 | 39.2 | 16.0 | 84.0 | 53.1 | 58.1 | 48.48 | 83.8 | |
| 512 | range | on | (c,c) | 1 | on | Gal. | 35.2 | 48.7 | 49.8 | 36.3 | 28.7 | 22.8 | 64.0 | 88.5 | 41.3 | 12.0 | 64.0 | 59.4 | 58.0 | 46.83 | 81.0 | |
| 512 | basis + refit | off | (g,g) | 1 | on | Gal. | 37.8 | 47.1 | 50.2 | 35.3 | 29.0 | 22.1 | 64.0 | 86.9 | 39.2 | 12.0 | 48.0 | 49.8 | 60.9 | 44.80 | 77.5 | |
| Q-DAIM exact [v5] | 64 | range | off | (c,c) | 1 | on | Gal. | 41.5 | 55.4 | 53.0 | 35.0 | 31.7 | 24.0 | 64.0 | 90.3 | 42.5 | 12.0 | 88.0 | 53.8 | 52.4 | 49.50 | 85.6 |
| 64 | range | off | (c,c) | on | Gal. | 38.4 | 58.1 | 56.1 | 39.8 | 30.8 | 22.9 | 60.0 | 81.7 | 40.3 | 4.0 | 92.0 | 55.8 | 38.3 | 47.56 | 82.2 | ||
| 64† | range | off | (c,c) | 1 | on | none | 34.8 | 48.6 | 52.6 | 40.0 | 31.4 | 25.3 | 56.0 | 91.3 | 42.4 | 8.0 | 88.0 | 52.1 | 54.2 | 47.93 | 82.9 | |
| 64† | range | off | (c,c) | 1 | off | Gal. | 38.3 | 52.0 | 49.5 | 45.9 | 32.5 | 22.1 | 56.0 | 88.7 | 39.9 | 4.0 | 92.0 | 50.1 | 52.6 | 47.97 | 82.9 | |
| 64† | range | off | (c,c) | 1 | off | none | 38.2 | 53.3 | 50.7 | 60.5 | 31.8 | 22.5 | 52.0 | 92.0 | 41.3 | 8.0 | 96.0 | 53.5 | 55.5 | 50.40 | 87.1 | |
| 64† | range | off | (c,c) | 1 | on | range- | 39.4 | 52.1 | 54.7 | 43.6 | 31.6 | 22.1 | 60.0 | 95.3 | 42.9 | 8.0 | 96.0 | 54.8 | 49.8 | 50.02 | 86.5 | |
| Q-DAIM RFF [v5] | 512 | none | on | (c,c) | 1 | on | Gal. | 39.2 | 47.0 | 48.3 | 45.6 | 29.0 | 21.7 | 68.0 | 81.6 | 41.4 | 12.0 | 80.0 | 53.9 | 52.0 | 47.67 | 82.4 |
| 2048 | none | on | (c,c) | 1 | on | Gal. | 42.8 | 39.4 | 39.3 | 42.5 | 28.2 | 22.4 | 72.0 | 88.9 | 40.8 | 12.0 | 40.0 | 58.4 | 60.5 | 45.17 | 78.1 | |
| RP-Cholesky[[SM26]-based] | 128 | none | off | (c,c) | on | Gal. | 33.8 | 58.3 | 48.8 | 53.6 | 29.4 | 22.6 | 60.0 | 88.9 | 41.6 | 8.0 | 76.0 | 53.9 | 55.4 | 48.49 | 83.8 | |
| 128 | none | off | (c,c) | off | Gal. | 36.8 | 58.6 | 43.2 | 53.6 | 29.8 | 23.4 | 64.0 | 88.9 | 37.4 | 12.0 | 76.0 | 51.6 | 53.6 | 48.38 | 83.7 | ||
| 128† | none | off | (c,c) | off | none | 41.1 | 57.9 | 54.5 | 42.9 | 31.7 | 22.7 | 60.0 | 91.3 | 38.1 | 12.0 | 84.0 | 55.6 | 59.0 | 50.06 | 86.6 | ||
| Q-DAIM exact [v5], % of Dense | 64† | range | off | (c,c) | 1 | off | none | 69.5 | 86.2 | 88.8 | 99.6 | 91.7 | 83.4 | 72.2 | 106.2 | 88.4 | 50.0 | 96.0 | 77.9 | 84.6 | 84.2 | 87.1 |
| Best score, % of Dense | - | - | - | - | - | - | - | 88.9 | 95.9 | 98.2 | 99.6 | 93.7 | 89.0 | 100.0 | 110.0 | 91.8 | 100.0 | 96.0 | 86.5 | 93.6 | 95.6 | 96.3 |
| Exact [SM26] | - | - | - | - | - | - | - | 43.8 | 50.1 | 56.4 | 43.7 | 34.2 | 24.3 | 64.0 | 87.5 | 38.6 | 14.7 | 99.7 | 70.0 | 62.2 | 53.00 | 100.0 |
| COMPRESSKV [SM26] | - | - | - | - | - | - | - | 33.2 | 38.1 | 43.4 | 33.4 | 30.3 | 22.3 | 54.3 | 86.2 | 35.4 | 14.3 | 98.0 | 64.8 | 60.4 | 47.25 | 89.1 |
| COMPRESSKV, % of Exact | - | - | - | - | - | - | - | 75.9 | 76.1 | 77.0 | 76.3 | 88.7 | 91.5 | 84.9 | 98.4 | 91.8 | 97.7 | 98.3 | 92.7 | 97.2 | 88.2 | 89.1 |
however does seem to determine which type of task performs better. At the same budget, Q-DAIM and GAIM-LIN reach nearly the same LongBench-E mean, albeit with different profiles. Comparing their Galerkin variants with range correction, Q-DAIM performs better on summarisation (GovRep, MultiNews), on HotpotQA and on code completion in LCC, while GAIM-LIN leads on single-document question answering (Qasper, MFQA) and, by a smaller margin, on 2Wiki and RepoB-P. This suggests that the selection criterion impacts which information the interpolation preserves, and that the range of the augmented operator, revealed by Q-DAIM, helps identify the features that contain it. It is also interesting to note that the selection of interpolation nodes has the most decisive impact on output performance. While projection does help in some respects, simply using the values associated with the nodes without projection, also works well. For instance, the projection-free Q-DAIM variant is the best performer on average (50.40, 87.1% of Dense), although it wins mainly by a large margin on a single task, 2Wiki, where it reaches 60.5 (almost on par with the uncompressed model) against 35.0 for the Galerkin variant with range correction (45.9 without), while performing less well than the former on eight of the twelve other tasks. Without projection or range correction, each node keeps its own key and value, so the score depends only on which tokens are kept; the fact that Q-DAIM still outperforms GAIM-LIN in this setting therefore suggests that its selection chooses better nodes.
Finally, Q-DAIM's revealed-range projection restricted to the revealed rank (range) performs very well. Obtaining 50.02 on average (86.5% of Dense), with the best scores on TriviaQA and the shared best on PRetr. The restriction to the revealed rank, which is not necessary for the other projections, is due to the fact that on the span revealed by of dimension , the first pivots reduce the residual on this subspace of to zero and the projected values on the remaining pivots are numerical noise. Indeed, under range deflation, the operator in a later segment can have fewer revealed directions than the node budget , down to one or two for in some heads of the middle layers. Unrestricted range projection then reduces the performance dramatically due to the induced noise (32.1 on average, with garbled outputs on several prompts). Restricting the projection to the first pivots, removes this failure but leaves part of the budget unused in those segments. Our restart method, consisting in projecting onto the orthogonal complement of the chosen nodes, allows us to find new directions that improve the reconstruction of on , but with diminishing returns as all the keys are required to construct completely. Finding a method that would allow one to represent the revealed range more fully, could use this budget to further improve the method ().
We also note that removing the RoPE positional embedding on the key vectors has a noticeable impact on the performance of our methods, illustrated by the best-performing PCount score. This provides some weight to the argument that better compression may require taking into account positional information separately from semantic information.
We highlight again the two cases illustrated in Figures 5 and 4, namely the fact that several regimes appear to occur in different heads, corresponding to the ability of either mean vector approximation or kernel based interpolation to provide an effective compression of the context and the interaction between the two methods. These cases provide some evidence to support the idea that several different structures emerge in different attention heads and that the best methods of approximation for each structure differ. It seems reasonable to expect that such structures not only appear in the studied model but that similar structures occur in most learned models of attention and that the correct way to compress the information contained in the data must take these structures into account.
6 Discussion and Future work
The experimental results we obtained are promising, showing a convergence in terms of residual norm and a reasonable LongBench-E performance, comparable to state of the art methods (see [SM26]), which may, given more experimentation on the choice of method and associated best set of parameters, allow for further improvements in performance. Furthermore, the interpolation methods we developed do not rely on the textual nature of the context, but only on the kernel underlying scaled dot-product attention. They are thus also suited to other types of attention mechanisms, such as the self-attention and cross-attention layers found in models aimed at vision, such as Vision Transformer [Dos+21] based models [Sim+25; Tea+25] or graph attention models [Sun+23]. In these non-causal settings, the complete context is usually available at once while the context size is then set by a fixed resolution input. Furthermore, given the fact that the nature of the output is different, the performance of the interpolated context might be more directly related to its residual operator norm or attention error. The interpolatory framework developed in this article motivates several extensions, which will be the subject of future work. First, since the revealed range of Q-DAIM exists in the infinite dimensional RKHS, we never manipulate it directly but only through its evaluations of key features , requiring the storage of the complete set of keys. The natural extension is thus to try to represent directly in order to reduce this costly dependence on the keys. An avenue to achieve this might be through the use of a random range finder for operators in Hilbert spaces [KPU25]. Second, our experiments provide support for the fact that different heads of attention possess different structures for the information they contain. These structures respond differently to interpolation and range correction, and thus motivate the construction of an efficiently computable metric to identify the methods suitable for the approximation. One such candidate is clustering, as it has been studied extensively for attention [Zan+23; Han+23; Hoo+25] but not for kernel interpolation, and a direct extension of our methods would be to interpolate each cluster separately along with its own mean vector range correction. A related finding which appears to affect the approximability of these structures is positional encoding, and applying our methods to Latent Attention [Dee+24] might shed some light on its impact due to its separation of positional from semantic information. Furthermore, applying our methods to it through conversion methods such as TransMLA [MYZ25] would let us compare how the same data interpolate in latent and regular attention.
Finally, the methods developed in this article reduce the context size , and can thus be complementary to quantization-based methods such as TurboQuant [Zan+25] or PolarQuant [Han+25a]. Further improvements may also be obtained by using quantization to develop a more efficient way of selecting keys and projecting values by concentrating the information contained in the key and value vectors.
7 Acknowledgments
The first author (M.F.S.) would like to thank Alexandre Pasco for the lively discussions that provided additional insights on the attention mechanism, Johannes Laute for the many conversations on the numerical implementation of our methods, and Benjamin Carrel for the numerous insightful discussions concerning interpolation.
Code and Data
The code used for the numerical experiments in Section 5 was written with the assistance of Claude Opus 4.8 and Fable 5.1 (Anthropic), accessed through Claude Code in 2026. The authors designed the experiments, reviewed and tested all generated code, and take full responsibility for the results. The experimental code is based upon the Huggingface transformers [Wol+20] python library and all experiments were run on Qwen2.5-7B-Instruct [Qwe+25]. The data used for the experiments comes from the Wiki-40b [Guo+20] dataset and the LongBench benchmark [Bai+24] dataset.
A.I. Usage for typesetting and literature review
In addition to the use of AI for coding, AI assistance using the Claude Code Harness (Opus 4.8, 5.5 and Fable 5.1) was used to search the literature, to generate diagrams, and to format and typeset parts of the text and ensure coherence of notation, as well as provide feedback on the text.
References
[Ain+23] Joshua Ainslie et al. GQA: Training Generalized Multi-Query Transformer Models from Multi-Head Checkpoints. Dec. 2023. DOI: 10.48550/arXiv.2305.13245. arXiv: 2305.13245 [cs].
[Bai+24] Yushi Bai et al. "LongBench: A Bilingual, Multitask Benchmark for Long Context Understanding". In: Proceedings of the 62nd Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers). Bangkok, Thailand: Association for Computational Linguistics, 2024, pp. 3119–3137. DOI: 10.18653/v1/2024.acl1-long.172.
[BG65] Peter Businger and Gene H. Golub. "Linear Least Squares Solutions by Householder Transformations". In: Numerische Mathematik 7.3 (1965), pp. 269–276. DOI: 10.1007/BF01436084.
[Che+21] Yifan Chen et al. Skyformer: Remodel Self-Attention with Gaussian Kernel and Nyström Method. Oct. 2021. DOI: 10.48550/arXiv.2111.00035. arXiv: 2111.00035 [cs].
[Che+26] Justin Y. Chen et al. Towards Tight Bounds for Streaming Attention. 2026. arXiv: 2606.07205 [cs.DS]. URL: https://arxiv.org/abs/2606.07205.
[Cho+22] Krzysztof Choromanski et al. Rethinking Attention with Performers. Nov. 2022. DOI: 10.48550/arXiv.2009.14794. arXiv: 2009.14794 [cs].
[CK26] Alice Cortinovis and Daniel Kressner. "Adaptive Randomized Pivoting for Column Subset Selection, DEIM, and Low-Rank Approximation". In: SIAM Journal on Matrix Analysis and Applications 47.1 (2026), pp. 25–47. DOI: 10.1137/24M1719189. eprint: https://doi.org/10.1137/24M1719189. URL: https://doi.org/10.1137/24M1719189.
[Com+08] Pierre Comon et al. Symmetric Tensors and Symmetric Tensor Rank. Sept. 2008. DOI: 10.48550/arXiv.0802.1681. arXiv: 0802.1681 [math].
[Dao+22] Tri Dao et al. FlashAttention: Fast and Memory-Efficient Exact Attention with IO-Awareness. June 2022. DOI: 10.48550/arXiv.2205.14135. arXiv: 2205.14135 [cs].
[Dao23] Tri Dao. FlashAttention-2: Faster Attention with Better Parallelism and Work Partitioning. July 2023. DOI: 10.48550/arXiv.2307.08691. arXiv: 2307.08691 [cs].
[Dav97] Geoffrey Davis. "Greedy adaptive approximation". In: Journal of Constructive Approximation 13.1 (1997), pp. 57–98.
[Dee+24] DeepSeek-AI et al. DeepSeek-V2: A Strong, Economical, and Efficient Mixture-of-Experts Language Model. June 2024. DOI: 10.48550/arXiv.2405.04434. arXiv: 2405.04434 [cs].
[DG16] Zlatko Drmač and Serkan Gugercin. "A New Selection Operator for the Discrete Empirical Interpolation Method—Improved A Priori Error Bound and Extensions". In: SIAM Journal on Scientific Computing 38.2 (2016), A631–A648. DOI: 10.1137/15M1019271. eprint: https://doi.org/10.1137/15M1019271. URL: https://doi.org/10.1137/15M1019271.
[Dos+21] Alexey Dosovitskiy et al. An Image is Worth 16x16 Words: Transformers for Image Recognition at Scale. 2021. arXiv: 2010.11929 [cs.CV]. URL: https://arxiv.org/abs/2010.11929.
[DS18] Zlatko Drmač and Arvind K. Saibaba. The Discrete Empirical Interpolation Method: Canonical Structure and Formulation in Weighted Inner Product Spaces. Feb. 2018. DOI: 10.48550/arXiv.1704.06606. arXiv: 1704.06606 [math].
[DSW05] Stefano De Marchi, Robert Schaback, and Holger Wendland. "Near-Optimal Data-Independent Point Locations for Radial Basis Function Interpolation". In: Advances in Computational Mathematics 23.3 (2005), pp. 317–330. DOI: 10.1007/s10444-004-1829-1.
[ETW25] Ethan N. Epperly, Joel A. Tropp, and Robert J. Webber. Embrace Rejection: Kernel Matrix Approximation by Accelerated Randomly Pivoted Cholesky. Apr. 2025. DOI: 10.48550/arXiv.2410.03969. arXiv: 2410.03969 [math].
[FG26] Israa Fakih and Laura Grigori. Efficient QR-based Column Subset Selection through Randomized Sparse Embeddings. 2026. arXiv: 2509.03198 [math.NA]. URL: https://arxiv.org/abs/2509.03198.
[Gon+26] Albert Gong et al. Express Language Modeling. June 2026. DOI: 10.48550/arXiv.2606.10944. arXiv: 2606.10944 [cs].
[Guo+20] Mandy Guo et al. "Wiki-40B: Multilingual Language Model Dataset". eng. In: Proceedings of the Twelfth Language Resources and Evaluation Conference. Ed. by Nicoletta Calzolari et al. Marseille, France: European Language Resources Association, May 2020, pp. 2440–2452. ISBN: 979-10-95546-34-4. URL: https://aclanthology.org/2020.lrec-1.297/.
[Han+23] Insu Han et al. HyperAttention: Long-context Attention in Near-Linear Time. Dec. 2023. DOI: 10.48550/arXiv.2310.05869. arXiv: 2310.05869 [cs].
[Han+25a] Insu Han et al. PolarQuant: Quantizing KV Caches with Polar Transformation. 2025. arXiv: 2502.02617 [cs.LG]. URL: https://arxiv.org/abs/2502.02617.
[Han+25b] Insu Han et al. Streaming Attention Approximation via Discrepancy Theory. May 2025. DOI: 10.48550/arXiv.2502.07861. arXiv: 2502.07861 [cs].
[Hig90] Nicholas J Higham. "Analysis of the Cholesky decomposition of a semi-definite matrix". In: Reliable Numerical Computation. Ed. by M G Cox and S Hammarling. Oxford University Press, Sept. 1990. ISBN: 9780198535645. DOI: 10.1093/oso/9780198535645.003.0010. eprint: https://academic.oup.com/book/0/chapter/422058562/chapter-pdf/52393608/isbn-9780198535645-book-part-10.pdf. URL: https://doi.org/10.1093/oso/9780198535645.003.0010.
[Hoo+25] Coleman Hooper et al. Multipole Attention for Efficient Long Context Reasoning. June 2025. DOI: 10.48550/arXiv.2506.13059. arXiv: 2506.13059 [cs].
[KKL20] Nikita Kitaev, Łukasz Kaiser, and Anselm Levskaya. Reformer: The Efficient Transformer. Feb. 2020. DOI: 10.48550/arXiv.2001.04451. arXiv: 2001.04451 [cs].
[KLS18] Agnan Kessy, Alex Lewin, and Korbinar Strimmer. "Optimal Whitening and Decorrelation". In: The American Statistician 72.4 (2018), pp. 309–314. DOI: 10.1080/00031305.2016.1277159. eprint: https://doi.org/10.1080/00031305.2016.1277159. URL: https://doi.org/10.1080/00031305.2016.1277159.
[KMZ24] Praneeth Kacham, Vahab Mirrokni, and Peilin Zhong. "PolySketchFormer: Fast Transformers via Sketching Polynomial Kernels". In: Proceedings of the 41st International Conference on Machine Learning. Ed. by Ruslan Salakhutdinov et al. Vol. 235. Proceedings of Machine Learning Research. PMLR, July 2024, pp. 22748–22770. URL: https://proceedings.mlr.press/v235/kacham24a.html.
[KPU25] Daniel Kressner, David Persson, and André Uschmajew. On the Randomized SVD in Infinite Dimensions. June 2025. DOI: 10.48550/arXiv.2506.06882. arXiv: 2506.06882 [math].
[Li+24] Yuhong Li et al. SnapKV: LLM Knows What You Are Looking for Before Generation. Apr. 2024. DOI: 10.48550/arXiv.2404.14469. arXiv: 2404.14469 [cs].
[LLS24] Sangho Lee, Hayun Lee, and Dongkun Shin. "Proxyformer: Nyström-Based Linear Transformer with Trainable Proxy Tokens". In: AAAI 38.12 (Mar. 2024), pp. 13418–13426. ISSN: 2374-3468, 2159-5399. DOI: 10.1609/aaai.v38i12.29244.
[Mad+07] Yvon Maday et al. "A general, multipurpose interpolation procedure: the magic points". working paper or preprint. Sept. 2007. URL: https://hal.science/hal-00174797.
[MM13] Y. Maday and O. Mula. "A Generalized Empirical Interpolation Method: Application of Reduced Basis Techniques to Data Assimilation". In: vol. 4. 2013, pp. 221–235. DOI: 10.1007/978-88-470-2592-9_13. arXiv: 1512.00683 [math].
[MYZ25] Fanxu Meng, Zengwei Yao, and Muhan Zhang. TransMLA: Multi-Head Latent Attention Is All You Need. Feb. 2025. DOI: 10.48550/arXiv.2502.07864. arXiv: 2502.07864 [cs].
[PP25] Ninh Pham and Rasmus Pagh. Tensor Sketch: Fast and Scalable Polynomial Kernel Approximation. May 2025. DOI: 10.48550/arXiv.2505.08146. arXiv: 2505.08146 [cs].
[PRK93] Y.C. Pati, R. Rezaiifar, and P.S. Krishnaprasad. "Orthogonal matching pursuit: recursive function approximation with applications to wavelet decomposition". In: Proceedings of 27th Asilomar Conference on Signals, Systems and Computers. 1993, 40–44 vol.1. DOI: 10.1109/ACSSC.1993.342465.
[Qwe+25] Qwen et al. Qwen2.5 Technical Report. Jan. 2025. DOI: 10.48550/arXiv.2412.15115. arXiv: 2412.15115 [cs].
[RR07] Ali Rahimi and Benjamin Recht. "Random Features for Large-Scale Kernel Machines". In: Advances in Neural Information Processing Systems. Ed. by J. Platt et al. Vol. 20. Curran Associates, Inc., 2007. URL: https://proceedings.neurips.cc/paper_files/paper/2007/file/013a006f03dbc5392effeb8f18fda755-Paper.pdf.
[Ser+26] Michel Fabrice Serret et al. Attention Mechanisms Through the Lens of Numerical Methods: Approximation Methods and Alternative Formulations. 2026. arXiv: 2604.01757 [math.NA]. URL: https://arxiv.org/abs/2604.01757.
[Ser26] Michel Fabrice Serret. Understanding Transformers and Attention Mechanisms: An Introduction for Applied Mathematicians. 2026. arXiv: 2604.00965 [math.NA]. URL: https://arxiv.org/abs/2604.00965.
[SH17] Gabriele Santin and Bernard Haasdonk. "Convergence Rate of the Data-Independent P-Greedy Algorithm in Kernel-Based Approximation". In: Dolomites Research Notes on Approximation 10. Special Issue (2017), pp. 68–78. DOI: 10.14658/PUPJ-DRNA-2017-Special_Issue-9. eprint: 1612.02672 (math).
[Sim+25] Oriane Siméoni et al. DINOv3. 2025. arXiv: 2508.10104 [cs.CV]. URL: https://arxiv.org/abs/2508.10104.
[Sin+24] Prajwal Singhania et al. Loki: Low-rank Keys for Efficient Sparse Attention. 2024. arXiv: 2406.02542 [cs.LG]. URL: https://arxiv.org/abs/2406.02542.
[SM26] Tobias Schröder and Lester Mackey. WildCat: Near-Linear Attention in Theory and Practice. 2026. arXiv: 2602.10056 [cs.LG]. URL: https://arxiv.org/abs/2602.10056.
[Su+23] Jianlin Su et al. RoFormer: Enhanced Transformer with Rotary Position Embedding. 2023. arXiv: 2104.09864 [cs.CL]. URL: https://arxiv.org/abs/2104.09864.
[Sun+23] Chengcheng Sun et al. "Attention-based graph neural networks: a survey". In: Artificial Intelligence Review 56.S2 (Aug. 2023), pp. 2263–2310. ISSN: 1573-7462. DOI: 10.1007/s10462-023-10577-2. URL: http://dx.doi.org/10.1007/s10462-023-10577-2.
[SW02] Andreas Stathopoulos and Kesheng Wu. "A Block Orthogonalization Procedure with Constant Synchronization Requirements". In: SIAM Journal on Scientific Computing 23.6 (2002), pp. 2165–2182. DOI: 10.1137/S1064827500370883. eprint: https://doi.org/10.1137/S1064827500370883. URL: https://doi.org/10.1137/S1064827500370883.
[Tea+25] Gemma Team et al. Gemma 3 Technical Report. 2025. arXiv: 2503.19786 [cs.CL]. URL: https://arxiv.org/abs/2503.19786.
[TGS06] Joel A. Tropp, Anna C. Gilbert, and Martin J. Strauss. "Algorithms for simultaneous sparse approximation. Part I: Greedy pursuit". In: Signal Processing 86.3 (2006). Sparse Approximations in Signal and Image Processing, pp. 572–588. ISSN: 0165-1684. DOI: https://doi.org/10.1016/j.sigpro.2005.05.030. URL: https://www.sciencedirect.com/science/article/pii/S0165168405002227.
[Vas+23] Ashish Vaswani et al. Attention Is All You Need. 2023. arXiv: 1706.03762 [cs.CL]. URL: https://arxiv.org/abs/1706.03762.
[Wan+20] Sinong Wang et al. Linformer: Self-Attention with Linear Complexity. 2020. arXiv: 2006.04768 [cs.LG]. URL: https://arxiv.org/abs/2006.04768.
[Wol+20] Thomas Wolf et al. "Transformers: State-of-the-Art Natural Language Processing". In: Proceedings of the 2020 Conference on Empirical Methods in Natural Language Processing: System Demonstrations. Ed. by Qun Liu and David Schlangen. Online: Association for Computational Linguistics, Oct. 2020, pp. 38–45. DOI: 10.18653/v1/2020.emnlp-demos.6. URL: https://aclanthology.org/2020.emnlp-demos.6/.
[WSH21] Tizian Wenzel, Gabriele Santin, and Bernard Haasdonk. "A novel class of stabilized greedy kernel approximation algorithms: Convergence, stability and uniform point distribution". In: Journal of Approximation Theory 262 (2021), p. 105508. ISSN: 0021-9045. DOI: https://doi.org/10.1016/j.jat.2020.105508. URL: https://www.sciencedirect.com/science/article/pii/S0021904520301441.
[WSH23] Tizian Wenzel, Gabriele Santin, and Bernard Haasdonk. "Analysis of Target Data-Dependent Greedy Kernel Algorithms: Convergence Rates for , - and -Greedy". In: Constructive Approximation 57.1 (2023), pp. 45–74. DOI: 10.1007/s00365-022-09592-3.
[Xia+24] Guangxuan Xiao et al. Efficient Streaming Language Models with Attention Sinks. 2024. arXiv: 2309.17453 [cs.CL]. URL: https://arxiv.org/abs/2309.17453.
[Yan+24] Dongjie Yang et al. PyramidInfer: Pyramid KV Cache Compression for High-throughput LLM Inference. 2024. arXiv: 2405.12532 [cs.CL]. URL: https://arxiv.org/abs/2405.12532.
[Zan+23] Amir Zandieh et al. KDEformer: Accelerating Transformers via Kernel Density Estimation. 2023. arXiv: 2302.02451 [cs.LG]. URL: https://arxiv.org/abs/2302.02451.
[Zan+25] Amir Zandieh et al. TurboQuant: Online Vector Quantization with Near-optimal Distortion Rate. 2025. arXiv: 2504.19874 [cs.LG]. URL: https://arxiv.org/abs/2504.19874.
[Zha+23] Zhenyu Zhang et al. : Heavy-Hitter Oracle for Efficient Generative Inference of Large Language Models. 2023. arXiv: 2306.14048 [cs.LG]. URL: https://arxiv.org/abs/2306.14048.
A Proofs
Proof of Proposition 1. We first prove the result when the rows of are, in addition, pairwise non-collinear, i.e. such that, for all distinct , there exists no for which . Let , we can then set, dropping the prefactor
where, for all , . Since there also exists a such that , so the degree- component is . For the case , we have and for any , , which thanks to the linear independence we shall prove below implies that, for all , , and hence . This contradiction then requires . For , we have for every , that the matricization of has rank 1. Let us show that this leads to a unique non-zero coefficient for some . Indeed, for sufficiently large , the rank of the matricization of is equal to the number of non-zero coefficients. Indeed, as the rows of are pairwise linearly independent vectors, we have that, the -th tensor power of the keys , for all , are linearly independent [Com+08, Corollary 4.4]. Hence, the rank of is equal to the number of non-zero coefficients. Thus, as the rank needs to be equal to 1, we have that there exists a single non-zero coefficient such that for some . The first result of Lemma 1 then gives us that . Finally, thanks to the second result of Lemma 1, we can extend the result to with distinct, non-zero rows. Indeed, consider a key matrix whose rows form equivalence classes for the pairwise collinearity, with representatives , and set for all , where the are non-zero and distinct inside each equivalence class. Let be the cardinality of the biggest collinearity class, , and, for any , let denote the truncated features. First, the truncated features , are linearly independent. Indeed, let be such that , i.e. such that, for all ,
As , the -th tensor powers of the representatives are linearly independent [Com+08, Corollary 4.4], so that for all and , and the second result of Lemma 1, applied inside each equivalence class, gives us that . In particular, the case is excluded in the same way as above, as it would give . Then, in the same way as above, consider the matricization of . Since, for any and , , its block is given by
so that , whose matricization has rank 1 as . Now, as before, since the truncated feature vectors are all linearly independent, we have the same rank argument as in the non-collinear case and thus the result, there is a unique such that .
Proof of Lemma 1. Suppose for some and . The equality of the degree-1 components gives . The equality of the degree-2 components then requires with , so , contradicting the supposition.
For the second claim, let be such that, for all ,
Since , , this is equivalent to
We show by induction on that this implies , for any , any pairwise distinct and any . For implies , hence as . For , assume the claim holds for the vectors. Let us consider such that for all ,
For each , subtracting times the equation of degree from that of degree eliminates the last term, giving us
We identify this as the property (28) for on the consecutive degrees , with coefficients . Hence, by the induction hypothesis, , and since the are pairwise distinct, for all . The equation of degree then reduces to , so . This proves the claim at rank , and thus for all by induction. The truncated features are thus linearly independent, hence so are the , and .
Proof of Proposition 2. (i.) The numerator and denominator are linear in , so any scalar cancels the ratio.
(ii.) The numerator and denominator are also linear in the key features , so rescaling all of them by multiplies both by .
(iii.) Translating all keys by multiplies each evaluation of the kernel by the single factor per-query , which cancels in the ratio,
Proof of Proposition 4. , and the second identity corresponds to applying equation (9) to the translated matrices.
Proof of Proposition 5. The interpolated attention can be written as
Using Proposition 4 and equation (13), we obtain
Simplifying the terms then gives us
where the first equality gives us the identity of the proposition. For the -th row of , and the equation simplifies to
which shows that the interpolation is exact at the translated nodes, whose features are, by Proposition 1, the only points of in .
Proof of Proposition 6. Using the identities of (9), we have and . Applying this to each block of the Schur complement , the terms cancel within and thus . Hence, using and , we can write
dividing both sides by , gives us the formula. The identity follows from , and the positive semi-definiteness from being an orthogonal projector.
B WildCat [SM26] temperature scaling as an oblique projection
WildCat introduces an alternative rescaled scalar product in the RKHS given by for a temperature . The selection and projection steps, of and in our formulation, of WildCat, then consist in considering the orthogonal projection of the linear map in this metric. In this subsection, we provide an equivalent formulation in terms of an oblique projection in the original kernel, allowing us to represent the WildCat temperature method as an oblique Petrov-Galerkin projection. Let and for any , set and . We then have, for any , , hence . We note that is unbounded on for , so that, for , either or its inverse is unbounded. The identities below are thus to be understood on the finite spans of feature vectors, the final expression of being bounded and used as its definition. Let
be the orthogonal projector onto . Then the WildCat projector is given by the oblique projector:
and the set of exact interpolation nodes is given by . In our Petrov-Galerkin formulation, this amounts to a trial space given by and a test space given by . Thanks to the obliqueness of the projector, it extrapolates differently than the orthogonal projector and as shown in [SM26] its error can be bounded under reasonable assumptions. For the weights, this gives us,
In the Gaussian reformulation, we have, for any , and any ,
Using this, the fact that and that, for any , , we obtain that
In the gauge with centering, the two-step solve (16) then becomes
while the readout (17) is unchanged.
C Additional figures
Figures 11–14 repeat Figures 2, 3, 6 and 7 with, for every curve, the interquartile range over the 112 query heads in dashed lines of the same colour. For each head, the error is the median over the future queries of (27), as in the main text. Reference levels lying far above the curves are not drawn and their values are given in the legend.

Figure 11: Heavy hitter relative error (27) in numerator (top, ) and denominator (bottom, ) on the future queries, with and without range correction, as in Figure 2. Solid: median over the 112 query heads; dashed: interquartile range over the heads.

Figure 12: Heavy hitter relative attention error on the future queries without (top) and with (bottom) range correction, with and , as in Figure 3. Solid: median over the 112 query heads; dashed: interquartile range over the heads.

Figure 13: Heavy hitter relative attention error using GAIM exact v4 interpolation nodes for the projection methods of Table 1 and without projection (), as in Figure 6. Solid: median over the 112 query heads; dashed: interquartile range over the heads.

Figure 14: Heavy hitter relative attention error using Q-DAIM exact v5 interpolation nodes for the projection methods of Table 1 and without projection (), as in Figure 7. Solid: median over the 112 query heads; dashed: interquartile range over the heads.
Figures 15 and 16 give, for the same projections, the residual operator they leave on the keys, i.e. the relative squared norm of the augmented operator and of its denominator part, computed from , and on the context keys, the sink excluded. The GAIM exact nodes are those of the v1 variant: with the v4 nodes of Figure 6, every projection leaves the whole operator, about 0.9999 of its norm at . The Galerkin projection, the orthogonal projection in , gives the smallest residual by construction, and the least-squares projection and the values of the selected keys, , are within 0.1% of it. The revealed-range projection is larger and peaks around , where the number of nodes reaches the revealed rank. The WildCat temperature projection leaves the largest residual, above the norm of the denominator operator itself for small , although it gives the lowest attention error at the future queries in Figures 6 and 7.

GAIM (Galerkin) least squares (direct and Petrov-Galerkin) Q-DAIM revealed range WildCat temperature, no projection ( )
Figure 15: Relative squared norm of the residual operator on the keys left by each projection of Table 1, and without projection ( ), on GAIM exact v1 interpolation nodes ( score), . Left: augmented operator; right: denominator. Median over the 16 KV heads.

GAIM (Galerkin) least squares (direct and Petrov-Galerkin) Q-DAIM revealed range WildCat temperature, no projection ( )
Figure 16: Relative squared norm of the residual operator on the keys left by each projection of Table 1, and without projection ( ), on the Q-DAIM exact v5 interpolation nodes of Figure 7, . Left: augmented operator; right: denominator. Median over the 16 KV heads.
D Conditioning of the key Gram matrices
In this appendix, we illustrate the conditioning argument of §2.4.1 on the document used in §5.1. Figure 17 shows, for each layer of the model and each of its four KV heads, the condition number of the Gram matrix of the context keys, , and of the Gram matrix of the interpolation nodes, . In both cases the sink keys are excluded, and the context consists of the first 4096 tokens of the document, i.e. keys once the sinks are removed, rather than the 4096 tokens following the sinks used in §5.1. The interpolation nodes are selected either by GAIM exact, using the v2 residual in norm, or by Q-DAIM exact, where the nodes past the revealed rank are chosen as described in Appendix E.
For each of these sets of keys, we compare three Gram matrices. The first one is the Gaussian Gram matrix which, by Proposition 4, does not depend on the centering of the keys. The two others correspond to the exponential Gram matrix of (9), computed either with the keys taken at the origin or with the keys centered on their mean. The condition numbers are obtained from the eigenvalues computed in double precision, which only allows us to resolve up to . Beyond this level, we instead give the lower bound
which can be computed exactly as it only involves the diagonal of , together with the upper bound .
Over the 112 KV heads of the model, the Gaussian Gram matrix of the context keys remains well conditioned, with a median of 0.41 and a maximum of 4.1, reached in layer 0. The Gaussian Gram matrices of the 512 interpolation nodes all stay below , with medians of for Q-DAIM and for GAIM exact. On the other hand, the exponential Gram matrix of the keys taken at the origin is beyond the double-precision resolution on 105 of the 112 heads, its diagonal bound having a median of and reaching in layer 27. Centering the keys on their mean lowers these values to a median of about and to at most , although 47 heads still remain beyond the resolution. For the 512 interpolation nodes, the centered exponential Gram matrix has a median condition number of for Q-DAIM and for GAIM exact. As discussed in §2.4.1, the ill-conditioning of the interpolation problem is thus carried by the norm terms , and the solves in the Gaussian formulation remain well conditioned in every head.
Context keys
GAIM exact nodes
Q-DAIM nodes

Gaussian — exponential , origin — exponential , centred on
head, fp64 — head past fp64: (bar to ) — fp64 resolution
Figure 17: Condition number per layer of the Gram matrices of the context keys, (, left), and of the interpolation nodes selected by GAIM exact (centre) and Q-DAIM exact (right), ; sink keys excluded. Blue: Gaussian Gram (any centering); red: exponential Gram with the keys at the origin; orange: exponential Gram with the keys centred on their mean. Lines: median over the four KV heads of the layer; small marks: one KV head. Past the double-precision resolution (dotted), hollow marks give the lower bound and the bars extend to ; triangles mark the heads beyond , with the largest exponent of the layer.
E Q-DAIM past the revealed rank
The operator Gram matrix of (22) is of size . Hence, the revealed range has rank and the evaluation matrix of (24) has columns. As the column-pivoted QR of Algorithm 2 deflates the rows of in these coordinates, once pivots have been selected, the remaining rows then give zero up to numerical error and any further pivot is thus chosen on numerical noise. For the document of §5.1, we observe that the norm of the pivot drops by about fifteen orders of magnitude after the 129-th selected node, and even earlier in heads of lower numerical rank, for example after 77 nodes in a head of layer 0 and after 10 nodes in a head of layer 14. However, the nodes beyond remain useful for the interpolation. Indeed, each direction of the revealed range is in general a combination of the features of many keys. We thus select these additional nodes by restarting the selection, in one of the two following ways.
Q-DAIM exact. In this case, the range is revealed only once and the selection proceeds in blocks. Within each block, the nodes are given by the pivots of the column-pivoted QR of , so that the first block coincides with Algorithm 2. Once the residual of the block collapses, i.e. once the largest remaining squared row norm falls below times that of the first pivot of the block, we replace by
where is the projection of the Gram matrix onto the orthogonal complement of of Proposition 6. The rows of are the coordinates, in the revealed range, of the key features orthogonalized in against all the selected nodes, and a new block is started by applying the column-pivoted QR to . Furthermore, can be updated at a cost per selected node. Indeed, setting and for the selected node , we have , where the columns form the partial Cholesky factor of , which allows us to obtain the next column of at a cost .
Q-DAIM RFF. For the surrogate selection of §3.1.5, we instead proceed in rounds of nodes. After each round, the coefficients of the selected nodes are computed using the exact kernel, . The next round then reveals the range of, and selects the pivots on, the surrogate residual operator instead of , so that each round has up to new directions to reveal.
Figure 18 compares both restart procedures with the single pass of Algorithm 2, for the v1 and v5 variants. The curves coincide up to about 129 nodes, after which the restarts lower the norm of the residual operator on the keys. At , this norm decreases from (v1) and (v5) to for Q-DAIM exact, and from (v1) and (v5) to for Q-DAIM RFF, which then matches the exact selector. The attention error on the future queries, on the other hand, changes little. With range correction, the restarted selections and the single pass of Q-DAIM exact reach 0.147–0.148, compared to 0.144 for the single pass of Q-DAIM RFF. Without range correction, the restarted selections reach 0.184–0.187, compared to 0.178–0.188 for the single pass of Q-DAIM exact and 0.176–0.177 for that of Q-DAIM RFF. As observed in §5, a lower residual on the keys therefore does not necessarily translate into a lower error on the future queries.

Figure 18: Q-DAIM exact (left) and Q-DAIM RFF (right) past the revealed rank, single pass of Algorithm 2 (dashed) against the restarted selections of Appendix E (solid), for the v1 and v5 targets. Top: relative squared norm of the augmented residual operator on the keys, without sink, as in Figure 1. Middle and bottom: heavy hitter relative attention error on the future queries with , without and with range correction, as in Figure 3. Each curve is the median over the heads. Dotted vertical lines: restarts, every nodes for Q-DAIM RFF; for Q-DAIM exact, where at least half of the KV heads reset , i.e. after 128, 256 and 384 nodes for the v1 target and one node later per block for v5 (on 14 of the 16 KV heads; the other two, of lower numerical rank, reset more often).