HyperAIHyperAI

Command Palette

Search for a command to run...

LOWRAM: 테스트 시점 조합 가능한 KV 캐시 압축을 위한 저랭크 키와 상각된 값

Teresa R. Delgado Hugo Hazard Martin Benfeghoul Jun Wang Zafeirios Fountas

초록

자기회귀적 디코딩은 KV 캐시에 의존하며, KV 캐시의 메모리 사용량은 컨텍스트 길이에 따라 선형적으로 증가하여 배치 크기와 처리량을 제한한다. 기존의 사후 학습 방법들은 토큰, 계층, 특징 차원에 걸친 중복성을 활용하거나 수치 정밀도를 낮춘다. 우리는 보완적인 축을 식별한다. 즉, 각 어텐션 헤드 내에서 값(value)은 대응하는 키(key)로부터 대체로 예측 가능하다. 우리는 이를 값 캐시 상각(value cache amortisation)으로 활용하는데, 이는 테스트 시점에 헤드별 경량 예측기를 적합하고 재구성 오차가 가장 큰 토큰들에 대해서만 잔차를 저장하여 4배의 거의 무손실 값 압축을 제공한다. 이 예측기는 메타 학습으로 초기화하여 프리필(prefill) 오버헤드를 크게 줄이거나, 다중 질의 추론과 같이 일회성 비용이 허용되는 환경에서는 처음부터 적합할 수 있다. 우리는 값 상각을 계층 간 저랭크 키 압축과 결합하여 LowRAM을 구성한다. LowRAM은 비대칭 압축 파이프라인으로, 세 모델 계열에 걸쳐 거의 무손실에 가깝게 유지된다. LowRAM은 각 디코딩 단계에서 선택된 KV 쌍의 일부만 재구성함으로써 디코딩 오버헤드를 최소로 유지할 수 있으며, 4배 압축에서 최고 디코딩 처리량을 최대 5배까지 높인다. 나아가 LowRAM은 양자화 및 축출(eviction)과 결합되어, 긴 컨텍스트에서 기준 성능의 94.5%를 유지하면서 26.9배 압축에 도달한다. 이러한 결과는 키와 값을 구조적으로 구별되는 것으로 취급하는 것이 효율적이고 적극적이며 조합 가능한 KV 캐시 압축을 가능하게 함을 보여준다.

One-sentence Summary

Researchers from Huawei Noah’s Ark Lab, AI Centre, and University College London propose LowRAM, an asymmetric KV cache compression pipeline that pairs test-time value cache amortisation with cross-layer low-rank key compression to achieve 4×4\times4× near-lossless compression, up to 5×5\times5× higher peak decode throughput, and 26.9×26.9\times26.9× compression at 94.5%94.5\%94.5% of baseline performance when composed with quantisation and eviction.

Key Contributions

  • The paper identifies within-head key-to-value predictability as a complementary redundancy source and introduces value cache amortisation, which fits a lightweight per-head predictor at test time and stores residuals only for the hardest-to-reconstruct tokens, yielding 4× near-lossless value compression.
  • The paper presents LowRAM, an asymmetric pipeline that pairs value cache amortisation with cross-layer low-rank key compression; LowRAM stays close to lossless across three model families and composes with quantisation and eviction to reach 26.9× compression at 94.5% of baseline performance on long contexts.
  • The paper reduces decoding overhead through a meta-learned predictor initialisation and selective reconstruction, enabling substantially reduced prefill overhead and up to 5× higher peak decode throughput at 4× compression.

Introduction

Transformers dominate language modelling, but autoregressive decoding at long context lengths becomes memory-bound because the key-value cache grows linearly with context and batch size. Architectural alternatives such as linear attention, state-space models, and reduced-cache attention variants can address this, but they typically require pretraining or substantial finetuning. Post-training compression methods for frozen models have therefore focused on eviction, quantisation, and low-rank decomposition, yet they largely overlook redundancy between keys and values. The authors identify within-head key-to-value predictability as an underexplored source of cache redundancy and introduce value cache amortisation, which fits a lightweight per-head network to reconstruct values from keys and stores residuals only for poorly predicted tokens. They then propose LowRAM, an asymmetric pipeline that combines amortised values with cross-layer low-rank key compression, achieving near-lossless moderate compression and composing with quantisation and eviction to reach 26.9x compression while retaining 94.5% of baseline performance.

Method

The authors propose LowRAM, an asymmetric compression pipeline that treats the key and value caches as structurally distinct objects. For keys, they adopt a low-rank cross-layer compression approach. For values, they introduce value cache amortisation, a learned associative memory that predicts each token's value vector directly from its key, retaining residuals only for the hardest-to-predict tokens. Prior to both decomposition and prediction, they invert RoPE, as pre-RoPE representations are more amenable to compression, with the rotation reapplied at attention time.

To determine the optimal representation for predictive compression, the authors perform a source-target analysis over the KV cache. They train a predictor to reconstruct either current-layer keys or values using various source representations, including previous-layer keys, previous-layer values, and current-layer representations.

The analysis reveals that reconstructing values from current-layer keys achieves the highest recovered downstream performance. Furthermore, value reconstruction generally recovers more downstream performance than key reconstruction, and reconstruction error correlates only weakly with downstream performance. Consequently, the authors base their design decisions primarily on recovered downstream performance rather than reconstruction error.

Building on the KL→VLK_L \rightarrow V_LKL​→VL​ prediction direction, the authors model this relationship with a lightweight parametric function. Let K∈RT×dkK \in \mathbb{R}^{T \times d_k}K∈RT×dk​ and V∈RT×dvV \in \mathbb{R}^{T \times d_v}V∈RT×dv​ denote the key and value matrices for a single attention head over a sequence of length TTT. They learn a mapping fθ:Rdk→Rdvf_\theta: \mathbb{R}^{d_k} \rightarrow \mathbb{R}^{d_v}fθ​:Rdk​→Rdv​ applied row-wise to the key cache, independently per layer and KV head. The function fθf_\thetafθ​ is a two-layer MLP with a learned linear residual branch:

fθℓ,h(k)=σ(kWℓ,h(1)+bℓ,h(1))Wℓ,h(2)+bℓ,h(2)+kWℓ,hlinf_{\theta_{\ell, h}}(k) = \sigma(k W_{\ell, h}^{(1)} + b_{\ell, h}^{(1)}) W_{\ell, h}^{(2)} + b_{\ell, h}^{(2)} + k W_{\ell, h}^{\mathrm{lin}}fθℓ,h​​(k)=σ(kWℓ,h(1)​+bℓ,h(1)​)Wℓ,h(2)​+bℓ,h(2)​+kWℓ,hlin​

where σ\sigmaσ is a ReLU nonlinearity. During prefill, the parameters θ\thetaθ are adapted to the current context by minimising the value reconstruction loss L(θ)=1T∥fθ(K)−V∥F2\mathcal{L}(\theta) = \frac{1}{T} \| f_\theta(K) - V \|_F^2L(θ)=T1​∥fθ​(K)−V∥F2​.

At decoding time, the value cache is reconstructed from the retained keys as V^=fθ(K)\hat{V} = f_\theta(K)V^=fθ​(K). Since not all tokens are reconstructed equally well, the authors store residual corrections only for the tokens with the largest prediction errors. For each token iii, the reconstruction error is ei=∥fθ(ki)−vi∥22e_i = \| f_\theta(k_i) - v_i \|_2^2ei​=∥fθ​(ki​)−vi​∥22​. Let p∈(0,1]p \in (0, 1]p∈(0,1] denote the fraction of residuals retained. They select the top-ppp fraction of tokens according to eie_iei​ and define a binary gate:

gi=1[rank(ei)>(1−p)T]g_i = \mathbb{1}[\mathrm{rank}(e_i) > (1 - p) T]gi​=1[rank(ei​)>(1−p)T]

The reconstructed value cache is then computed as:

V~=fθ(K)+G⊙ΔV\tilde{V} = f_\theta(K) + G \odot \Delta VV~=fθ​(K)+G⊙ΔV

which replaces the original value cache in standard attention.

To reduce the computational overhead of fitting the value predictor, the authors employ a meta-learned initialisation using First-Order MAML. Each sequence defines a meta-learning task consisting of its observed KV pairs, and the inner loop adapts the per-head predictor for KKK gradient updates. At inference, the predictor is initialised from the learned parameters ϕ⋆\phi^\starϕ⋆ and adapted to the new context using the same KKK-update budget. Additionally, they implement selective reconstruction to avoid reconstructing the complete cache at every decoding step. They partition the prefix into chunks represented by mean-key landmarks, retain outlier chunks and a local window exactly, and reconstruct only the top-kkk chunks selected by the current query. A persistent buffer reuses chunks selected across consecutive decoding steps, and they replace the exact key cache SVD with a randomised Cholesky-QR decomposition to achieve significant speedups without loss in downstream quality.

Experiment

Evaluation across RULER and LongBench with Mistral, Llama, and Qwen models shows that LowRAM preserves near-baseline performance at moderate compression by predicting value caches from keys and storing residuals for poorly reconstructed tokens. Efficiency experiments indicate that meta-learned initialization reduces prefill overhead and selective reconstruction improves decoding throughput, with a tradeoff favoring full adaptation when contexts are reused. Stacking with quantization improves recovery and allows higher compression, while eviction is only beneficial when sequences remain long enough to amortize the reconstruction network; value amortization in isolation remains nearly lossless. Overall, LowRAM is best suited to long contexts and supports compressing keys and values asymmetrically, with future work needed for long generations and cross-context reuse.

LowRAM recovers most baseline accuracy across Mistral-7B, Llama-3.1-8B, and Qwen3.5-4B at moderate compression. Mistral and Llama remain within a few points of baseline at 3x and 4x compression, with one larger drop for Llama on RULER at 4x. Qwen matches its RULER baseline across reported compression ratios, while LongBench recovery declines as compression increases. Mistral-7B and Llama-3.1-8B retain nearly all baseline performance at 3x and 4x compression, except for a larger RULER drop for Llama at 4x. Qwen3.5-4B matches its RULER baseline across reported compression ratios, while its LongBench recovery falls to the low nineties at stronger compression.

At 4x compression on Llama-3.1-8B-Instruct, LowRAM retains most baseline performance on long-context RULER and LongBench tasks. Selective reconstruction matches or slightly improves full reconstruction accuracy, while meta-initialization adds a small accuracy cost in exchange for lower prefill overhead. Even with both mechanisms enabled, recovery stays above 92 percent on both benchmarks. Selective reconstruction preserves LongBench recovery exactly and remains within about one point of, or above, full reconstruction on RULER at 16K, 32K, and 64K contexts. Adding meta-initialization lowers RULER recovery by 1.4 to 4.4 points and LongBench recovery by 2.4 points relative to full 300-update adaptation. With both selective reconstruction and meta-initialization enabled, recovered performance ranges from 92.4 to 96.8 percent on RULER and reaches 92.9 percent on LongBench.

Combining LowRAM with quantisation improves recovered performance while raising compression, with LowRAM-Q reaching near-baseline scores on both benchmarks and matching eviction-level recovery on LongBench at a higher compression ratio. Adding eviction to LowRAM increases compression but often reduces accuracy, especially on RULER where the fixed cost of the reconstruction network is less amortised over shorter contexts. Overall, quantisation pairs more favourably with LowRAM than eviction does. Quantisation combines well with LowRAM: LowRAM-Q improves recovery over LowRAM alone while also increasing the compression ratio. Eviction combined with LowRAM raises compression further but lowers recovery, with a larger penalty on RULER than on LongBench. Standalone quantisation retains high recovered performance at a substantially higher compression ratio than standalone eviction. LowRAM-EQ reaches the highest LongBench compression among the stacked methods, but its recovery remains below LowRAM-Q.

On LongBench contexts longer than 10K tokens, the full stack of eviction, quantisation, and LowRAM reaches 26.9× compression while recovering 94.5% of Mistral-7B baseline performance, outperforming each standalone method. Standalone eviction, quantisation, and LowRAM retain at least 90% performance only at compression ratios between 7.5× and 10×. The combined method therefore improves both compression and recovered accuracy on long contexts. The full stack achieves 26.9× compression with 94.5% recovered performance on long contexts, exceeding standalone methods in both compression ratio and score. Standalone methods keep at least 90% recovery at 7.5× to 10× compression, with quantisation scoring highest and eviction compressing most among them.

For value-cache-only compression with exact keys, amortisation stays near lossless across the evaluated ratios, retaining 98.2% of RULER and 99.3% of LongBench at 4x compression. xKV is slightly better on RULER at higher compression, but amortisation is consistently stronger on LongBench and stays ahead at every ratio. This supports treating value caches predictively rather than using low-rank compression. Amortisation keeps LongBench performance near or above baseline across 2x to 4x value compression. xKV gains a small edge on RULER at higher compression ratios but drops to roughly 95 percent on LongBench across all ratios.

The experiments evaluate LowRAM, selective reconstruction, meta-initialization, quantization, eviction, and value-cache amortization on Mistral-7B, Llama-3.1-8B, and Qwen3.5-4B using RULER and LongBench. LowRAM retains most baseline accuracy at moderate compression, and selective reconstruction matches or slightly improves full reconstruction while meta-initialization adds only a small accuracy cost. Quantization combines more favorably with LowRAM than eviction, and the full stack reaches 26.9x compression while recovering 94.5% of long-context performance. For value-only compression with exact keys, amortization remains near lossless and consistently stronger than xKV on LongBench.


AI로 AI 구축

아이디어에서 출시까지 — 무료 AI 코코딩, 즉시 사용 가능한 환경, 최적의 GPU 가격으로 AI 개발을 가속화하세요.

AI 협업 코딩
바로 사용 가능한 GPU
최적의 가격

HyperAI Newsletters

최신 정보 구독하기
한국 시간 매주 월요일 오전 9시 에 이번 주의 최신 업데이트를 메일로 발송합니다
이메일 서비스 제공: MailChimp