DeepSeek-V2 cuts inference KV-cache memory by 93.3%, lowers training cost by 42.5%, and lifts maximum generation throughput 5.76x over DeepSeek 67B while beating dense Multi-Head Attention (MHA) in controlled accuracy ablations. Built as a 236B-parameter Mixture-of-Experts model (21B activated per token, 128K context, pretrained on 8.1T tokens), it solves the classic attention dilemma where shrinking the KV cache normally degrades model quality.

Standard MHA caches separate keys and values for all 128 heads (2 * n_h * d_h * l elements per token), which limits batch size and sequence length during decoding. Existing workarounds like Multi-Query Attention (MQA) and Grouped-Query Attention (GQA) slash KV memory by sharing heads, yet in DeepSeek’s controlled 7B dense ablations (1.33T tokens), 5-shot MMLU drops from 45.2% (MHA) to 41.2% (GQA-8) and 37.9% (MQA).

  • GQA-2.25 footprint, MHA-beating accuracy: Multi-Head Latent Attention (MLA) caches 576 elements per layer per token (d_c = 512 latent + 64 decoupled RoPE), matching GQA with 2.25 groups while scoring 50.0% MMLU vs MHA’s 48.7% in 16B MoE ablations (86% less cache).
  • 96% cache reduction in 250B ablation: at 247B total parameters (420B tokens), MLA cuts KV cache per token from 860.2K elements (MHA) to 34.6K while matching MMLU (50.9%) and jumping from 59.2% to 62.5% on CMMLU.
  • 42.5% cheaper pretraining: pairing MLA with fine-grained DeepSeekMoE (2 shared + 160 routed experts, Top-6 active) lowers H800 GPU hours per trillion tokens from 300.6K (DeepSeek 67B) to 172.8K.
  • 5.76x serving throughput: on an 8xH800 node with FP8 weights and 6-bit average KV quantization, DeepSeek-V2 tops 50K output tokens/s and 100K prompt tokens/s, reaching 78.5% MMLU base and 8.97 MT-Bench after GRPO alignment.
How MLA compresses KV state without breaking Rotary Position Embeddings
1. Content path (NoPE)
Down-projects hidden state into one 512-dim latent vector.
Cache c_t^KV (512 dims) + absorb up-projections
Because no RoPE sits between W^UQ and W^UK, W^UK folds into queries and W^UV folds into W^O at inference, avoiding full key/value materialization.
2. Decoupled RoPE path
Carries relative position outside the compressed latent.
Cache shared k_t^R (64 dims)
Produces per-head RoPE queries q_t,i^R and one shared RoPE key k_t^R, concatenated with content heads before softmax. Total cache per layer: 512 + 64 = 576 elements.

In DeepSeek-V2: 60 layers, n_h = 128, d_h = 128, d_c = 512, d_h^R = 64. Source: DeepSeek-AI (2024), Section 2.1 and Appendix C.

Why low-rank KV compression breaks with RoPE

At first glance, low-rank KV compression looks trivial: project the hidden state h_t down to a compact latent c_t^{KV} (d_c = 512 vs 128 * 128 = 16,384 full head dims), cache only c_t^{KV}, and fold the key and value up-projections (W^{UK}, W^{UV}) directly into W^Q and W^O using matrix associativity during decoding.

The catch is Rotary Position Embedding (RoPE). Applying RoPE directly to compressed keys inserts a position-dependent rotation matrix between W^{UQ} and W^{UK}. Because matrix multiplication does not commute, W^{UK} can no longer be absorbed into the query projection, forcing the server to recompute and materialize full keys for every prefix token at every decoding step.

MLA’s decoupled RoPE solves this by splitting each head into two pieces: a position-free content vector (d_h = 128) computed from c_t^{KV} with full matrix absorption, and a narrow 64-dim RoPE sub-vector (q_{t,i}^R per head, plus one shared k_t^R across all heads). That keeps total cached state at (d_c + d_h^R) * l = 576 * l, while YaRN context extension only needs to act on k_t^R to reach 128K tokens.

Controlled attention ablations: KV cache per token vs hard-benchmark accuracy
Mechanism / ModelKV Elements / TokenBBHMMLUCMMLU
Dense 7B w/ MQA (1.33T tokens)2 * d_h * l33.237.934.6
Dense 7B w/ GQA-8 (1.33T tokens)16 * d_h * l35.641.238.4
Dense 7B w/ MHA (1.33T tokens)2 * n_h * d_h * l37.045.243.5
Large MoE 250.8B w/ MHA (420B)860.2K51.650.959.2
Large MoE 247.4B w/ MLA (420B)34.6K (-96%)52.350.962.5

Source: DeepSeek-AI (2024), Tables 1, 8, and 9.

Sparse routing and system engineering

The training savings come from DeepSeekMoE: every layer except the first replaces the dense FFN with 2 always-on shared experts plus 160 routed experts (1536 width, Top-6 active). To keep 8-way expert-parallel all-to-all traffic bounded, each token routes to at most M = 3 of D = 8 devices, guarded by three auxiliary balance losses (expert, device, and communication) and a capacity-1.0 token-dropping pass during training (exempting 10% of sequences).

Caveats and builder takeaway

Three caveats separate MLA’s clean mechanism from the headline system numbers. First, the 93.3% KV reduction and 5.76x throughput compare an MoE model with FP8 weights and 6-bit quantized KV cache against dense BF16 DeepSeek 67B; MLA is a major driver, not the sole cause. Second, DeepSeek-V2 relies on three auxiliary balance losses and token dropping that create subtle training-vs-inference mismatch, a limitation the team later eliminated in DeepSeek-V3 using auxiliary-loss-free bias routing. Third, bilingual EN/ZH pretraining and contentious-topic filtering leave weaker performance outside English and Chinese as well as on value-sensitive subsets like MMLU Humanity-Moral.

For inference architects, MLA shows that caching a low-rank latent with a tiny decoupled RoPE key breaks the GQA accuracy tax, letting long-context, high-concurrency serving scale without sacrificing multi-head expressiveness.