Abstract
As Large Language Models (LLMs) scale to longer context windows, the memory and bandwidth requirements of the Key-Value (KV) cache have become a primary bottleneck for inference efficiency. This paper introduces KV-Latent, a novel paradigm that reduces the dimensionality of the KV cache rather than just the number of heads. By combining a two-stage distillation process with a Frequency-aware Rotary Positional Embedding (RoPE), KV-Latent achieves a 50-87% reduction in KV cache size. Remarkably, model quality is recovered using less than 1% of the original pre-training effort, maintaining high performance across standard benchmarks and long-context retrieval tasks.
1. Introduction
The KV cache stores intermediate states for every token in a sequence to prevent redundant computations during autoregressive generation. However, this cache grows linearly with sequence length, leading to two critical issues: memory bottlenecks, where long contexts exceed GPU VRAM, and bandwidth bottlenecks, where the sheer volume of data transfer slows down token generation.
Existing solutions like Multi-Query Attention (MQA) and Grouped-Query Attention (GQA) reduce the number of heads stored but leave the dimensionality of those heads untouched. KV-Latent addresses this by targeting the "head-dimension" level, providing a more granular approach to compression that is orthogonal to existing architectural optimizations.
2. Methodology
2.1 KV-Latent and Two-Stage Training
The KV-Latent framework utilizes a two-stage distillation pipeline to adapt pre-trained models to a lower-dimensional latent space:
- Model Preparation: The weight matrices ($W_K$ and $W_V$) of a pre-trained model are down-sampled into a lower-dimensional latent space.
- Stage I (In-Layer Distillation): The model undergoes layer-wise training using Mean Squared Error (MSE) loss. This ensures that the output of each modified layer closely matches the output of the original high-dimensional layer.
- Stage II (End-to-End Training): The entire model is fine-tuned using Next-Token Prediction (NTP) or KL-Divergence distillation. This stage recovers the model's global reasoning and language capabilities using a small fraction of the original training data.
2.2 Frequency-aware RoPE
Standard Rotary Positional Embeddings (RoPE) often fail when applied to low-dimensional vectors (e.g., reducing a 128-dimensional head to 16 dimensions). The researchers identified that high-frequency rotations introduce significant numerical noise at low dimensions, disrupting the "positional attenuation" necessary for long-range coherence.
To solve this, the authors proposed a frequency sampling mechanism that excludes high-frequency components and amplifies low-frequency ones. This modification ensures that the numerical approximation of the RoPE integral remains stable, preserving the model's ability to distinguish relative positions even in highly compressed latent spaces.
3. Experimental Evaluation
3.1 Setup
The researchers evaluated the method using a LLaMA-3-8B base. Distillation was performed on a 1-billion-token subset of FineWeb-edu, representing a tiny fraction of typical pre-training budgets. Performance was measured across general knowledge (MMLU), science (AI2ARC), and open-book QA (OBQA) benchmarks, alongside the "Needle In A Haystack" (NIH) test for long-context retrieval.
3.2 Key Results
- Efficiency vs. Accuracy: On LLaMA-3-8B, reducing the KV dimension from 128 to 64 (a 50% reduction) resulted in a marginal average benchmark score drop of only 0.8% (from 42.1 to 41.3). The model maintained a 92% pass rate on the NIH test.
- Extreme Compression: The method successfully reduced the KV cache by up to 87% (down to 16 dimensions). While performance degradation becomes more pronounced at this level, it establishes a new frontier for extreme cache compression.
- Inference Speedup: The 50% reduction in cache size translated to an 8-17% improvement in Time to First Token (TTFT) and overall generation latency, directly addressing the memory bandwidth bottleneck.
4. Discussion and Insights
4.1 Sensitivity of Keys vs. Values
Experiments indicated that model performance is significantly more sensitive to the dimensionality of the Value ($d_{vo}$) component than the Key ($d_{qk}$). This suggests that Values encapsulate more essential semantic information for the final output, whereas Keys—used primarily for calculating attention scores—can be compressed more aggressively.
4.2 Orthogonality
A key advantage of KV-Latent is its orthogonality. Because it operates on the head-dimension level, it can be combined with GQA or token-level eviction strategies (like PyramidInfer) to achieve multiplicative memory savings.
5. Conclusion and Future Work
KV-Latent demonstrates that the dimensionality of the KV cache is a viable and efficient target for LLM optimization. By combining targeted distillation with frequency-aware embeddings, the method slashes memory requirements with minimal recovery costs. Future research will explore the integration of Singular Value Decomposition (SVD) into the pipeline and evaluate the impact of dimensional reduction on post-training phases such as Supervised Fine-Tuning (SFT) and Reinforcement Learning from Human Feedback (RLHF).
Summary updated