Fine-tune existing MHA LLMs to DeepSeek MLA for up to ~97% KV-cache savings with 0.6–1% data

February 20, 20257 min

Overview

Decision SnapshotReady For Pilot

The method is practical and implemented with code and multi-scale experiments; it is ready for evaluation in production-style setups but needs broader validation on more and larger models.

Citations0

Evidence Strength0.80

Confidence0.90

Risk Signals9

Trust Signals

Findings with numeric evidence: 5/5

Findings with evidence refs: 5/5

Results with explicit delta: 4/5

Reproducibility

Status: Code + data available

Open source: Partial

At A Glance

Cost impact: 80%

Production readiness: 70%

Novelty: 60%

Authors

Tao Ji, Bin Guo, Yuanbin Wu, Qipeng Guo, Lixing Shen, Zhan Chen, Xipeng Qiu, Qi Zhang, Tao Gui

Links

Abstract / PDF / Code / Data

Why It Matters For Business

MHA2MLA lets teams cut KV cache memory by ~90%+ and keep near-original quality, lowering GPU RAM needs and cost for long-context inference while requiring only tiny fine-tuning budgets.

Who Should Care

Summary TLDR

The paper introduces MHA2MLA, a fine-tuning recipe that converts pre-trained Multi-Head Attention (MHA) LLMs into DeepSeek’s Multi-Head Latent Attention (MLA). It uses two key moves: partial-RoPE (remove positional rotations in low-impact dimensions) and joint SVD factorization of the keys/values to build a compact latent KV cache. Across models from 135M to 13B, MHA2MLA recovers performance using only 0.6%–1% of pretraining tokens, reduces KV cache size by up to 96.87% (when combined with Int4 quantization), and keeps quality losses small (example: ~1% LongBench drop for 7B), making it practical to retrofit many deployed models for cheaper long-context inference.

Problem Statement

KV cache memory during autoregressive inference grows with sequence length and blocks long-context use. DeepSeek's MLA compresses KV into a latent space but is architecturally different from standard MHA, so converting well-trained MHA models to MLA without retraining from scratch is hard and costly. The paper asks: can we adapt pretrained MHA/GQA models to MLA cheaply and without large data?

Main Contribution

MHA2MLA: a data-efficient full-parameter fine-tuning pipeline to migrate pretrained MHA/GQA models to MLA.

Partial-RoPE: remove RoPE from selected dimensions using a contribution-aware (S_2-norm) selection.

Key Findings

MHA2MLA adapts pretrained MHA/GQA models using a tiny fraction of data.

Numbers0.6%–1% of pretraining tokens used for fine-tuning

Practical UseYou can retrofit large models to MLA with minimal fine-tuning compute and data.

Evidence RefAbstract; Sec.4.1; Table1

KV cache size can be cut dramatically while keeping quality near baseline.

NumbersUp to -96.87% KV cache (d_kv=16 + Int4) with ~-2.4% LongBench drop

Practical UseCombine MHA2MLA with 4-bit KV quantization to slash memory for long-context inference.

Evidence RefSec.4.2; Table2

Results

MetricValueBaselineDeltaSplit / DatasetEvidenceEvidence Ref
Fine-tuning data fraction0.6%–1% of pretraining tokenspretraining tokensAbstract; Sec.4.1; Table1Table1
KV cache reduction (Llama2-7B)-92.19% (d_kv=64 + Int4 HQQ)BF16 baseline-92.19%LongBench / inference KV sizeTable2; Sec.4.2Table2

What To Try In 7 Days

Run S_2-norm partial-RoPE + SVDjoint on a 7B checkpoint and measure KV cache size vs baseline.

Try d_kv=64 (moderate) and compare LongBench or your long-context task before quantization.

If stable, combine with Int4 KV quantization and profile memory/latency and quality trade-offs.

Optimization Features

Token Efficiency
Reduces memory per token during long-context decoding
Infra Optimization
Lower GPU memory and potential for fewer GPUs per request
Model Optimization
Low-rank KV projection (SVDjoint)
System Optimization
Matrix merging for NoPE part to reduce inference ops
Training Optimization
Data-efficient full-parameter fine-tuning (0.6%–1% data)
Inference Optimization
KV cache compression into latent vectors (MLA)Compatible with Int4 KV quantization

Reproducibility

Risks & Boundaries

Limitations

Validated on models up to 13B; not tested systematically on very large models (e.g., Llama3) due to compute limits.

Depends on access to model weights and ability to run full-parameter fine-tuning.

When Not To Use

If you cannot fine-tune model weights (no access or policy restrictions).

When absolute no-drop quality is required for small models under extreme compression.

Failure Modes

Aggressive RoPE removal using low-frequency retention (S_low) can cause convergence failure and large quality drops.

Very aggressive quantization (2-bit) can collapse generation quality despite KV reduction.

Core Entities

Models

Llama2-7BLlama2-13BSmolLM-135MSmolLM-360MSmolLM-1B7

Metrics

KV cache memory reduction (%)AccuracyLongBench average scoreFine-tuning tokens as fraction of pretraining tokens

Datasets

LongBenchMMLUARCPIQAHellaSwagOpenBookQAWinograndeSmolLM pretraining corpus (fineweb-edu-dedup, cosmopedia-v2, python-edu, open-web-math, StackOverflo

Benchmarks

LongBenchCommonsense reasoning suite (MMLU, ARC, PIQA, HellaSwag, OBQA, Winogrande)