X-EcoMLA: Upcycling Pre-Trained Attention into MLA for Efficient and Extreme KV Compression

Guihong Li, Mehdi Rezagholizadeh, Mingyu Yang, Vikram Appia, Emad Barsoum

TL;DR

X-EcoMLA introduces a lightweight post-training approach to "upcycle" standard attention mechanisms (MHA/GQA) from pre-trained LLMs into highly efficient Multi-Head Latent Attention (MLA). By combining SVD-based weight initialization with knowledge distillation from larger teacher models, it achieves up to a 10.6× reduction in KV cache size with virtually no loss in accuracy, bypassing the millions of GPU hours typically required to train MLA models from scratch.

What Problem Does This Paper Address?

As Large Language Models (LLMs) handle increasingly long sequences, the Key-Value (KV) cache becomes a massive memory bottleneck during inference. While Multi-Query Attention (MQA) and Grouped-Query Attention (GQA) mitigate this by sharing keys and values across heads, Multi-Head Latent Attention (MLA)—recently popularized by DeepSeek—offers a much more aggressive solution via low-rank joint compression of keys and values.

However, MLA has traditionally suffered from a major adoption barrier: it must be integrated during the initial pre-training phase, requiring models to be trained completely from scratch using vast computational resources. X-EcoMLA addresses this gap by asking: Can we upcycle existing, well-trained Transformer models into efficient MLA variants without costly retraining?

Methods

The authors propose a cost-effective, two-stage post-training adaptation framework to convert pre-trained Multi-Head Attention (MHA) or GQA blocks into MLA blocks:

  1. SVD-based Weight Initialization: Instead of random initialization, X-EcoMLA uses Singular Value Decomposition (SVD) on the pre-trained attention weight matrices ($W^Q, W^K, W^V$) to derive the low-rank down-projection and up-projection matrices required by MLA. The paper introduces two strategies for rank selection:
  2. Fixed Rank Selection: Constant rank values across all layers.
  3. Dynamic Rank Selection: Layer-dependent ranks calculated based on a predefined singular-value energy threshold ($\delta$).
  4. Unified RoPE Design: To maintain compatibility with Rotary Position Embeddings (RoPE) under low-rank compression, X-EcoMLA adopts a unified RoPE approach where all attention heads share a single Key-RoPE vector, maximizing positional encoding capacity.
  5. LayerNorm Omission: Unlike the original MLA architecture, X-EcoMLA intentionally omits intermediate LayerNorm layers between the projection operations, which empirically leads to better loss convergence during upcycling.
  6. Two-Stage Distillation Training: The initialized model undergoes end-to-end knowledge distillation using a Supervised Fine-Tuning (SFT) dataset to minimize KL divergence against a teacher model, followed by Direct Preference Optimization (DPO) to stabilize and boost final performance.

Datasets

  • Training (SFT Stage): An aggregated dataset containing 6.8B tokens from OpenHermes-2.5, GenQA, and Infinity-Instruct.
  • Training (DPO Stage): A 0.2B token preference dataset combining Llama3-ultrafeedback, orca_dpo_pairs, and ultrafeedback_binarized.
  • Evaluation:
  • LM Harness Eval: Evaluated across 9 zero-shot tasks including MMLU, ARC, HellaSwag, PIQA, PubMedQA, OpenBookQA, RACE, and WinoGrande.
  • LongBench: Used for long-context evaluation (LCC, Qasper, QMSum, Multi-News, SamSum).

Key Insights and Ideas

  • The "Dark Knowledge" Buffer: One of the most compelling findings is that using a larger teacher model during distillation acts as an accuracy buffer against extreme compression. When compressing a 1B model, distilling from an 8B teacher allows the student to withstand aggressive KV cache downscaling far better than self-distillation.
  • Structural Alignment via SVD: Initializing MLA weights using SVD provides a massive head start. SVD initialization yielded up to a 30.9% performance improvement for SmolLM models compared to random initialization, proving that pre-trained attention features map cleanly onto low-rank latent spaces.
  • RoPE Capacity Matters: By sharing a single Key-RoPE vector across all heads rather than splitting dimensions per head (as done in competing methods like MHA2MLA), X-EcoMLA provides $8\times$ more positional encoding capacity in an 8-head setup, which is critical for preserving accuracy under extreme compression.

Key Results

  • Extreme Compression with Zero Performance Drop: For a Llama3.2-1B-Instruct baseline, X-EcoMLA achieves a 6.4× KV cache compression with zero average score degradation on the LM Harness benchmark, requiring only 3.6B training tokens and 70 GPU hours on an AMD MI300.
  • Pushing the Limits: By increasing the training budget to 7B tokens (140 GPU hours), the KV cache can be compressed by 10.6× with less than a 0.1% drop in average score.
Accuracy vs. KV Cache Compression Ratio across different teacher sizes
  • Baseline Comparisons: X-EcoMLA consistently outperforms alternative post-training low-rank compression methods. As shown in the paper's evaluations, X-EcoMLA operating at a mere 15.63% KV cache size matches or outperforms state-of-the-art methods like PALU operating at 50% KV cache size.
  • System-Level Efficiency: In practical deployment, X-EcoMLA-8B delivers a 1.7× to 2× throughput speedup and a 5× reduction in peak GPU memory usage at large batch sizes compared to standard Llama3.1-8B.
Throughput and Peak GPU Memory Usage vs. Batch Size

Limitations and Future Work

While X-EcoMLA drastically reduces the compute required to achieve MLA-level efficiency, it is not entirely "free"—it still requires a few billion tokens of high-quality SFT/DPO data and a few dozen GPU hours for post-training adaptation. Additionally, the extreme compression ratios rely heavily on the availability of a larger, highly capable teacher model.

Future work could explore expanding this upcycling technique to even larger model scales (e.g., 70B+ parameters) and investigating hybrid architectures that selectively upcycle only specific layers to optimize the compute-memory trade-off.

Summary updated

Abstract

Multi-head latent attention (MLA) is designed to optimize KV cache memory through low-rank key-value joint compression. Rather than caching keys and values separately, MLA stores their compressed latent representations, reducing memory overhead while maintaining the performance. While MLA improves memory efficiency without compromising language model accuracy, its major limitation lies in its integration during the pre-training phase, requiring models to be trained from scratch. This raises a key question: can we use MLA's benefits fully or partially in models that have already been pre-trained with different attention mechanisms? In this paper, we propose X-EcoMLA to deploy post training distillation to enable the upcycling of Transformer-based attention into an efficient hybrid MLA variant through lightweight post-training adaptation, bypassing the need for extensive pre-training. We demonstrate that leveraging the dark knowledge of a well-trained model can enhance training accuracy and enable extreme KV cache compression in MLA without compromising model performance. The experimental results show that our proposed method can effectively compress the KV cache while preserving the performance on the benchmarks; specifically, for Llama3.2-1B-Instruct baseline, a 6.4x compression achieves the same average score by using only 3.6B training tokens and 70 GPU hours on AMD MI300, whereas a 10.6x compression have less than 0.1% average score drop with 7B training tokens and 140 GPU hours. The code for this work is available at https://github.com/AMD-AGI/AMD-Hybrid-Models.
BibTeX
@inproceedings{li2025x,
  author = {Guihong Li and Mehdi Rezagholizadeh and Mingyu Yang and Vikram Appia and Emad Barsoum},
  title = {{X-EcoMLA: Upcycling Pre-Trained Attention into MLA for Efficient and Extreme KV Compression}},
  booktitle = {COLM},
  year = {2025},
  url = {https://openreview.net/forum?id=CPJ9EAeYfd},
}
Figure