HyperAIHyperAI

Command Palette

Search for a command to run...

LLM
Transformer

LOWRAM: مفاتيح منخفضة الرتبة وقيم مُطفأة التكلفة لضغط قابل للتركيب لذاكرة التخزين المؤقت KV في وقت الاختبار

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

الملخص

يعتمد فك الترميز الانحداري الذاتي على ذاكرة التخزين المؤقت KV، التي تنمو بصمتها الذاكرية خطيًا مع طول السياق وتضع حدًا أقصى لحجم الدفعات والإنتاجية. تستغل أساليب ما بعد التدريب الحالية التكرارَ عبر الرموز والطبقات وأبعاد السمات، أو تخفض الدقة العددية. نحدد محورًا مكملًا: داخل كل رأس انتباه، تكون القيم قابلة للتنبؤ بها إلى حد كبير من مفاتيحها المقابلة. نستغل ذلك من خلال إطفاء ذاكرة القيم المخبأة، حيث يُدرَّب متنبئ خفيف لكل رأس في وقت الاختبار، ولا تُخزَّن البواقي إلا للرموز التي يعيد بناءها بشكل أسوأ، مما يحقق ضغطًا للقيم شبه عديم الفقد بمقدار 4×. يمكن تهيئة المتنبئ باستخدام التعلم الفوقي لتقليل عبء التعبئة المسبقة بشكل كبير، أو تدريبه من الصفر في الإعدادات التي تتيح تكلفة تُدفع مرة واحدة، مثل الاستدلال متعدد الاستعلامات. نزاوج بين إطفاء القيم وضغط المفاتيح منخفض الرتبة عبر الطبقات لإنتاج LowRAM، وهو خط أنابيب ضغط غير متماثل يبقى قريبًا من عدم الفقد عبر ثلاث عائلات من النماذج. من خلال إعادة بناء مجموعة فرعية مختارة فقط من أزواج KV في كل خطوة فك ترميز، يستطيع LowRAM إبقاء عبء فك الترميز عند أدنى حد وتحقيق إنتاجية ذروة أعلى تصل إلى 5× عند ضغط 4×. يتكامل LowRAM كذلك مع التكميم والإخلاء، ليصل إلى ضغط 26.9× عند 94.5% من أداء خط الأساس على السياقات الطويلة. تُظهر هذه النتائج أن معاملة المفاتيح والقيم بوصفهما مختلفين بنيويًا تتيح ضغطًا فعالًا وقويًا وقابلًا للتركيب لذاكرة التخزين المؤقت 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.


بناء الذكاء الاصطناعي بالذكاء الاصطناعي

من الفكرة إلى الإطلاق — سرّع تطوير الذكاء الاصطناعي الخاص بك مع المساعدة البرمجية المجانية بالذكاء الاصطناعي، وبيئة جاهزة للاستخدام، وأفضل أسعار لوحدات معالجة الرسومات.

البرمجة التعاونية باستخدام الذكاء الاصطناعي
وحدات GPU جاهزة للعمل
أفضل الأسعار

HyperAI Newsletters

اشترك في آخر تحديثاتنا
سنرسل لك أحدث التحديثات الأسبوعية إلى بريدك الإلكتروني في الساعة التاسعة من صباح كل يوم اثنين
مدعوم بواسطة MailChimp