# 1 Introduction
KQ-SVD: Compressing the KV Cache with Provable Guarantees on Attention Fidelity
Damien Lesens Beheshteh T. Rakhshan Guillaume Rabusseau
ENS de Lyon DIRO, Université de Montréal Mila DIRO, Université de Montréal Mila - CIFAR AI Chair
## Abstract
The Key–Value (KV) cache is central to the efficiency of transformer-based large language models (LLMs), storing previously computed vectors to accelerate inference. Yet, as sequence length and batch size grow, the cache becomes a major memory bottleneck. Prior compression methods typically apply low-rank decomposition to keys alone or attempt to jointly embed queries and keys, but both approaches neglect that attention fundamentally depends on their inner products. In this work, we prove that such strategies are sub-optimal for approximating the attention matrix. We introduce KQ-SVD, a simple and computationally efficient method that directly performs an optimal low-rank decomposition of the attention matrix via a closed-form solution. By targeting the true source of redundancy, KQ-SVD preserves attention outputs with higher fidelity under compression. Extensive evaluations on LLaMA and Mistral models demonstrate that our approach consistently delivers superior projection quality.
The rise of Large Language Models (LLMs) [touvron2023llama, chaplot2023albert, achiam2023gpt, guo2025deepseek] has expanded AI capabilities beyond earlier models. Transformers [vaswani2017attention] replace recurrence with self-attention, enabling parallelism and improved sequence modeling, but their quadratic memory and computation costs limit long-sequence scalability.
Key-Value (KV) caches are introduced to accelerate autoregressive generation by storing intermediate attention KV vectors, avoiding redundant computation of shared prefixes for each generated token. Although KV caching reduces computational overhead, it substantially increases memory consumption, as the cache size grows linearly with both sequence length and batch size. This trade-off motivates the development of KV cache compression techniques, which are crucial for enabling efficient and cost-effective deployment of LLMs across diverse hardware platforms [fu2024challenges, shi2024keep]. Variants like Multi-Query Attention (MQA) [shazeer2019fast] and Grouped-Query Attention (GQA) [ainslie2023GQA] reduce KV cache size by sharing or grouping query vectors while maintaining performance comparable to full Multi-Head Attention (MHA). However, they may introduce accuracy trade-offs and hardware sensitivity, which can affect performance generalization. Additional approaches, including sparse [zhang2021sparse] and linearized [katharopoulos2020transformers] attention, further reduce computational and memory costs, shaping KV cache optimization strategies.
Another promising line of research exploits the low-rank structure of KV caches to reduce memory overhead. Multi-Head Latent Attention (MLA) [liu2024deepseek, guo2025deepseek] maps tokens into the low-rank latent space and stores these compressed representations in place of the original key and value states. However, using MLA necessitates training the model from the ground up. In contrast, ASVD [yuan2024asvd], LoRC [zhang2024lorc], and Palue [changpalu] apply SVD to key-value parameter matrices without retraining to build low-rank projection modules. A key limitation of these approaches is that they often compress only the keys, neglecting the query-key interaction that underlies attention. EigenAttention [saxena2024eigen] and Zack [zhang2024zack] attempt to address this by incorporating both queries and keys in low-rank decompositions, yet their behavior largely resembles that of SVD-based methods that compress keys alone.
In this work, we address these limitations by introducing KQ-SVD, a compression method that achieves optimal low-rank approximation of the attention matrix efficiently and in closed form. Our method explicitly captures the interactions between queries and keys through their inner products, preserving the fundamental structure of attention. Beyond key-query interactions, we also consider the corresponding interactions between values and the output projection, enhancing the fidelity of the approximation. By leveraging the inherent low-rank structure of KV caches [yu2024effectively, saxena2024eigen], we formulate attention matrix approximation as a principled low-rank decomposition problem. Our theoretical analysis quantifies the error between prior key-only SVD approaches and our optimal method, and shows that methods incorporating both queries and keys can degrade when keys and queries are rescaled by the same factor, effectively behaving like key-only SVD methods. Our contributions can be summarized as follows:
- We introduce KQ-SVD, an optimal low-rank approximation of the attention matrix capturing key-query interactions.
- We theoretically quantify the advantages of KQ-SVD over methods based on key low-rank decomposition and SVD on concatenated queries and keys.
- We show that KQ-SVD is compatible with and also optimal in the Grouped-Query Attention setting.
- We provide extensive empirical evaluations with LLaMA2-7B, LLaMA2-13B, LLama3-8B and Mistral-7B models on the C4 dataset demonstrating significant advantages of KQ-SVD over existing low rank projection methods.
## 2 Related Works
#### Low-rank structure of the KV-cache.
Several methods exploit the inherent low-rank structure of cached key–value (KV) matrices to reduce memory footprint. ECKVH [yu2024effectively] compresses the cache by grouping attention heads, performing singular value decomposition (SVD) within each group, and retaining only the dominant singular components. EigenAttention [saxena2024eigen] generalizes this idea by constructing low-rank bases that jointly approximate queries, keys, and values, effectively lowering the dimensionality of KV representations. Q-Filters [godeyq] introduces a training-free variant, projecting keys into a low-rank subspace via SVD to approximate attention scores efficiently with minimal accuracy loss. Moreover, [yu2024effectively] investigates the intrinsic low-rank nature of KV caches and compresses KV heads through careful grouping and SVD-based decomposition. In contrast, Loki [singhania2024loki] adopts a two-stage strategy: it first estimates approximate attention scores in a lower-dimensional space to rank and select the most relevant keys, and then computes exact attention scores using only the selected keys, reducing both memory and computational cost.
#### KV Weights Compression.
An alternative approach targets the KV weight matrices themselves rather than the cached matrices. LoRC [zhang2024lorc] applies low-rank approximations directly to the key and value weight matrices, achieving compression at the parameter level. Palu [changpalu] follows a similar strategy, jointly compressing key and value weight matrices via SVD. ShadowKV [sun2024shadowkv] introduces a distinct perspective by performing SVD on pre-RoPE key matrices to reduce their dimensionality, demonstrating the versatility of low-rank methods in optimizing KV representations.
#### Positioning of KQ-SVD.
Although prior methods have made significant strides in compressing KV caches and their weight matrices, they often treat keys and values independently or approximate attention only indirectly, leaving the core query–key interactions underrepresented and leading to sub-optimal low rank approximation of attention matrices. KQ-SVD addresses these limitations by formulating a principled, closed-form low-rank approximation of the full attention matrix.
## 3 Preliminary
In this section, we introduce our notations and present the necessary background on Multi-Head Attention (MHA).
### 3.1 Notations
We use lower case bold letters for vectors (e.g., $a,b$ ), upper case bold letters for matrices (e.g., $A,B$ ). $A^+$ denotes the Moore–Penrose pseudo-inverse of $A$ . Throughout the paper, the singular value decomposition (SVD) of a matrix $S∈ℝ^m× n$ is presented by $S=UΣV^⊤$ , with $U∈ℝ^m× n$ , $V∈ℝ^n× n$ matrices with orthonormal columns and $Σ∈ℝ^n× n$ a diagonal matrix with positive diagonal entries $\{σ_i\}_i=1^n$ . The columns of $U$ and $V$ are called respectively the left and right singular vectors of $S$ , and the $σ_i$ ’s the singular values of $S$ , noted $σ_i(S)$ . The optimal rank- $R$ approximation of $S$ with respect to the Frobenius norm can be obtained via the SVD by truncating it to keep only the first $R$ singular vectors and singular values: ${S}≈\hat{U}\hat{Σ}\hat{V}^⊤$ with $\hat{U}∈ℝ^m× R$ , $\hat{V}∈ℝ^n× R$ and $\hat{Σ}∈ℝ^R× R$ . The column space of $S$ is noted $R(S)$ .
### 3.2 Background
In transformer architectures, self-attention assigns relative importance to tokens, enabling the model to selectively focus on different segments of the input sequence. For a sequence of token embeddings $X∈ℝ^T× D$ , multi-head attention is computed as
$$
MHA(X)=[H_1,\dots,H_h]W^O,
$$
where
$$
H_i=Softmax\Big(\frac{Q_iK_i^⊤}{√{d}}\Big)V_i,
$$
with $W_i^Q,W_i^K,W_i^V∈ℝ^D× d$ , $d=D/h$ , $Q_i=XW_i^Q$ , $K_i=XW_i^K$ , $V_i=XW_i^V$ , and $W^O∈ℝ^D× D$ . In masked attention, the upper-diagonal entries of the attention matrix $Q_iK_i^⊤$ are set to $-∞$ to prevent a token from attending to future positions.
This computation scales quadratically with the sequence length $T$ . In auto-regressive decoding, previously computed key and value vectors are cached to avoid redundant computation, reducing the per-token cost. Specifically at time $T$ , for each head, new key–value pairs are concatenated to the caches $K$ and $V$ , followed by an attention computation:
| | $\displaystyleK←$ | $\displaystyleConcat(K,k_T), V←Concat(V,\bm{v}_T),$ | |
| --- | --- | --- | --- |
where $k_T=x_TW^K$ , $\bm{v}_T=x_TW^V$ , $q_T=x_TW^Q$ . While caching mitigates redundant computation, generating the $T$ -th token still incurs $O(T)$ cost, and the memory footprint of stored keys and values grows linearly with sequence length. For sufficiently long contexts, this memory requirement becomes a dominant bottleneck, as the cumulative size of the KV cache can surpass the model parameters by several orders of magnitude. In the following sections, we briefly review the K-SVD method [changpalu, yu2024effectively, zhang2024lorc], which compresses key representations using singular value decomposition (SVD), and the Eigen approach [saxena2024eigen], which jointly considers keys and queries by vertically concatenating them and applying SVD to the resulting matrix.
### 3.3 Cache compression with SVD
Recent works [changpalu, zhang2024lorc, chang2025xkv] demonstrate that singular value decomposition (SVD) is a powerful tool for compressing the KV cache in large language models, as the cache exhibits low-rank structure. Let $K=U_KΣ_KV_K^⊤∈ℝ^T× d$ be the SVD of the key matrix, and let $\widetilde{K}=\hat{U}_K\hat{Σ}_K\hat{V}_K^⊤$ denote its rank- $R$ truncated version. By the Eckart–Young–Mirsky theorem, $\widetilde{K}$ is the best rank- $R$ approximation of $K$ under the Frobenius norm. In other words, the optimization problem
$$
\min_P∈ℝ^d× d\|KP-K\|_F^2 s.t. rank(P)≤ R,
$$
is solved by $P=\hat{V}_K\hat{V}_K^⊤$ , leading to the approximation $\widetilde{K}=K\hat{V}_K\hat{V}_K^⊤=\hat{U}_K\hat{Σ}_K\hat{V}_K^⊤$ . Applying the same procedure to the value matrix $V=U_VΣ_VV_V^⊤$ , we can approximate the attention output as
| | $\displaystyle\widetilde{H}$ | $\displaystyle=Softmax(Q\widetilde{K}^⊤/√{d})\widetilde{V}$ | |
| --- | --- | --- | --- |
This formulation is particularly useful because it allows to store only the compressed caches $K\hat{V}_K$ and $V\hat{V}_V$ in memory. These matrices are of size $R× T$ instead of $d× T$ , resulting in significant memory savings. At runtime, queries are multiplied by $\hat{V}_K$ , while $\hat{V}_V^⊤$ can be absorbed into the output projection $W_O$ , streamlining computation.
A key advantage of this approach is that the SVD does not need to be computed during token generation. Instead, it can be performed once in a post-training calibration phase. For each layer $l$ and attention head $i$ , we only need to determine a basis $V_i,l∈ℝ^d× R$ such that $K_i,l≈K_i,lV_i,l(V_i,l)^⊤$ with an analogous construction for the values. This basis can be learned from a calibration set of sequences. Specifically, we pass $n_s$ calibration sequences (e.g., sampled from a high-quality dataset such as C4 [C4]) through the model. The $k$ th sequence produces caches $K_i,l^k$ and $V_i,l^k$ for every layer $l$ and head $i$ . These are concatenated to form large cache matrices $K_i,l=\begin{pmatrix}K_i,l^1,K_i,l^2,\dots,K_i,l^n_s\end{pmatrix}$ . This aggregated cache provides a representative sample of the key vectors that will appear during inference. Performing SVD on $K_i,l$ then yields the dominant singular vectors, which form a suitable low-rank basis for compression. The cost of generating calibration caches and computing the SVDs is negligible compared to model training, and is offset by the runtime speedups from cache compression. In the following, we will refer to this method as K-SVD.
Rank selection. The compression rank $R$ is determined per layer by examining the singular value spectrum. Let $\{σ_j\}_j$ denote the singular values of a matrix $M$ . For a relative error tolerance $ε$ , we select the smallest $R$ such that
$$
\|M-\widetilde{M}\|_F^2≤ε\|M\|_F^2⇔\frac{∑_j=1^Rσ_j^2}{∑_i=1^dσ_j^2}≥ 1-ε.
$$
Prior studies [yu2024effectively, saxena2024eigen] have shown that KV matrices are indeed approximately low-rank, so substantial compression can be achieved with small error budget $ε$ . The chosen rank may differ for keys and values depending on their spectra.
### 3.4 Cache compression with Eigen
Other works [saxena2024eigen, zhang2024zack] emphasize that queries should also be considered when compressing key caches. Indeed, by projecting the key cache we also project the query matrix: $Q\hat{V}_K\hat{V}_K^⊤K^⊤=(Q\hat{V}_K\hat{V}_K^⊤)(K\hat{V}_K\hat{V}_K^⊤)^⊤$ as $\hat{V}_K\hat{V}_K^⊤$ is an idempotent matrix. Hence, it makes sense to compute the low rank projection by solving
$$
\min_S\|K-KS\|_F^2+\|Q-QS\|_F^2 s.t. rank(S)≤ R,
$$
which is equivalent to
$$
\min_S≤ft\|\begin{bmatrix}K\\
Q\end{bmatrix}-\begin{bmatrix}K\\
Q\end{bmatrix}S\right\|_F^2 s.t. rank(S)≤ R,
$$
so that $S$ will approximate queries and keys simultaneously. As the second formulation of the optimization problem shows, $S$ can be computed by performing an SVD on the combined matrix $\begin{bmatrix}K\ Q\end{bmatrix}$ . This approach ensures that the learned projection preserves keys and queries while reducing dimensionality. We refer to this approach as Eigen throughout this paper. The calibration process follows the same procedure as K-SVD: large calibration caches are formed by using a collection of calibration sequences. The only difference is that query matrices from the calibration set are also used in the projection computation.
## 4 Methodology
In this section, we introduce our proposed approach KQ-SVD for KV cache compression. We consider taking the interaction between queries and keys into account. The method views the key and query matrices as a single entity and applies singular value decomposition (SVD) to $KQ^⊤$ . We begin by outlining the motivation behind this idea, followed by a detailed explanation of the technique.
### 4.1 Motivation
Existing compression methods based on SVD typically compress keys or jointly embed $Q/K/V$ . Theorem 1 (proof in Appendix A) inspired by [wang2025squat] shows why that can fail: perturbations in $K$ are amplified by the inner products $QK^⊤$ and further propagated by the value multiplication.
**Theorem 1**
*Let $X∈ℝ^T× d$ be a sequence of token embeddings, $K,Q,V∈ℝ^T× d$ and
$$
MHA(X)=\big[Softmax(Q_iK_i^⊤/√{d})V_i)\big]_iW^O,
$$
$$
\widetilde{MHA}(X)=\big[Softmax(Q_i\widetilde{K_i}^⊤/√{d})\widetilde{V_i})\big]_iW^O,
$$
where $\widetilde{MHA}(X),\widetilde{K_i}$ and $\widetilde{V_i}$ represent the approximation of $MHA(X),K_i$ and $V_i$ , respectively. The difference between the actual attention output and the one produced with approximate keys and values is upper bounded as
$$
\displaystyle\|\widetilde{MHA}(X)-MHA(X)\|_2 \displaystyle≤∑_i=1^h\frac{\|V_iW_i^O\|_2}{√{d}}\|Q_iK_i^⊤-Q_i\widetilde{K_i}^⊤\|_2 \displaystyle+\|V_iW_i^O-\widetilde{V_i}W_i^O\|_2. \tag{1}
$$*
The method proposed by this paper stems from the will to minimize this upper bound on the output approximation error. In each attention head, for a key cache $K$ and a calibration set of query vectors $\{q^(j)\}_j∈calibration$ (row vectors of size $d$ ), we want to minimize
$$
∑_j∈calibration\|q^(j)K^⊤-q^(j)\widetilde{K}^⊤\|_2^2,
$$
over low-rank $\widetilde{K}$ . This objective is equivalent to a low-rank approximation of the query–key interaction matrix and admits an optimal closed-form solution via the singular value decomposition. Similarly, to compress values we directly optimize the second term of Eq. (Theorem) over low-rank $\widetilde{V}$ for each attention head (see Appendix B).
### 4.2 Proposed Method
In the following, we drop the head index $i$ for ease of clarity. Our method addresses cache compression by producing an optimal solution to
$$
\min_\widetilde{K}\|QK^⊤-Q\widetilde{K}^⊤\|_F^2 s.t. rank(\widetilde{K})≤ R,
$$
with $Q=\begin{pmatrix}q^(j)\end{pmatrix}_j∈calibration$ the collection of query vectors from the calibration set. This formulation jointly considers the properties of both $K$ and $Q$ , while taking into account their interaction through the inner product. The optimization problem can be restated using a projection matrix as
$$
\min_S\|KSQ^⊤-KQ^⊤\|_F^2~~~~~~s.t.~~~rank(S)≤ R,
$$
where $S∈ℝ^d× d$ . To be able to compress the key cache during the attention computation, we write the projection matrix $S$ as a product of two matrices, i.e., $S=AB$ with $A,B∈ℝ^d× R$ . The minimization problem tackled by KQ-SVD is thus
$$
\displaystyle\min_A,\mathbf{B∈ℝ^d× R}\|KAB^⊤Q^⊤-KQ^⊤\|_F^2. \tag{2}
$$
Given $A^*$ and $B^*$ the solutions of this optimization problem, we store the low-rank matrix $KA^*∈ℝ^T× R$ , which allows for compression while maintaining an accurate reconstruction of the attention matrix. The same strategy also applies to the value–output matrices (see Appendix B). In the next section, we state the main theorem which demonstrates that the optimization problem described above admits an optimal solution which can be computed efficiently.
### 4.3 KQ-SVD: Optimal attention factorization
The following theorem establishes the provably optimal low-rank factorization of the key–query matrix, which admits a simple closed-form solution.
**Theorem 2**
*Let $K,Q∈ℝ^T× d$ be key and query cache matrices. The optimal solution to the low rank attention approximation problem
$$
\min_A,\mathbf{B∈ℝ^d× R}\|KAB^⊤Q^⊤-KQ^⊤\|_F,
$$
is given by
$$
A=K^+\hat{U}, B=K^T\hat{U},
$$
where $\hat{U}∈ℝ^T× R$ is the matrix having the top $R$ left singular vectors of $KQ^⊤$ as columns.*
* Proof*
Observe that $KAB^⊤Q^⊤$ has rank at most $R$ . Hence,
$$
\min_A,\mathbf{B∈ℝ^d× R}\|KAB^⊤Q^⊤-KQ^⊤\|_F,
$$
is lower bounded by
$$
\min_M∈ℝ^T× T\|M-KQ^⊤\|_F s.t. rank(M)≤ R.
$$
By the Eckart-Young theorem, we know the best rank $R$ approximation of $KQ^⊤$ is given by its truncated SVD:
$$
KQ^⊤≃\hat{U}\hat{Σ}\hat{V}^⊤,
$$
where $\hat{U}∈ℝ^T× R,\hat{Σ}∈ℝ^R× R$ and $\hat{V}∈ℝ^T× R$ . We will show that $KAB^⊤Q^⊤=\hat{U}\hat{Σ}\hat{V}^⊤$ from which the optimality of $A$ and $B$ follows. Let $K=UΣV$ be the full SVD of $K$ . Observe that we have the inclusion of (column) spans: $R(\hat{U})⊆R(U)=R(K)$ . Since $KK^+$ is the orthogonal projection onto $R(K)$ , we have $KK^+\hat{U}=\hat{U}$ , hence
| | $\displaystyleKAB^⊤Q^⊤$ | $\displaystyle=KK^+\hat{U}\hat{U}^⊤KQ^⊤=\hat{U}\hat{U}^⊤KQ^⊤$ | |
| --- | --- | --- | --- |
Therefore $A=K^+\hat{U}$ and $B=K^⊤\hat{U}$ are optimal solutions to $\min_A,\mathbf{B∈ℝ^d× R}\|KAB^⊤Q^⊤-KQ^⊤\|_F$ . ∎
The Moore-Penrose pseudo inverse of $K$ can be expressed through the SVD of $K$ as $K^+=V_KΣ^-1_KU_K^⊤$ . The singular value decomposition of $KQ^⊤∈ℝ^T× T$ can be computed efficiently as its rank is at most $d$ . Indeed, we can first perform an SVD on $K=U_KΣ_KV_K^⊤$ and $Q=U_QΣ_QV_Q^⊤$ , then on the $d× d$ matrix $Σ_KV_K^⊤V_QΣ_Q=U^\primeΣ^\primeV^\prime⊤$ . The SVD of $KQ^⊤$ is then $U_KU^\primeΣ^\prime(V_QV^\prime)^⊤=UΣV^⊤$ with $U=U_KU^\prime∈ℝ^T× d$ and $V=V_QV^\prime∈ℝ^T× d$ . This way the optimal solution provided by Theorem 2 can be computed efficiently in time $O(Td^2)$ .
A similar approach is used by KQ-SVD to derive optimal projections for the low rank approximation of the product of the value cache with the output matrix (see Appendix B).
## 5 Theoretical analysis
In this section, we focus on the minimization problem in Eq. (5); the same reasoning applies to value and output matrices (see Appendix B). We first provide an exact formula quantifying the accuracy difference between K-SVD and KQ-SVD. We then exhibit a failure mode of Eigen method [saxena2024eigen] which KQ-SVD circumvent by design. Finally, we show how KQ-SVD also obtains optimal low rank approximation in the Grouped Query Attention (GQA) framework.
### 5.1 Comparing K-SVD and KQ-SVD
In this section, we characterize the optimality gap between KQ-SVD and K-SVD (Section 3.3) and derive a closed form expression of their accuracy difference.
**Theorem 3**
*Let $opt=\min_A,\mathbf{B∈ℝ^d× R}\|KAB^⊤Q^⊤-KQ^⊤\|_F^2$ be the optimal error for the low rank attention approximation problem (achieved by KQ-SVD), and let $err_K-SVD=\|K\hat{V}_K\hat{V}_K^TQ^T-KQ^T\|_F^2$ be the error of K-SVD. We have
$$
err_K-SVD-opt=∑_i=1^Rσ_i(KQ^⊤)^2-\|K\hat{V}_K\hat{V}_K^TQ^T\|^2_F≥ 0,
$$
with equality only if the top $R$ left singular vectors of $K$ and the top $R$ of $KQ^⊤$ span the same subspace.*
* Proof*
Let $K≈\hat{U}_K\hat{Σ}_K\hat{V}_K^⊤$ be the rank $R$ truncated SVD of $K$ and $KQ^⊤≈\hat{U}\hat{Σ}\hat{V}^⊤$ be the one of $KQ^⊤$ . By Theorem 2, $opt=\|\hat{U}\hat{U}^⊤KQ^T-KQ^T\|_F^2=∑_i=R+1^dσ_i(KQ^T)^2$ . On the one hand we have
| | $\displaystyle\|KQ^T\|_F^2=∑_i=1^dσ_i(KQ^T)^2=∑_i=1^Rσ_i(KQ^T)^2+opt.$ | |
| --- | --- | --- | On the other hand,
| | $\displaystyle\|KQ^⊤\|_F^2=\|KQ^⊤-\hat{U}_K\hat{U}_K^⊤KQ^⊤+\hat{U}_K\hat{U}_K^⊤KQ^⊤\|_F^2$ | |
| --- | --- | --- |
since $(I-\hat{U}_K\hat{U}_K^⊤)$ and $\hat{U}_K\hat{U}_K^⊤$ are projections on orthogonal subspaces. Since $K\hat{V}_K\hat{V}_K^⊤=\hat{U}_K\hat{U}_K^⊤K$ , the left term is exactly $err_K-SVD$ and the second term can be reduced to $\hat{U}_K\hat{U}_K^⊤KQ^⊤=K\hat{V}_K\hat{V}_K^⊤Q^⊤$ . Putting everything together, we get
$$
∑_i=1^Rσ_i(KQ^T)^2+opt=err_K-SVD+\|K\hat{V}_K\hat{V}_K^⊤Q^⊤\|_F^2,
$$
which shows the equality in the theorem. To show that $err_K-SVD-opt≥ 0$ , first observe that
$$
err_K-SVD-opt=\|\hat{U}\hat{U}^⊤KQ^⊤\|-\|\hat{U}_K\hat{U}_K^⊤KQ^⊤\|.
$$
A direct consequence of the Eckart-Young theorem is that, for any matrix $M∈ℝ^T× T$ and any $R≤ T$ , the solution of
$$
\max_X∈ℝ^T× R\|XX^⊤M\|~~~s.t.~~ X^⊤X=I
$$
is obtained by setting the columns of $X$ to the top $R$ left singular vectors of $M$ . Hence, $\|\hat{U}\hat{U}^⊤KQ^⊤\|≥\|\hat{U}_K\hat{U}_K^⊤KQ^⊤\|$ and thus $err_K-SVD-opt≥ 0$ , with equality only if $\hat{U}\hat{U}^⊤=\hat{U}_K\hat{U}_K^⊤$ , i.e., when the top $R$ left singular vectors of $K$ and the top $R$ of $KQ^⊤$ span the same subspace. ∎
It is worth observing that equality between $err_K-SVD$ and $opt$ happens only when the projection onto $\hat{V}_K$ captures all of the energy (Frobenius norm) in the top $R$ singular values of $KQ^⊤$ . Since the best rank- $R$ approximation in the Frobenius norm is unique, this holds precisely when the subspace spanned by the top $R$ left singular vectors of $K$ coincides with that spanned by the top $R$ left singular vectors of $KQ^⊤$ . In other words, equality holds precisely when these two subspaces match.
### 5.2 Comparing Eigen and KQ-SVD
We now compare Eigen [saxena2024eigen] with KQ-SVD. Although we do not derive an exact value for the optimality gap of Eigen, we identify a critical limitation of Eigen: the method is highly sensitive to unbalance between the norms of $K$ and $Q$ . Eigen’s performance can be degraded simply by multiplying $K$ by a constant $β$ and dividing $Q$ by the same constant. While this rescaling leaves the attention computation unchanged and does not affect KQ-SVD, it causes Eigen method to behave increasingly like K-SVD as the unbalance between the two norms grows. Theorem 4 formalizes this intuition.
**Theorem 4**
*Let $K,Q∈ℝ^T× d$ , let $α=\frac{\|Q\|_F}{\|K\|_F}$ and let $err_Eigen=\|K\hat{V}_Eigen\hat{V}_Eigen^⊤Q^⊤-KQ^⊤\|$ be the error of Eigen. If there is a non-trivial gap between the $R$ th and $(R+1)$ th singular values of $K$ , i.e. $σ_R(K)>σ_R+1(K)$ , then $\lim_α→ 0err_Eigen=err_K-SVD$ .*
* Proof*
Recall that Eigen approximate $KQ^⊤$ with $K\hat{V}_Eig\hat{V}_Eig^⊤Q^⊤$ where $\hat{V}_Eig$ is the matrix with the top $R$ right singular vectors of $\begin{bmatrix}K\ Q\end{bmatrix}$ as columns. In the limit where $\frac{\|Q\|_F}{\|K\|_F}$ tends to $0$ , the concatenated matrix $\begin{bmatrix}K\ Q\end{bmatrix}$ tends to $\begin{bmatrix}K\ 0\end{bmatrix}$ . Since $σ_R(K)>σ_R+1(K)$ , it follows from the Davis-Kahan theorem [davis1970rotation] that, as $α$ tends to $0$ , the space spanned by the top $R$ right singular vectors of $\begin{bmatrix}K\ Q\end{bmatrix}$ converges to the one of $\begin{bmatrix}K\ 0\end{bmatrix}$ , and thus of $K$ . Hence $\lim_α→ 0\hat{V}_Eig\hat{V}_Eig^⊤=\hat{V}_K\hat{V}_K^⊤$ and $err_Eigen$ tends to $err_K-SVD$ . ∎
### 5.3 Handling grouped query attention
Standard multi-head attention (MHA) is powerful but slow at inference, while multi-query attention (MQA) [shazeer2019fast] is much faster but can hurt model quality and requires retraining. Grouped-query attention (GQA) [ainslie2023GQA], sits in between MHA and MQA by letting groups of query heads share a key-value head, balancing accuracy and performance. GQA organizes attention/query heads into groups of size $m$ . All query heads within a group share the same set of keys and values, enabling more efficient computation without significantly compromising model performance. We have assumed in the presentation of our method that each key head attends to a single query head. We show in the following theorem that simply applying KQ-SVD on the shared key cache and the concatenated query caches provides the optimal approximation with GQA.
**Theorem 5**
*Given a (shared) key cache matrix $K∈ℝ^T× d$ and $m$ full column rank query cache matrices $Q_1,⋯,Q_m∈ℝ^T× d$ , solving
$$
\min_A,\mathbf{B_1,⋯,B_m∈ℝ^d× R}∑_i=1^m\|KAB_i^⊤Q_i^⊤-KQ_i^⊤\|^2_F,
$$
is equivalent to solving
$$
\min_A,\mathbf{B∈ℝ^d× R}\|KAB^⊤Q^⊤-KQ^⊤\|^2_F,
$$
where $Q=[Q_1^⊤ Q_2^⊤ ⋯ Q_m^⊤]^⊤∈ℝ^mT× d$ is the matrix obtained by stacking the $m$ query matrices.*
* Proof*
We first show that the solution matrices $B_i$ can be chosen to be all equal, i.e., that solving
$$
\min_A,\mathbf{B_1,⋯,B_m∈ℝ^d× R}∑_i=1^m\|KAB_i^⊤Q_i^⊤-KQ_i^⊤\|^2_F,
$$
is equivalent to solving
$$
\min_A,\mathbf{B∈ℝ^d× R}∑_i=1^m\|KAB^⊤Q_i^⊤-KQ_i^⊤\|^2_F.
$$
Indeed, for any $A$ and any $i$ , since $Q_i^⊤$ is full row rank, the minimizers of $\min_B_i\|KAB_i^⊤Q_i^⊤-KQ_i^⊤\|^2_F$ are the same as the minimizers of $\min_B_i\|KAB_i^⊤-K\|^2_F$ , and are thus independent of $Q_i$ . Since this is true for any $A$ , and in particular for the optimal one, this shows that all the solutions $B_i$ can be taken to be equal. The result then directly follows from the fact that the squared Frobenius norm of a block matrix is equal to the sum of the squared Frobenius norms of the blocks. ∎
Theorem 5 states that optimal projections can be computed for models using GQA by stacking query matrices in each group and using KQ-SVD as in the non GQA case. Computing the optimal projection for a head group costs $O(mTd^2)$ , where $m$ is the size of the head group, leading to an amortized cost per query head of $O(Td^2)$ .
## 6 Experiments
<details>
<summary>x1.png Details</summary>

### Visual Description
## Line Graphs and Bar Charts: Model Performance Comparison
### Overview
The image contains four sets of comparative graphs analyzing the performance of different neural network models (Llama2-7B, Llama2-13B, Llama3-8B, Mistral-7B-v0.3) across three optimization methods (K-SVD, Eigen, KQ-SVD). Each model has two subplots:
1. **Line Graph**: Output error per layer (0–40 layers)
2. **Bar Chart**: Mean relative error across components (K, Q, V, Attn, Output)
### Components/Axes
#### Line Graphs
- **X-axis**: Layer (0–40)
- **Y-axis**: Output error per layer (0–0.6)
- **Legend**:
- Blue: K-SVD
- Red: Eigen
- Green: KQ-SVD
- **Legend Position**: Top-left corner
#### Bar Charts
- **X-axis**: Components (K, Q, V, Attn, Output)
- **Y-axis**: Mean relative error (log scale: 10⁻²–10⁰)
- **Legend**: Same as line graphs (blue, red, green)
- **Legend Position**: Top-right corner
### Detailed Analysis
#### Line Graph Trends
1. **Llama2-7B**:
- K-SVD (blue) starts at ~0.5 error, fluctuates, and stabilizes near 0.3.
- Eigen (red) and KQ-SVD (green) begin lower (~0.3–0.4), with KQ-SVD showing the steepest decline to ~0.15 by layer 30.
- **Key Outlier**: K-SVD spikes to ~0.6 at layer 10.
2. **Llama2-13B**:
- All methods converge to ~0.2–0.3 error by layer 40.
- KQ-SVD (green) maintains the lowest error throughout.
3. **Llama3-8B**:
- K-SVD (blue) shows erratic fluctuations, peaking at ~0.5.
- Eigen (red) and KQ-SVD (green) stabilize near 0.1–0.2.
4. **Mistral-7B-v0.3**:
- K-SVD (blue) has a sharp spike at layer 10 (~0.5) but recovers.
- KQ-SVD (green) remains consistently below 0.2.
#### Bar Chart Trends
- **K Component**:
- KQ-SVD (green) consistently outperforms others (10⁻²–10⁻¹ range).
- Eigen (red) and K-SVD (blue) show similar performance (~10⁻¹).
- **Q Component**:
- KQ-SVD (green) achieves the lowest error (~10⁻²).
- Eigen (red) and K-SVD (blue) are comparable (~10⁻¹).
- **V Component**:
- KQ-SVD (green) dominates (~10⁻²).
- Eigen (red) and K-SVD (blue) overlap (~10⁻¹).
- **Attn Component**:
- KQ-SVD (green) is ~10⁻², while Eigen (red) and K-SVD (blue) are ~10⁻¹.
- **Output Component**:
- KQ-SVD (green) leads (~10⁻²).
- Eigen (red) and K-SVD (blue) are ~10⁻¹.
### Key Observations
1. **KQ-SVD Superiority**:
- Consistently achieves the lowest output error and mean relative error across all models and components.
- Stabilizes faster than other methods in line graphs.
2. **Eigen Competitiveness**:
- Matches KQ-SVD in some components (e.g., Q in Llama2-13B) but lags in others.
3. **K-SVD Limitations**:
- High initial errors and instability (e.g., Llama2-7B layer 10 spike).
4. **Model-Specific Behavior**:
- Llama2-13B and Mistral-7B-v0.3 show better convergence than Llama2-7B and Llama3-8B.
### Interpretation
The data demonstrates that **KQ-SVD** is the most effective optimization method for reducing both per-layer output error and mean relative error across components. Its consistent performance suggests robustness in handling model-specific complexities. **Eigen** serves as a viable alternative but lacks the consistency of KQ-SVD. **K-SVD** underperforms, particularly in early layers, indicating potential instability or suboptimal parameter tuning.
The trends imply that layer depth influences error dynamics: models with deeper architectures (e.g., Llama2-13B) exhibit smoother convergence, while shallower models (e.g., Llama2-7B) show more variability. The **Attn component** consistently exhibits higher errors, highlighting attention mechanisms as critical for optimization.
This analysis underscores the importance of method selection in neural network optimization, with KQ-SVD emerging as the optimal choice for minimizing errors in transformer-based models.
</details>
Figure 1: Relative Frobenius approximation output error per layer (top) and mean relative errors on $K$ , $Q$ , $V$ , $KQ^⊤$ and attention layer output across layers (bottom) for Mistral and Llama models.
The theoretical results established in the previous sections require further validation on real cache matrices generated by state-of-the-art LLMs. In this section, we first compare KQ-SVD with K-SVD and Eigen, and then demonstrate the claim of Theorem 4 using real-world cache data.
### 6.1 Comparing methods
Setup: To validate our theoretical claims, we run experiments on several widely used LLMs. We test two models without grouped-query attention (GQA)—Llama2-7B and Llama2-13B [touvron2023llama] —and two models with GQA—Llama3-8B [grattafiori2024llama] and Mistral-7B-v0.3 [jiang2023mistral7b]. All experiments use the C4 dataset [C4], with projections learned on the training split and evaluated on the validation split.
Learning projections: Following the methodology of saxena2024eigen, we select 128 training sequences of 2048 tokens each from C4. Each sequence is passed through the model, storing the key, value, and query caches for every layer and attention head (queries are needed by both Eigen and KQ-SVD). For each layer–head pair, we collect the corresponding caches from all 128 sequences and concatenate them, yielding large matrices $K,Q,V∈ℝ^T_huge× d$ with $T_huge=262{,}144$ . Because model context length is limited and attention cost scales quadratically with sequence length, it is not feasible to build these matrices from a single long sequence. Instead, we construct them from multiple shorter ones. Once the large cache matrices are formed, we perform SVD and apply the formulas presented in previous sections to compute low-rank projections.
Rank selection: All methods are evaluated at the same rank $R$ , determined individually for each layer. For a given layer, we analyze the singular value spectra of the key and value matrices, averaged across heads, and choose the smallest $R$ that discards no more than an $ε=0.1$ fraction of the spectral energy. That is, for singular values $\{σ_j\}_j$ of $K$ , $\frac{∑_j=1^Rσ_j^2}{∑_i=1^dσ_j^2}≥ 1-ε$ . This is equivalent to requiring that the relative Frobenius error is at most $ε$ .
Evaluation: We evaluate the learned projections on 32 validation sequences of 2048 tokens each. For every sequence, we extract the cache matrices ( $K,Q,V$ ) at each layer and head. Using these matrices, we can simulate attention computations directly, since attention depends only on these three components. Each cache is projected onto its corresponding low-rank subspace to form approximations, and we then compute the approximate Multi-Head Attention output using the standard formulas. For comparison, we also compute the exact (uncompressed) attention output. This enables us to measure the relative error of each method across all matrices of the attention pipeline. Errors are averaged across validation sequences.
Metrics: For a matrix $M$ and its approximation $\widetilde{M}$ , we report the relative Frobenius norm error $err_Fro=\frac{\|M-\widetilde{M}\|_F^2}{\|M\|_F^2}$ . This error is computed for the key, query, and value matrices, for the attention score matrix $KQ^⊤$ , and for the Multi-Head Attention output $MHA(X)$ .
Results: Results are shown in Figure 1. For each model, the top plot reports the relative error on the attention output across layers, while the bottom plot reports the averaged errors on the intermediate components. We observe that K-SVD provides the most accurate approximation of the key matrices (as expected from the optimality of SVD), but performs poorly on query matrices, leading to weaker approximations of the attention scores and consequently higher output errors. This effect is more pronounced in GQA models, where sharing the key matrix across queries in a group amplifies approximation errors.
In contrast, Eigen and KQ-SVD achieve comparable accuracy on keys, queries, and values. The key difference lies in the attention score matrix: KQ-SVD consistently delivers higher accuracy, resulting in lower attention errors and outperforming all other methods on all models.
### 6.2 Unbalanced $K$ and $Q$ matrices
We verify experimentally the claims of Section 5.2 and analyze the attention approximation error under unbalanced $K$ and $Q$ matrices.
Set up: We follow the same experimental setup as in the previous section using the C4 train/validation split to learn projections and evaluate their accuracy. The only difference is that cache matrices are scaled to assess the effect of unbalance. Key matrices are multiplied by $β$ and query matrices are divided by $β$ . This is equivalent to scaling the projection matrices $W_K,i$ / $W_Q,i$ by $β$ , as the operation permutes with matrix multiplication (this does not change the output since the query and key matrices are multiplied before any non-linear activation).
Metrics: For each unbalance ratio, we plot the relative attention output error for the three methods, averaged across all layers and validation sequences.
Results: Results are shown in Figure 2. As discussed in Section 5.2, K-SVD and KQ-SVD are invariant to scaling $K$ by a factor $β$ and dividing $Q$ by the same factor, which is confirmed by the constant error observed for these methods. As predicted theoretically, a higher unbalance ratio brings Eigen closer to K-SVD; for $β=10$ , their errors are nearly indistinguishable. This confirms Theorem 4 and exposes a limitation of Eigen, which underperforms even under modest query-key unbalance.
<details>
<summary>x2.png Details</summary>

### Visual Description
## Scatter Plot: Relative Attention Computation Output Error vs Unbalance Factor
### Overview
The image is a scatter plot comparing three algorithms (KQ-SVD, K-SVD, Eigen) across an unbalance factor range (1-10). The y-axis measures relative computation output error, while the x-axis represents the unbalance factor. Three distinct data series are plotted with different colors and markers.
### Components/Axes
- **X-axis**: Unbalance factor (integer values 1-10, labeled "Unbalance factor")
- **Y-axis**: Relative Attention Computation Output Error (continuous scale from 0.275 to 0.375)
- **Legend**: Located in the top-right corner, with:
- Green circles: KQ-SVD
- Blue circles: K-SVD
- Red circles: Eigen
- **Data Points**:
- KQ-SVD (green): 10 points at y=0.275 across all x-values
- K-SVD (blue): 10 points at y=0.375 across all x-values
- Eigen (red): 10 points showing a linear increase from y=0.28 (x=1) to y=0.38 (x=10)
### Detailed Analysis
1. **KQ-SVD (Green)**:
- All 10 data points cluster at y=0.275
- No variation across unbalance factors
- Spatial pattern: Horizontal line at bottom of plot
2. **K-SVD (Blue)**:
- All 10 data points cluster at y=0.375
- No variation across unbalance factors
- Spatial pattern: Horizontal line at top of plot
3. **Eigen (Red)**:
- Linear progression from (1, 0.28) to (10, 0.38)
- Each subsequent point increases by ~0.01 in error
- Spatial pattern: Diagonal upward trend from bottom-left to top-right
### Key Observations
- KQ-SVD demonstrates perfect stability (zero error variation)
- K-SVD shows maximum error but no sensitivity to unbalance
- Eigen exhibits predictable error growth (0.01 error per unbalance factor unit)
- All algorithms maintain consistent performance within their respective error ranges
- No overlapping data points between series
### Interpretation
The plot reveals fundamental differences in algorithmic behavior:
1. **KQ-SVD** appears most efficient, maintaining minimal error regardless of unbalance
2. **K-SVD** consistently underperforms with highest error but shows no degradation
3. **Eigen**'s error increases linearly with unbalance, suggesting potential scalability issues
4. The 0.1 error difference between KQ-SVD and K-SVD indicates significant performance disparity
5. Eigen's predictable error growth could enable error compensation strategies
The data suggests KQ-SVD is optimal for unbalanced scenarios, while Eigen's performance degradation might require mitigation techniques for high-unbalance applications.
</details>
Figure 2: Llama2-7B relative output approximation error averaged across layers for varying unbalanced factor $β$ .
## 7 Conclusion
We introduced KQ-SVD, a novel approach for computing low-rank projections for KV cache compression. KQ-SVD is driven by minimizing an upper bound on the attention output approximation error, resulting in an optimization problem that yields the optimal low-rank approximation of the attention matrix. Crucially, this problem admits a closed-form solution that can be computed efficiently. We quantify the advantage of KQ-SVD over previous methods, either through exact error formulas or by highlighting failure modes of prior approaches. Our technique is complementary to popular cache compression methods such as GQA. Experiments validate our theoretical findings and demonstrate that considering the interaction between queries and keys—as KQ-SVD—provides a superior alternative to performing SVD on the key cache or on concatenated keys and queries.
### Acknowledgment
This research is supported by the Canadian Institute for Advanced Research (CIFAR AI chair program). This work was completed while Damien Lesens interned at Mila. This work made use of compute resources provided by the Digital Research Alliance of Canada and by Mila (mila.quebec).
## KQ-SVD: Compressing the KV Cache with Provable Guarantees on Attention Fidelity (Supplementary Material)
## Appendix A Proof of Theorem 1
**Theorem**
*Let $X∈ℝ^T× d$ be a sequence of token embeddings, $K,Q,V∈ℝ^T× d$ and
$$
MHA(X)=\big[Softmax(Q_iK_i^⊤/√{d})V_i)\big]_iW^O,
$$
$$
\widetilde{MHA}(X)=\big[Softmax(Q_i\widetilde{K_i}^⊤/√{d})\widetilde{V_i})\big]_iW^O,
$$
where $\widetilde{MHA}(X),\widetilde{K_i}$ and $\widetilde{V_i}$ represent the approximation of $MHA(X),K_i$ and $V_i$ , respectively. The difference between the actual attention output and the one produced with approximate keys and values is upper bounded as
$$
\displaystyle\|\widetilde{MHA}(X)-MHA(X)\|_2 \displaystyle≤∑_i=1^h\frac{\|V_iW_i^O\|_2}{√{d}}\|Q_iK_i^⊤-Q_i\widetilde{K_i}^⊤\|_2 \displaystyle+\|V_iW_i^O-\widetilde{V_i}W_i^O\|_2. \tag{3}
$$*
* Proof*
Let $W^O=[W^O_1;W^O_2;⋯;W^O_h]∈ℝ^D× D$ , where $W^O_i∈ℝ^d× D$ are stacked vertically. By the definition of multi-head attention (see Section 3.2), we can write
$$
MHA(X)=[H_1,\dots,H_h]W^O=∑_i=1^hH_iW^O_i, \widetilde{MHA}(X)=[\widetilde{H}_1,\dots,\widetilde{H}_h]W^O=∑_i=1^h\widetilde{H}_iW^O_i.
$$
Therefore,
$$
\|\widetilde{MHA}(X)-MHA(X)\|_2=≤ft\|∑_i=1^h(\widetilde{H}_i-H_i)W^O_i\right\|_2≤∑_i=1^h\|(\widetilde{H}_i-H_i)W^O_i\|_2.
$$ For each head $i∈\{1,…,h\}$ ,
$$
\displaystyle\|(\widetilde{H}_i-H_i)W^O_i\|_2 \displaystyle=\big\|\big(Softmax(\tfrac{Q_iK_i^⊤}{√{d}})V_i-Softmax(\tfrac{Q_i\widetilde{K}_i^⊤}{√{d}})\widetilde{V}_i\big)W^O_i\big\|_2 \displaystyle≤\big\|\big(Softmax(\tfrac{Q_iK_i^⊤}{√{d}})-Softmax(\tfrac{Q_i\widetilde{K}_i^⊤}{√{d}})\big)V_iW^O_i\big\|_2+\big\|Softmax(\tfrac{Q_i\widetilde{K}_i^⊤}{√{d}})(V_i-\widetilde{V}_i)W^O_i\big\|_2. \tag{4}
$$ For the first term in (4), applying the submultiplicative property of the 2-norm gives
$$
\big\|\big(Softmax(\tfrac{Q_iK_i^⊤}{√{d}})-Softmax(\tfrac{Q_i\widetilde{K}_i^⊤}{√{d}})\big)V_iW^O_i\big\|_2≤\|Softmax(\tfrac{Q_iK_i^⊤}{√{d}})-Softmax(\tfrac{Q_i\widetilde{K}_i^⊤}{√{d}})\|_2 \|V_iW^O_i\|_2.
$$
The factor $\|V_iW^O_i\|_2$ acts as an amplification term, capturing how sensitivity in the value projections may magnify small perturbations in the attention weights—this term is typically not directly controllable in practice. Since the Softmax function is $\tfrac{1}{2}$ -Lipschitz continuous (see Appendix A.4 [alghamdi2022beyond]), we have
$$
\|Softmax(\tfrac{Q_iK_i^⊤}{√{d}})-Softmax(\tfrac{Q_i\widetilde{K}_i^⊤}{√{d}})\|_2≤\frac{1}{√{d}}\|Q_iK_i^⊤-Q_i\widetilde{K}_i^⊤\|_2.
$$ For the second term in (4), note that $\|Softmax(·)\|_1=1$ , implying $\|Softmax(·)\|_2≤ 1$ . Therefore,
$$
\big\|Softmax(\tfrac{Q_i\widetilde{K}_i^⊤}{√{d}})(V_i-\widetilde{V}_i)W^O_i\big\|_2≤\|V_iW^O_i-\widetilde{V}_iW^O_i\|_2.
$$ Combining the two bounds yields
$$
\|(\widetilde{H}_i-H_i)W^O_i\|_2≤\frac{\|V_iW^O_i\|_2}{√{d}}\|Q_iK_i^⊤-Q_i\widetilde{K}_i^⊤\|_2+\|V_iW^O_i-\widetilde{V}_iW^O_i\|_2.
$$
Summing over all heads $i=1,…,h$ gives the desired bound (Theorem), completing the proof. ∎
## Appendix B Value-Output Projection
In this section, we examine the interaction between the value representations and the output projection. While the main analysis of this paper focuses on the relationship between keys and queries, the same reasoning naturally extends to values $V_i∈ℝ^T× d$ and the output matrix $W_i^O∈ℝ^d× D$ . To further tighten the upper bound established in Theorem 1, we aim to minimize the second term in the summation, which leads to the following optimization problem:
$$
\min_\widetilde{V} \big\|VW^O-\widetilde{V}W^O\big\|_F^2~~~~s.t.~~~rank(\widetilde{V})≤ R,
$$
where for simplicity we drop the subscript. Likewise for the keys and queries case, the optimization problem can be restated using a projection matrix $S∈ℝ^d× d$ such that
$$
\min_S\|VSW^O-VW^O\|_F^2~~~~~~s.t.~~~rank(S)≤ R,
$$
where $S∈ℝ^d× d$ where we write the projection matrix $S$ as a product of two matrices, i.e., $S=AB^⊤$ with $A,B∈ℝ^d× R$ . The minimization problem tackled by KQ-SVD for the value and output projections is
$$
\displaystyle\min_A,\mathbf{B∈ℝ^d× R}\|VAB^⊤W^O-VW^O\|_F^2. \tag{5}
$$
Theorem 2 applies, in a similar fashion to the case of values and outputs.
## Appendix C Practical settings
Code: The code used for experiments presented in Section 6 is available at https://github.com/DamienLesens/KQ-SVD. We used Pytorch [pytorch] and the Hugging Face transformers library [wolf2020huggingfacestransformersstateoftheartnatural]. For reproducibility, we fixed random seeds equals to 0.
Hardware: All experiments were conducted on NVIDIA Tesla V100-SXM2-32GB GPUs with CUDA acceleration. The primary compute nodes were Intel Xeon E5-2698 v4 @ 2.20GHz (503GB RAM).