Back to LLMs Mind Map
中文·English
LLMsID: mla-attention

Multi-head Latent Attention

MLA 低秩 KV 压缩
🎯Core Definition
MLA (Multi-head Latent Attention) is the low-rank KV compression introduced by DeepSeek-V2: the layer's K/V are first compressed into a low-dimensional latent vector ctKVRdcc_t^{KV} \in \mathbb{R}^{d_c} (dc=512d_c = 512 in DeepSeek-V2), and per-head K/V are reconstructed by up-projection at attention time; a small position-only rotary K (ktRk_t^R) is kept separately for RoPE compatibility (decoupled RoPE).
💡Use Cases
standard in DeepSeek-V2/V3/R1, most beneficial for long context and large batch serving; by 2026 it is the reference design for long-context deployment at big companies, and "why MLA saves memory" is a must-know interview question.
Key Problems Solved
GQA only shares KV heads, still caching 2Hd2 H d values per token; MLA cuts per-token cache to dcd_c, with dc=5122Hdd_c = 512 \ll 2 H d — DeepSeek-V2 drops its KV cache from about 41.5GB (GQA variant) to about 5.1GB (MLA), a reduction of 80%+; during training, recomputing K/V from ctKVc_t^{KV} at prefill also saves substantial activation memory.
🎯5 High-Frequency Exam Points
1
How does MLA compress KV? Dimensionality of ctKVc_t^{KV} and the reconstruction process?
2
Why does MLA need decoupled RoPE? What role does ktRk_t^R play?
3
How much memory does MLA save vs GQA? Concrete numbers (41.5GB → 5.1GB)?
4
How does MLA cut activation memory in training (recomputing K/V at prefill)?
5
Essential difference between MLA and MQA/GQA (sharing vs low-rank projection)?
Updated 2026-08-12
🎯
Test Your Knowledge: Practice Questions for "Multi-head Latent Attention"
Single choice pitfall questions with instant feedback and mistake tracking.
🚀 Start Card Practice
Previous CardAttention Variants MHA/MQA/GQANext CardSSM & Hybrid Architectures

🔗 More LLMs Knowledge Cards

Agent & Tool CallingAlignment Tax & Preference DataScaled Dot-Product AttentionBenchmarks MMLU/GSM8K