betaFeedback

WorksComputer Science

Kronecker Product Attention: Memory-Efficient KV Compression via Structured Factorization

Abstract

Efficient autoregressive generation is increasingly limited by the memory footprint of the key-value (KV) cache, which grows linearly with sequence length, batch size, and model depth. Existing approaches such as Multi-Query Attention (MQA), Grouped-Query Attention (GQA), Multi-Head Latent Attention (MLA), and Tensor Product Attention (TPA) reduce this cost through different trade-offs, but often sacrifice expressivity, require additional positional-encoding machinery, or impose restrictive low-rank structure. We propose Kronecker Product Attention (KPA), which represents key and value activations as sums of Kronecker products of compact, token-dependent matrix factors. KPA strictly generalizes TPA: rank-one vector-outer-product factorization arises as a degenerate Kronecker split, while non-degenerate matrix factors can represent richer block-structured patterns. We further show that a structured rotary embedding operator matched to the Kronecker representation preserves the relative-position property of RoPE while rotating only the compact factors, removing the need for a decoupled RoPE branch as in MLA. Empirically, KPA matches or exceeds TPA, MHA, MQA, GQA, and MLA across four model scales and nine downstream benchmarks under identical training conditions, while achieving up to 10x KV cache compression. The Kronecker head split is a tuneable hyperparameter that allows practitioners to navigate the compression-accuracy trade-off at design time without architectural changes.

Introduction

The deployment of large-scale Transformer-based language models is increasingly bottlenecked by inference-time memory rather than parameter count. At the core of this bottleneck is the key-value (KV) cache, which stores projected keys and values across every layer and token so they do not need to be recomputed during decoding. This cache grows linearly with sequence length, batch size, and head dimensionality. As context windows extend to hundreds of thousands of tokens and batch sizes increase for throughput, the KV cache can dominate total GPU memory consumption, leaving little headroom for model weights or activations and directly limiting the context length, batch size, and deployment scale that practitioners can afford, motivating a broad line of work on KV compression.

Existing approaches address this along several lines. Token eviction and sparse attention methods risk discarding relevant tokens [30, 27]. Others propose off-chip storage of key-value states, trading memory pressure for increased I/O latency. At the architectural level, Multi-Query Attention (MQA) Shazeer [ [19] and Grouped-Query Attention (GQA) [1] share keys and values across heads at the cost of representational diversity. Multi-Head Latent Attention (MLA) [5] avoids this by caching compressed latent representations instead, but requires a decoupled RoPE branch, in which a small set of uncompressed key dimensions carry the rotary embedding and are concatenated to the latent key at each decoding step. Tensor Product Attention (TPA) imposes low-rank CP (Canonical Polyadic) structure directly on KV projections, storing only the low-dimensional factors [29]. However, CP decomposition operates on vectors and cannot jointly encode structure at both the head level and the feature level within each head. This limitation is important as empirical studies have shown that attention heads specialize into distinct functional roles, with different subsets attending to syntactic, semantic, and positional patterns, suggesting that an effective KV factorization should operate at both levels simultaneously [13, 25].

Motivated by this, we use Kronecker product structure to represent per-token key and value matrices via two smaller contextual matrix factors. Unlike CP decomposition which operates on vectors, the Kronecker product expands two small matrices into a larger block-structured matrix with the same shape as a standard key or value slice, making it naturally suited to multi-head attention where both the head axis and the within-head feature axis have product structure. Among structured factorizations, the Kronecker product is distinguished by combining three properties in a single operation: its mixed-product identity lets inner products between Kronecker-structured queries and keys factor into products of smaller inner products; it admits a Kronecker-separable rotary operator that acts on only one compact factor; and a rank-1 outer product, which is the basic building block of CP decomposition, is a special case, making Kronecker factorization strictly more general than CP at the same parameter budget. We note that Kronecker structure has also been explored in attention mechanisms for encoder models operating on multi-dimensional inputs [15], reducing training-time computation rather than KV cache size. That setting differs fundamentally from autoregressive decoding, which is our focus.

We introduce Kronecker Product Attention (KPA), a structured attention mechanism that applies this factorization to the query, key, and value projections of each attention head. This yields a family of KV compression schemes parameterized by the factor dimensions, allowing flexible trade-offs between compression ratio, head structure, and representational capacity. We provide a theoretical analysis characterizing the expressivity of KPA as a function of rank and factor dimensions, and prove that a modified frequency schedule we call Kronecker-Separable RoPE integrates seamlessly with the factorized KV representation without materializing the full key or value tensors and without breaking the standard relative-position property. To evaluate KPA empirically, we train models at four scales including 124M, 353M, 773M, and 1.5B parameters on the FineWeb-Edu corpus. We compare KPA variants against TPA at matched compression ratios, finding that KPA matches or exceeds TPA across all scales. Figure 1 summarizes the contrast between MHA, TPA, and KPA. Our contributions are as follows:

Figure 1. Overview of Multi-Head Attention (MHA), Tensor Product Attention (TPA), and Kronecker Product Attention (KPA, ours). MHA projects xx directly into dense QQ, KK, VV. TPA and KPA instead factor each projection into two components, combined via an outer product (×\times) for TPA or a Kronecker product (⊗\otimes) for KPA. RoPE is applied only to QQ and KK (never VV), and rotates only the BB factor in both methods (the Theorem 2.4 formalizes this for KPA); AA is cached unrotated. Since TPA’s AA, BB are vectors, their outer product is a flat, unstructured matrix; since KPA’s AA, BB are matrices, their Kronecker product is block-structured with a two-level head/feature hierarchy (shown by the internal grid lines). Only KK, VV factors enter the KV cache; QQ is not cached. The token index tt is omitted throughout except on the final QtQ_t, KtK_t, VtV_t, for clarity.

  • We propose Kronecker Product Attention (KPA), the first application of Kronecker product factorization to per-token, contextual key and value representations for KV cache compression in autoregressive decoding. Unlike prior Kronecker attention work that decomposes static attention score matrices for encoder models, KPA operates on input-dependent factors and directly reduces inference-time memory.

  • We introduce Kronecker-Separable RoPE, which applies rotary position encoding directly to the compact key factors, preserving the standard relative-position property without a decoupled RoPE branch as in MLA.

  • We train KPA at four scales (125M–1.5B) on FineWeb-Edu under identical conditions to TPA, showing KPA matches or exceeds TPA, MHA, MQA, GQA, and MLA across nine benchmarks while achieving 6.4×–10× KV cache compression.

Kronecker Product Attention

The key-value cache in standard multi-head attention stores, for each token tt, a pair of matrices Kt,Vt∈Rh×dhK_t,V_t \in\mathbb{R}^{h \times d_h}, whose entries are dense and unstructured. We argue that this is wasteful: attention heads are known to specialise into distinct functional roles [13, 25], suggesting that the head-level dimension of KtK_t and VtV_t (i.e., how information is shared or differs across heads) carries structured, differentiable information. We hypothesise that the feature-level dimension (variation across features within a single head) benefits from an analogous structure, and design KPA. The proposed KPA makes this two-level structure explicit by factorising each key and value matrix as a sum of Kronecker products of two smaller matrices, one operating on a coarse partition of the head space, the other on the per-head feature space (formalised in § 2.2), and caching only these factors. The result is a compression scheme that is structurally aligned with the functional organisation of multi-head attention in a way that CP decomposition, which operates on vectors rather than matrices, cannot achieve.

Background and Notation

Notation. Bold uppercase denotes matrices (Kt,Vt,Qt,A,B,WKK_t,V_t,Q_t,A,B,W^K); bold lowercase denotes vectors (qt,kt,vt,xtq_t,k_t,v_t,x_t); unbolded lowercase denotes scalars and indices (h,dh,dmodel,RK,t,ih,d_h,d_{\mathrm{model}},R_K,t,i); and calligraphic uppercase denotes higher-order tensors (K,V,Q\mathcal{K},\mathcal{V},\mathcal{Q}). We write K\mathcal{K} for the Kronecker product, InI_n for the n×nn \times n identity, and Rθ(t)R_\theta(t) for the RoPE rotation at position tt. Subscripts index sequence positions; superscripts identify projections. We set [n]:={1,…,n}[n] := \{1,\ldots,n\}, and all vectors are column vectors unless stated otherwise.

Definition 2.1 (Kronecker product). For matrices A∈Rm1×n1A \in\mathbb{R}^{m_1 \times n_1} and B∈Rm2×n2B \in\mathbb{R}^{m_2 \times n_2}, the Kronecker product A⊗B∈Rm1m2×n1n2A \otimes B \in\mathbb{R}^{m_1m_2 \times n_1n_2} is defined as

A⊗B=(a11B⋯a1n1B⋮⋱⋮am11B⋯am1n1B).A \otimes B = \begin{pmatrix} a_{11}B & \cdots& a_{1n_1}B \\ \vdots& \ddots& \vdots\\ a_{m_11}B & \cdots& a_{m_1n_1}B \end{pmatrix}.

The central algebraic property used in KPA is the mixed-product identity [24] which states for conformable matrices M,N,P,QM,N,P,Q, we can write:

(M⊗N)(P⊗Q)=(MP)⊗(NQ).(1)(M \otimes N)(P \otimes Q) = (MP) \otimes(NQ). \tag*{(1)}

This identity underlies both the factored score computation (§ 2.3) and the RoPE compatibility proof (§ 2.4).

Factorised Key, Value, and Query Representations

Let h=h1h2h = h_1 h_2 and dh=d1d2d_h = d_1 d_2, where h1h_1, h2h_2, d1d_1, d2d_2 are hyperparameters that control the two-level structure. For each token tt with hidden state xt∈Rdmodelx_t \in\mathbb{R}^{d_{\mathrm{model}}}, KPA represents the key, value, and query slices as normalized sums of contextual Kronecker products:

Qt=1RQ∑r=1RQArQ(xt)⊗BrQ(xt)∈Rh×dh,(2)Q_t = \frac{1}{R_Q} \sum_{r=1}^{R_Q} A_r^Q(x_t) \otimes B_r^Q(x_t) \in\mathbb{R}^{h \times d_h}, \tag*{(2)}
Kt=1RK∑r=1RKArK(xt)⊗BrK(xt)∈Rh×dh,(3)K_t = \frac{1}{R_K} \sum_{r=1}^{R_K} A_r^K(x_t) \otimes B_r^K(x_t) \in\mathbb{R}^{h \times d_h}, \tag*{(3)}
Vt=1RV∑r=1RVArV(xt)⊗BrV(xt)∈Rh×dh,(4)V_t = \frac{1}{R_V} \sum_{r=1}^{R_V} A_r^V(x_t) \otimes B_r^V(x_t) \in\mathbb{R}^{h \times d_h}, \tag*{(4)}

where Ar⋅(xt)∈Rh1×d1A_r^\cdot(x_t) \in\mathbb{R}^{h_1 \times d_1} operates on the head-partition subspace Rh1×d1\mathbb{R}^{h_1 \times d_1} and Br⋅(xt)∈Rh2×d2B_r^\cdot(x_t) \in\mathbb{R}^{h_2 \times d_2} operates on the within-head subspace Rh2×d2\mathbb{R}^{h_2 \times d_2}. Both factors are fully contextual meaning they depend on xtx_t through independent learned linear projections as:

ArK(xt)=WrAKxt,BrK(xt)=WrBKxt,(5)A_r^K(x_t) = W_r^{A^K} x_t, \qquad B_r^K(x_t) = W_r^{B^K} x_t, \tag*{(5)}

with WrAK∈R(h1d1)×dmodelW_r^{A^K} \in\mathbb{R}^{(h_1 d_1) \times d_{\mathrm{model}}} and WrBK∈R(h2d2)×dmodelW_r^{B^K} \in\mathbb{R}^{(h_2 d_2) \times d_{\mathrm{model}}} reshaped after multiplication. Analogous maps define the query and value factors. In practice, we merge the rank index into aggregate weight matrices WAK∈R(RKh1d1)×dmodelW^{A^K} \in\mathbb{R}^{(R_K h_1 d_1) \times d_{\mathrm{model}}} and WBK∈R(RKh2d2)×dmodelW^{B^K} \in\mathbb{R}^{(R_K h_2 d_2) \times d_{\mathrm{model}}}, then reshape to AK(xt)∈RRK×h1×d1A^K(x_t) \in\mathbb{R}^{R_K \times h_1 \times d_1} and BK(xt)∈RRK×h2×d2B^K(x_t) \in\mathbb{R}^{R_K \times h_2 \times d_2}, enabling a single batched projection per token.

The ranks RQR_Q, RKR_K, RVR_V are independent. Since queries are never cached, one may freely set RQ≫RK,RVR_Q \gg R_K, R_V to enrich query expressivity at no memory cost. Only the KK and VV factors enter the cache.

It should be noted that setting h1=hh_1 = h, d1=1d_1 = 1, h2=1h_2 = 1, d2=dhd_2 = d_h makes Ar∈Rh×1A_r \in\mathbb{R}^{h \times1} and Br∈R1×dhB_r \in\mathbb{R}^{1 \times d_h} vectors, so each Kronecker term reduces to a rank-one outer product, exactly recovering TPA [29]. Non-degenerate Kronecker factors are strictly richer: rank⁡(Ar⊗Br)=rank⁡(Ar)⋅rank⁡(Br)\operatorname{rank}(A_r \otimes B_r) = \operatorname{rank}(A_r) \cdot\operatorname{rank}(B_r), giving KPA strictly greater representational capacity at matched parameter budgets.

Factored Attention Score Computation

Heads in KPA are indexed by pairs (i1,i2)(i_1, i_2) with i1∈[h1]i_1 \in[h_1], i2∈[h2]i_2 \in[h_2]. Denoting the i1i_1-th row of ArQA^Q_r as (ArQ)i1∈Rd1(A^Q_r)_{i_1} \in\mathbb{R}^{d_1}, the mixed-product identity (1) gives an exact factorisation of the attention score (scaled by 1/dh1/\sqrt{d_h} before softmax in practice):

Proposition 2.2 (Factored Score Computation). The attention score for head (i1,i2)(i_1, i_2) at positions tt and ss satisfies

score⁡(i1,i2)(t,s)=1RQRK∑r=1RQ∑r′=1RK((ArQ)i1T(Ar′K)i1)((BrQ)i2T(Br′K)i2).(6)\operatorname{score}_{(i_1,i_2)}(t,s) = \frac{1}{R_Q R_K} \sum_{r=1}^{R_Q} \sum_{r'=1}^{R_K} \left((A_r^Q)_{i_1}^{\mathsf{T}} (A_{r'}^K)_{i_1}\right) \left((B_r^Q)_{i_2}^{\mathsf{T}} (B_{r'}^K)_{i_2}\right). \tag*{(6)}

Proof. See Appendix A.

Every attention score decomposes into a product of a head-level and a feature-level inner product, reflecting the two-level structure of KPA. Proposition 2.2 shows that scores can in principle be computed directly from the compact factors without materializing the full key tensor, analogously to factored score computation in TPA [29].

Kronecker-Separable RoPE

A natural concern with any structured KV factorisation is compatibility with rotary positional embeddings (RoPE) [21]. MLA resolves this by maintaining a small set of non-compressed KV dimensions that carry the rotary encoding, introducing a decoupled RoPE branch at every decoding step. We show that KPA requires no such branch.

Definition 2.3 (Kronecker-Separable RoPE). Let Id1I_{d_1} be the d1×d1d_1 \times d_1 identity and Rθ(2)(t)∈Rd2×d2R_{\theta}^{(2)}(t) \in\mathbb{R}^{d_2 \times d_2} be a RoPE rotation matrix with frequencies calibrated to d2d_2: θj=10000−2j/d2\theta_j = 10000^{-2j/d_2}, j=0,…,d2/2−1j = 0, \ldots, d_2/2 - 1. The Kronecker-Separable RoPE operator on Rdh\mathbb{R}^{d_h} is RKPA(t)=Id1⊗Rθ(2)(t)R_{\mathrm{KPA}}(t) = I_{d_1} \otimes R_{\theta}^{(2)}(t).

Theorem 2.4 (RoPE Compatibility of KPA). Under Kronecker-Separable RoPE, applying Id1⊗Rθ(2)(⋅)I_{d_1} \otimes R_{\theta}^{(2)}(\cdot) to the query or key vector of head (i1,i2)(i_1, i_2) is equivalent to rotating only the BB factor:

(Id1⊗Rθ(2)(t))((ArQ)i1⊗(BrQ)i2)=(ArQ)i1⊗Rθ(2)(t)(BrQ)i2,(7)\left(I_{d_1} \otimes R_{\theta}^{(2)}(t)\right)\left((A_r^Q)_{i_1} \otimes(B_r^Q)_{i_2}\right) = (A_r^Q)_{i_1} \otimes R_{\theta}^{(2)}(t)(B_r^Q)_{i_2}, \tag*{(7)}
(Id1⊗Rθ(2)(s))((Ar′K)i1⊗(Br′K)i2)=(Ar′K)i1⊗Rθ(2)(s)(Br′K)i2.(8)\left(I_{d_1} \otimes R_{\theta}^{(2)}(s)\right)\left((A_{r'}^K)_{i_1} \otimes(B_{r'}^K)_{i_2}\right) = (A_{r'}^K)_{i_1} \otimes R_{\theta}^{(2)}(s)(B_{r'}^K)_{i_2}. \tag*{(8)}

Moreover, the attention score depends only on the relative offset s−ts - t:

score⁡(i1,i2)(t,s)=1RQRK∑r,r′[(ArQ)i1T(Ar′K)i1]⋅[(BrQ)i2TRθ(2)(s−t)(Br′K)i2].(9)\operatorname{score}_{(i_1,i_2)}(t,s) = \frac{1}{R_Q R_K} \sum_{r,r'} \left[(A_r^Q)_{i_1}^{\mathsf{T}}(A_{r'}^K)_{i_1}\right] \cdot\left[(B_r^Q)_{i_2}^{\mathsf{T}}R_{\theta}^{(2)}(s-t)(B_{r'}^K)_{i_2}\right]. \tag*{(9)}

Proof. See Appendix A.

Theorem 2.4 has two practical consequences: (i) only the BKB^K factors need to be pre-rotated before caching; the AKA^K factors are position-independent and stored as-is, and (ii) the BB factor structure is preserved by the rotation, so positional encoding need not require reconstructing the full key tensor. Unlike MLA, no decoupled RoPE branch is required.

KV Cache Cost and Compression

During autoregressive decoding, KPA caches the key and value factors per token tt:

{ArK(xt),BrK(xt)}r=1RK∪{ArV(xt),BrV(xt)}r=1RV,\left\{A_r^K(x_t), B_r^K(x_t)\right\}_{r=1}^{R_K} \cup\left\{A_r^V(x_t), B_r^V(x_t)\right\}_{r=1}^{R_V},

where ArK∈Rh1×d1A_r^K \in\mathbb{R}^{h_1 \times d_1} and BrK∈Rh2×d2B_r^K \in\mathbb{R}^{h_2 \times d_2} (pre-rotated via Kronecker-Separable RoPE). The per-token cache cost is (RK+RV)(h1d1+h2d2)(R_K + R_V)(h_1d_1 + h_2d_2), compared with 2hdh=2h1h2d1d22hd_h = 2h_1h_2d_1d_2 for MHA. The compression factor is:

CKPA=2h1h2d1d2(RK+RV)(h1d1+h2d2).(10)C_{\mathrm{KPA}} = \frac{2h_1h_2d_1d_2}{(R_K + R_V)(h_1d_1 + h_2d_2)}. \tag*{(10)}

For fixed hh and dhd_h, compression increases with factor asymmetry: a more unequal split of hh or dhd_h makes h1d1+h2d2h_1d_1 + h_2d_2 smaller relative to h1h2d1d2h_1h_2d_1d_2.

Experiments

Experimental Setup

We train KPA models at four scales (125M, 353M, 773M, 1.5B) using a Llama-inspired architecture with SwiGLU and RoPE on top of nanoGPT [10], trained on FineWeb-Edu for ∼50\sim50B tokens with RK=RV=2R_K = R_V = 2 and RQ=6R_Q = 6. We compare against MHA, MQA, GQA, MLA, and TPA baselines from Zhang et al. [ [29] under identical conditions, evaluating zero-shot on nine benchmarks using lm-evaluation-harness [8]. Full training and evaluation details are in Appendix C.

Main Results

Tables 1 and 2 report zero-shot benchmark performance at 353M and 773M scales; 1.5B and 125M results appear in Appendix D.

At 353M, all three KPA configurations outperform TPA. KPA h=(8×2)h=(8 \times2) achieves the best average at 6.4×6.4 \times compression, matching TPA’s ratio while exceeding its accuracy by 1.49pp, with the largest gains on ARC-Easy and SciQ. KPA h=(4×4)h=(4 \times4) outperforms TPA at strictly higher compression (8×8 \times), demonstrating that increasing compression need not sacrifice accuracy. At 773M, KPA h=(10×2)h=(10 \times2) outperforms TPA, MLA, and all other baselines at 6.7×6.7 \times compression, with particularly strong gains on ARC-Easy, BoolQ, and SciQ. Notably, KPA surpasses MLA despite requiring no decoupled RoPE branch. KPA h=(4×5)h=(4 \times5) achieves better accuracy than TPA at higher compression (8.9×8.9 \times).

In both cases, the best-performing KPA variant uses an asymmetric split with larger h1h_1, consistent with the ablation findings in § 3.3. KPA improves monotonically across scales and matches or exceeds TPA at comparable or higher compression ratios at every scale.

Ablation on Head-Split Asymmetry

We ablate the effect of the Kronecker head split h1×h2=hh_1 \times h_2 = h, holding d1=d2=8d_1 = d_2 = 8 and RK=RV=2R_K = R_V = 2 fixed. At 353M we compare symmetric h=(4×4)h=(4\times4), asymmetric h=(2×8)h=(2\times8), and reversed asymmetric h=(8×2)h=(8\times2); at 773M we compare h=(4×5)h=(4\times5), h=(2×10)h=(2\times10), and h=(10×2)h=(10\times2). Table 1 and Table 2 reveal a consistent pattern across scales. Asymmetric splits with larger h1h_1 outperform both symmetric KPA and TPA at both scales. At 353M, h=(8×2)h=(8\times2) achieves the best average, and at 773M, h=(10×2)h=(10\times2) outperforms all baselines. We attribute this to the AA-factor’s capacity to encode joint interactions across h1h_1 heads simultaneously in feature space. A larger h1h_1 expands this capacity, whereas the BB-factor refines within-head feature structure independently, which appears less critical. This is distinct from MHA, where head projections are fully independent by construction. Symmetric splits trade some accuracy for higher compression (8×8\times to 8.9×8.9\times), offering a favourable operating point when memory is the primary constraint. The head split h1×h2h_1 \times h_2 is a tuneable hyperparameter that allows practitioners to navigate the compression–accuracy trade-off at design time, with no other architectural changes required.

MethodARC-EARC-CBoolQHellaSw.OBQAPIQAW.G.MMLUSciQAvg.
MHA59.5129.5259.6045.6834.2068.8253.4323.3376.9050.11
MQA57.6231.9159.4545.6935.4069.3153.5126.4774.6050.44
GQA58.6731.4858.2945.4535.2068.5054.4624.5876.5050.35
MLA56.6529.5257.8346.0534.6069.4252.8024.6279.7050.13
TPA58.3831.5759.3946.8337.0070.0254.0625.5279.9051.41
KPA h=(4×4)h=(4\times4)64.2330.7259.6644.0934.4070.0854.3826.7985.3052.18
KPA h=(2×8)h=(2\times8)64.1531.4857.2145.9336.2070.1854.9226.3183.9052.25
KPA h=(8×2)h=(8\times2)66.1633.0260.3745.1135.8071.2953.1226.7984.4052.90

Table 1. Zero-shot evaluation on nine benchmarks (FineWeb-Edu, ∼50\sim50B tokens), 353M-parameter models. Best score per column in bold. HellaSw. = HellaSwag, W.G. = WinoGrande.

MethodARC-EARC-CBoolQHellaSw.OBQAPIQAW.G.MMLUSciQAvg.
MHA59.9333.6261.9350.6336.0071.0655.4122.8781.2052.52
MQA60.7333.6257.3450.0937.0069.9755.4925.3079.6052.13
GQA61.6634.3058.7249.8538.4071.1653.7525.2377.6052.30
MLA63.5532.8560.9551.7238.8070.5155.0124.5581.9053.32
TPA63.2235.5860.0351.2636.8071.4455.5624.7779.6053.14
KPA h=(4×5)h=(4\times5)68.5635.9260.0950.2836.8072.8555.3325.2685.9054.55
KPA h=(2×10)h=(2\times10)68.3134.9855.3250.9138.0071.0655.6424.6685.3053.80
KPA h=(10×2)h=(10\times2)68.8936.0162.0350.3839.4072.8555.9824.5286.0055.12

Table 2. Zero-shot evaluation on nine benchmarks (FineWeb-Edu, ∼50\sim50B tokens), 773M-parameter models. Best score per column in bold. HellaSw. = HellaSwag, W.G. = WinoGrande.

Conclusion

We introduced Kronecker Product Attention (KPA), a structured factorization of key and value projections that strictly generalizes TPA and integrates natively with RoPE without requiring a decoupled branch as in MLA. KPA matches or outperforms TPA, MHA, MQA, GQA, and MLA across all evaluated scales under identical training conditions, while achieving substantial KV cache compression. The Kronecker head split is a tuneable hyperparameter that allows practitioners to navigate the compression–accuracy trade-off at design time without architectural changes. By reducing the KV cache footprint, KPA directly addresses the memory-bandwidth bottleneck that limits language models deployment on resource-constrained devices such as smartphones, robotics platforms, and embedded systems, making it a natural fit for agentic systems that must plan and act under strict memory budgets without relying on cloud infrastructure. The same compression benefits apply during fine-tuning for tool use and multi-step reasoning, where longer context windows are critical but memory is scarce. Developing an efficient factored decoding kernel and evaluating KPA on longer contexts where cache compression is most practically impactful are natural next steps.

Proofs

Proof of Proposition 2.2

Proof. For head (i1,i2)(i_1,i_2), the per-head query and key vectors are

qt,(i1,i2)=1RQ∑r(ArQ)i1⊗(BrQ)i2,ks,(i1,i2)=1RK∑r′(Ar′K)i1⊗(Br′K)i2.q_{t,(i_1,i_2)}=\frac{1}{R_Q}\sum_r (A^Q_r)_{i_1}\otimes(B^Q_r)_{i_2},\qquad k_{s,(i_1,i_2)}=\frac{1}{R_K}\sum_{r'}(A^K_{r'})_{i_1}\otimes(B^K_{r'})_{i_2}.

Taking the dot product and applying the mixed-product identity

(a⊗b)⊤(c⊗d)=(a⊤c)(b⊤d),(a\otimes b)^\top(c\otimes d)=(a^\top c)(b^\top d),

we obtain

qt,(i1,i2)⊤ks,(i1,i2)=1RQRK∑r,r′[(ArQ)i1⊤(Ar′K)i1][(BrQ)i2⊤(Br′K)i2].q_{t,(i_1,i_2)}^\top k_{s,(i_1,i_2)}=\frac{1}{R_QR_K}\sum_{r,r'}\left[(A^Q_r)_{i_1}^\top(A^K_{r'})_{i_1}\right]\left[(B^Q_r)_{i_2}^\top(B^K_{r'})_{i_2}\right].

Proof of Theorem 2.4

Proof. Applying Id1⊗Rθ(2)(t)I_{d_1}\otimes R_\theta^{(2)}(t) to (ArQ)i1⊗(BrQ)i2(A^Q_r)_{i_1}\otimes(B^Q_r)_{i_2} and using the mixed-product identity gives

(Id1⊗Rθ(2)(t))((ArQ)i1⊗(BrQ)i2)=(ArQ)i1⊗Rθ(2)(t)(BrQ)i2.(I_{d_1}\otimes R_\theta^{(2)}(t))((A^Q_r)_{i_1}\otimes(B^Q_r)_{i_2})=(A^Q_r)_{i_1}\otimes R_\theta^{(2)}(t)(B^Q_r)_{i_2}.

Summing over rr and averaging by 1/RQ1/R_Q preserves the factored form.

The relative-position identity then follows from

Rθ(2)(t)⊤Rθ(2)(s)=Rθ(2)(s−t),R_\theta^{(2)}(t)^\top R_\theta^{(2)}(s)=R_\theta^{(2)}(s-t),

which is the standard RoPE relative-position property restricted to the d2d_2-dimensional subspace.

KV Cache Compression

During autoregressive decoding, KPA caches the factor matrices per past token at a cost of (RK+RV)(h1d1+h2d2)(R_K+R_V)(h_1d_1+h_2d_2) per token, compared with 2h1h2d1d22h_1h_2d_1d_2 for MHA. The compression factor is

CKPA=2h1h2d1d2(RK+RV)(h1d1+h2d2).(11)C_{\mathrm{KPA}}=\frac{2h_1h_2d_1d_2}{(R_K+R_V)(h_1d_1+h_2d_2)}. \tag*{(11)}

Table 3 reports CKPAC_{\mathrm{KPA}} for all evaluated configurations with RK=RV=2R_K=R_V=2 and d1=d2=8d_1=d_2=8.

ScaleConfigCKPAC_{\mathrm{KPA}}
353Mh=(4×4)h=(4\times4)8.0×8.0\times
353Mh=(2×8)h=(2\times8)6.4×6.4\times
353Mh=(8×2)h=(8\times2)6.4×6.4\times
773Mh=(4×5)h=(4\times5)8.9×8.9\times
773Mh=(2×10)h=(2\times10)6.7×6.7\times
773Mh=(10×2)h=(10\times2)6.7×6.7\times
1.5Bh=(5×5)h=(5\times5)10.0×10.0\times
TPAall scales6.4×6.4\times

Table 3. KV cache compression factors for evaluated KPA configurations.

Training and Evaluation Details

Architecture and data. All models use the nanoGPT codebase [10] with SwiGLU activations [20] and RoPE embeddings [21]. We fix d1=d2=8d_1=d_2=8 and vary h1h_1, h2h_2 across configurations to study head-split asymmetry. Models are trained from scratch on FineWeb-Edu-100B [16] for 50,000 iterations with a batch size yielding approximately 1M tokens per iteration, totalling ∼\sim50B tokens.

Optimisation. We use AdamW with peak learning rate 6×10−46 \times10^{-4} (3×10−43 \times10^{-4} at 773M and 1.5B scales), cosine decay to one-tenth of the peak, 2,000 warmup steps, and weight decay 0.1. All models train in bfloat16 on NVIDIA H100 GPUs.

Evaluation. We evaluate zero-shot performance on nine benchmarks using lm-evaluation-harness [8]: ARC-Easy, ARC-Challenge, BoolQ, HellaSwag, OpenbookQA, PIQA, WinoGrande, MMLU, and SciQ. We report accuracy-normalized scores for ARC-E, ARC-C, HellaSwag, OBQA, PIQA, and SciQ, and standard accuracy for BoolQ, WinoGrande, and MMLU. The primary scalar metric is the unweighted average across all nine tasks.

Additional Experimental Results

1.5B Scale

Since h=25h=25 admits only the symmetric Kronecker split h1=h2=5h_1=h_2=5, a single KPA configuration is evaluated at the 1.5B scale. KPA outperforms TPA and all other baselines on eight of nine benchmarks, with the only exception being MMLU where MHA achieves a slightly higher score. The gains are most pronounced on ARC-Easy, SciQ, and BoolQ, consistent with the pattern observed at 353M and 773M scales. This confirms that KPA scales favourably with model size even when the head split is constrained to a single symmetric factorization.

125M Scale

At 125M scale, all KPA configurations outperform TPA (46.21%). Consistent with the pattern at larger scales, asymmetric splits with larger h1h_1 perform better: h=(6×2)h=(6 \times2) achieves the best average, followed by h=(4×3)h=(4 \times3), h=(3×4)h=(3 \times4), and h=(2×6)h=(2 \times6). The gains over TPA are smaller than at 353M and 773M, which is expected as smaller models have less capacity to benefit from richer factorization. Nevertheless, KPA consistently outperforms all baselines including MHA, MQA, GQA, MLA, and TPA across all four configurations.

MethodARC-EARC-CBoolQHellaSw.OBQAPIQAW.G.MMLUSciQAvg.
MHA64.8135.4161.9054.3237.2072.7455.8025.4482.8054.49
MQA64.1036.0162.2654.3839.0072.5856.4323.7081.9054.48
GQA63.6835.9260.4654.1738.4073.5656.2724.7781.7054.33
MLA64.1435.9260.1253.6039.2072.2555.1724.7181.6054.08
TPA66.7136.5261.3854.0340.4072.5256.8324.4982.2055.01
KPA h=(5×5)h=(5 \times5)70.6238.7463.2654.6041.0073.7257.2024.3885.5056.56

Table 4. Zero-shot evaluation of 1.5B-parameter models (FineWeb-Edu, ∼50\sim50B tokens). Baselines from Zhang et al. [2025]. Best score in each column is bold.

MethodARC-EARC-CBoolQHellaSw.OBQAPIQAW.G.MMLUSciQAvg.
MHA50.6326.9659.3936.1832.0064.9651.8523.4070.3046.19
MQA49.6225.3455.7235.9431.4064.8551.3023.3768.7045.14
GQA48.7025.6856.1535.5831.4064.9151.6223.1268.2045.04
MLA50.2126.7158.0136.2532.8064.6950.5924.6771.9046.20
TPA51.2627.3957.0936.6832.8064.4749.7224.6172.0046.21
KPA h=(3×4)h=(3 \times4)52.1027.3057.5835.9032.2065.1050.8024.5073.8046.59
KPA h=(4×3)h=(4 \times3)52.8927.5257.8436.0632.4065.3051.1024.5574.2046.87
KPA h=(2×6)h=(2 \times6)52.3027.2057.2235.7832.2065.0950.9024.4073.5046.51
KPA h=(6×2)h=(6 \times2)53.5127.6657.9035.7032.6065.6051.2024.5974.8047.06

Table 5. Zero-shot evaluation of 125M-parameter models (FineWeb-Edu, ∼50\sim50B tokens). Baselines from Zhang et al. [2025]. Best score in each column is bold.

Related Work

Head sharing

MQA [19] reduces the KV cache by sharing a single key and value head across all query heads, and GQA [1] generalizes this by grouping query heads to share a smaller set of key-value heads, recovering a spectrum between MQA and full MHA. MLA [5] instead projects keys and values into a low-dimensional latent space before caching, achieving stronger compression, but requires a decoupled RoPE branch to handle positional encoding. KPA avoids head sharing entirely and eliminates the decoupled RoPE branch by exploiting the Kronecker structure of its projections.

Low-rank and structured attention

Linformer [26] approximates the attention matrix via low-rank projection of keys and values along the sequence dimension, while Performer [3] approximates the softmax kernel with random features. These methods target the quadratic complexity of attention rather than KV cache size and do not apply to autoregressive decoding. Monarch [4] and Tensorizing-NN [14] apply structured matrix factorizations to weight matrices for parameter efficiency, but do not specifically target KV cache compression. TPA [29] is the closest prior work, applying CP decomposition to KV projections; KPA strictly generalizes TPA by replacing rank-1 vector outer products with Kronecker matrix factors.

KV compression, eviction, and quantization

H2O [30] and StreamingLLM [28] reduce cache size by evicting tokens deemed less important based on attention scores, but risk discarding tokens that become relevant later. KIVI [12] and KVQuant [9] compress the cache through low-bit quantization, trading precision for memory. PagedAttention [11] improves memory management through virtual paging but does not reduce the total cache footprint. KPA takes a complementary architectural approach, reducing the cache at the representation level before any eviction or quantization is applied.

Positional encoding

RoPE [21] encodes relative position by rotating query and key vectors and has become the dominant positional scheme in modern language models. ALiBi [18] instead adds position-dependent biases to attention logits, avoiding explicit positional embeddings. Extensions such as YaRN [17], xPos [22], and PI [2] adapt RoPE for longer contexts through frequency scaling or interpolation. KPA introduces Kronecker-Separable RoPE, which applies rotary embeddings directly to the factorized representation by rotating only the feature-level factor, preserving the standard relative-position property without materializing full key tensors or requiring a decoupled positional branch.

Kronecker factorization in transformers.

Kronecker decomposition has been applied to transformers in several distinct settings, all targeting static weight compression rather than inference-time KV cache reduction. KroneckerBERT [23] compresses BERT weight matrices via Kronecker decomposition with knowledge distillation. KnGPT2 [7] applies the same idea to GPT-2, replacing linear layer weights with Kronecker-structured matrices and using intermediate layer distillation to recover accuracy. KronA [6] uses Kronecker products as a drop-in replacement for LoRA adapters in parameter-efficient fine-tuning, achieving a better expressivity-to-parameter trade-off than low-rank decomposition. HOT [15] decomposes the attention score matrix as a sum of Kronecker products to reduce training-time computation for multi-dimensional encoder inputs. KPA differs from all of these: it factorizes dynamic, per-token key and value activations rather than static weight matrices or score matrices, targeting inference-time memory reduction in autoregressive decoding, a setting none of the above address.

References

  1. [1]Joshua Ainslie, James Lee-Thorp, Michiel de Jong, Yury Zelaski, Sumit Sanghai, and Yuhuai Fu. Gqa: Training generalized multi-query transformer models from multi-head checkpoints. In Proceedings of the 2023 Conference on Empirical Methods in Natural Language Processing, pages 4895–4901, 2023.
  2. [2]Shouyuan Chen, Sherman Wong, Lianjian Chen, and Yuandong Tian. Extending context window of large language models via positional interpolation. 2023.arxiv.org/abs/2306.15595
  3. [3]Krzysztof Choromanski, Valerii Likhosherstov, David Dohan, Xingyou Song, Andreea Gane, Tamas Sarlos, Peter Hawkins, Jared Davis, Afroz Mohiuddin, Lukasz Kaiser, David Belanger, Lucy Colwell, and Adrian Weller. Rethinking attention with Performers. In International Conference on Learning Representations (ICLR), 2021.arxiv.org/abs/2009.14794
  4. [4]Tri Dao, Beidi Chen, Nimit S. Sohoni, Arjun Desai, Michael Poli, Jessica Grogan, Alexander Liu, Aniruddh Rao, Atri Rudra, and Christopher Ré. Monarch: Expressive structured matrices for efficient and accurate training. In International Conference on Machine Learning (ICML), 2022.arxiv.org/abs/2204.00595
  5. [5]DeepSeek-AI. DeepSeek-V2: A strong, economical, and efficient mixture-of-experts language model. 2024.arxiv.org/abs/2405.04434
  6. [6]Ali Edalati, Marzieh Tahaei, Ivan Kobzyev, Vahid Partovi Nia, James J. Clark, and Mehdi Rezagholizadeh. KronA: Parameter efficient tuning with Kronecker adapter. arXiv preprint arXiv:2212.10650, 2022a.arxiv.org/abs/2212.10650
  7. [7]Ali Edalati, Marzieh Tahaei, Ahmad Rashid, Vahid Partovi Nia, James J Clark, and Mehdi Rezagholizadeh. Kronecker decomposition for GPT compression. In ACL, 2022b.
  8. [8]Leo Gao, Jonathan Tow, Stella Biderman, et al. A framework for few-shot language model evaluation. https://github.com/EleutherAI/lm-evaluation-harness, 2023.
  9. [9]Coleman Hooper, Sehoon Kim, Hiva Mohammadzadeh, Michael W. Mahoney, Yakun Sophia Shao, Kurt Keutzer, and Amir Gholami. KVQuant: Towards 10 million context length LLM inference with KV cache quantization. In Advances in Neural Information Processing Systems (NeurIPS), 2024.arxiv.org/abs/2401.18079
  10. [10]Andrej Karpathy. nanogpt. https://github.com/karpathy/nanoGPT, 2022.
  11. [11]Woosuk Kwon, Zhuohan Li, Siyuan Zhuang, Ying Sheng, Lianmin Zheng, Cody Hao Yu, Joseph E. Gonzalez, Hao Zhang, and Ion Stoica. Efficient memory management for large language model serving with PagedAttention. In ACM Symposium on Operating Systems Principles (SOSP), 2023.arxiv.org/abs/2309.06180
  12. [12]Zirui Liu, Jiayi Yuan, Hongye Jin, Shaochen Zhong, Zhaozhuo Xu, Vladimir Braverman, Beidi Chen, and Xia Hu. KIVI: A tuning-free asymmetric 2bit quantization for KV cache. In International Conference on Machine Learning (ICML), 2024.DOI
  13. [13]Paul Michel, Omer Levy, and Graham Neubig. Are sixteen heads really better than one? In Advances in Neural Information Processing Systems, volume 32, 2019.arxiv.org/abs/1905.10650
  14. [14]Alexander Novikov, Dmitry Podoprikhin, Anton Osokin, and Dmitry Vetrov. Tensorizing neural networks. In Advances in Neural Information Processing Systems (NeurIPS), 2015.arxiv.org/abs/1509.06569
  15. [15]Soroush Omranpour, Guillaume Rabusseau, and Reihaneh Rabbany. Higher order transformers: Efficient attention mechanism for tensor structured data. 2024.
  16. [16]Guilherme Penedo, Hynek Kydlíček, Anton Lozhkov, Margaret Mitchell, Colin Raffel, Leandro Von Werra, and Thomas Wolf. The fineweb datasets: Decanting the web for the finest text data at scale. arXiv preprint arXiv:2406.17557, 2024.arxiv.org/abs/2406.17557
  17. [17]Bowen Peng, Jeffrey Quesnelle, Honglu Fan, and Enrico Shippole. YaRN: Efficient context window extension of large language models. In International Conference on Learning Representations (ICLR), 2024.arxiv.org/abs/2309.00071
  18. [18]Ofir Press, Noah A. Smith, and Mike Lewis. Train short, test long: Attention with linear biases enables input length extrapolation. In International Conference on Learning Representations (ICLR), 2022.arxiv.org/abs/2108.12409
  19. [19]Noam Shazeer. Fast transformer decoding: One write-head is all you need. 2019.arxiv.org/abs/1911.02150
  20. [20]Noam Shazeer. Glu variants improve transformer. arXiv preprint arXiv:2002.05202, 2020.arxiv.org/abs/2002.05202
  21. [21]Jianlin Su, Yu Lu, Shengfeng Pan, Bo Wen, and Yunfeng Liu. Roformer: Enhanced transformer with rotary position embedding. Neurocomputing, 568:127063, 2024.arxiv.org/abs/2104.09864
  22. [22]Yutao Sun, Li Dong, Barun Patra, Shuming Ma, Shaohan Huang, Alon Benhaim, Vishrav Chaudhary, Xia Song, and Furu Wei. A length-extrapolatable transformer. In Annual Meeting of the Association for Computational Linguistics (ACL), 2023.
  23. [23]Marzieh Tahaei, Ella Charlaix, Vahid Partovi Nia, Ali Ghodsi, and Mehdi Rezagholizadeh. Kronecker-BERT: Significant compression of pre-trained language models through Kronecker decomposition and knowledge distillation. In Proceedings of the 2022 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies (NAACL), pages 2116–2127, 2022.
  24. [24]Charles F. Van Loan and Nikos Pitsianis. Approximation with kronecker products. In Linear Algebra for Large Scale and Real-Time Applications, pages 293–314. Springer, 1993.
  25. [25]Elena Voita, David Talbot, Fedor Moiseev, Rico Sennrich, and Ivan Titov. Analyzing multi-head self-attention: Specialized heads do the heavy lifting, the rest can be pruned. In Proceedings of the 57th Annual Meeting of the Association for Computational Linguistics, pages 5797–5808, 2019.arxiv.org/abs/1905.09418
  26. [26]Sinong Wang, Belinda Z. Li, Madián Khabsa, Han Fang, and Hao Ma. Linformer: Self-attention with linear complexity. 2020.arxiv.org/abs/2006.04768
  27. [27]Guangxuan Xiao, Yuandong Tian, Beidi Chen, Song Han, and Mike Lewis. Efficient streaming language models with attention sinks. arXiv preprint arXiv:2309.17453, 2023.arxiv.org/abs/2309.17453
  28. [28]Guangxuan Xiao, Yuandong Tian, Beidi Chen, Song Han, and Mike Lewis. Efficient streaming language models with attention sinks. In International Conference on Learning Representations (ICLR), 2024.arxiv.org/abs/2309.17453
  29. [29]Yifan Zhang, Yifeng Liu, et al. Tensor product attention is all you need. In Advances in Neural Information Processing Systems, 2025. Spolight.arxiv.org/abs/2501.06425
  30. [30]Zhenyu Zhang, Ying Sheng, Tianyi Zhou, Tianlong Chen, Lianmin Zheng, Ruisi Cai, Zhao Song, Yuandong Tian, Christopher Ré, Clark Barrett, Zhangyang Wang, and Beidi Chen. H2O: Heavy-hitter oracle for efficient generative inference of large language models. In Advances in Neural Information Processing Systems (NeurIPS), 2023.arxiv.org/abs/2306.14048

Paper details

vlnc:W_hxbcc3q8
Version
v1 · latest
Published
Fresh — added to the Hub within the last 30 days
Added
License
CC BY 4.0
Usage

views · 10

downloads · 0

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

  • Computer Science

Not recorded for this paper

View statement
Looking for related papers…
Contents