KV caches can be reduced by decreasing head count or cached vector dimensions. MLA reduces the dimensions.
The wall that head-count compression hits
Decoding produces one token at a time and re-reads the Key and Value of every preceding token. The KV cache therefore has to stay in GPU memory until the request finishes. Its size depends on model dimensions, batch size, and context length.
In MHA, one token requires (2 L n_h d_h) cached elements. Here (L) is the layer count, (n_h) is the number of attention heads, and (d_h) is the head dimension. The leading 2 stands for the two copies, Key and Value. Multiply by bytes per element to obtain storage size; both architecture and precision matter.
GQA (Grouped-Query Attention) and MQA (Multi-Query Attention) work on the head-count term. Several query heads share one set of Key and Value, which lowers (n_h) to a group count (n_g). The cache shrinks in proportion, but query heads do not become identical. The GQA paper evaluates speed and quality under KV sharing. The same head-count choice affects both compression ratio and quality.
| Scheme | Cache per token | Character |
|---|---|---|
| MHA | (2 L n_h d_h) | Separate KV per head |
| GQA | (2 L n_g d_h) ((n_g \ll n_h)) | Several query heads share KV |
| MQA | (2 L d_h) | One KV head, risk of quality degradation |
| MLA | (L (d_c + d_r)) | Latent vector caching |
MHA cache: 2 × L × n_h × d_h
MLA cache: L × (d_c + d_r)MLA (Multi-head Latent Attention) folds the remaining axis, the dimension. Head count stays untouched while the dimension of the cached vector goes down. The MLA row is the only one without a leading 2 because Key and Value are not stored separately.
Caching one latent vector
MLA is introduced by the DeepSeek-V2 report and retained in DeepSeek-V3. Instead of keeping Key and Value as they are, it squeezes the input hidden state into a low-dimensional latent vector (c) and caches only that. Key and Value are reconstructed from (c) when they are needed.
During prefill, a down-projection matrix (W_d) compresses the hidden state to (d_c) dimensions. The Key and Value used in the attention computation come from an up-projection matrix (W_u) that expands (c) back out. Both matrices are low-rank structures obtained through training, so compression and reconstruction follow a fixed rule.
flowchart LR
X[Input hidden state<br/>d dimensions] --> DKV[Down-projection<br/>matrix W_d]
X --> KR[Positional key projection<br/>+ RoPE rotation]
DKV --> C[(Latent vector c<br/>d_c dims · cached)]
KR --> R[(Positional key k_r<br/>d_r dims · cached)]
C --> UK[Up-projection W_u<br/>absorbed into query at inference]
UK --> ATT[Attention scores]
R --> ATT
ATT --> OUT[Output]
- Only two pieces enter the cache: the latent vector (c) and the positional key (k_r).
- What differs per head is the up-projection matrix, not the cache, so head count never multiplies the cache size.
- The DeepSeek-V2 configuration uses (d_c = 512) and (d_r = 64). Savings depend on the comparison model and storage precision.
- The reason positional information sits in a separate stream is covered in the next section.
The compression comes from a single dimensionality reduction. Key and Value that used to be scattered across heads collapse into one latent vector, and the cache size falls from (2 n_h d_h) to (d_c + d_r).
The absorption trick and decoupled RoPE
Reconstructing Key and Value at every step adds computation despite the memory savings from latent caching. The absorption trick removes that reconstruction cost. An attention score is the inner product of a query and a key, and since the key is (k_j = W_u c_j), the score can be rewritten as follows.
(W_u) is a fixed matrix once training ends. It can therefore be multiplied into the query projection matrix ahead of time. During inference, the absorbed query takes an inner product with (c_j) read straight from the cache.
The step of materializing the Key in memory disappears entirely. The Value-side up-projection is absorbed into the output projection matrix the same way.
The report describes this rearrangement as an inference optimization. Training memory and prefill efficiency require separate evaluation of execution paths and intermediate activations. Algebraic absorption alone does not establish less computation at every stage.
RoPE (Rotary Position Embedding) prevents this direct absorption. RoPE multiplies the key by a rotation matrix (R_j) that varies with token position (j), which makes the key (R_j W_u c_j). Because (R_j) changes per position, (W_u) cannot be peeled off and moved to the query side.
MLA avoids the collision by splitting the key into two streams.
- NoPE stream: position-independent semantic information. It is compressed into the latent vector (c) and cached, and absorption applies only here.
- RoPE stream: a (d_r)-dimensional key carrying position alone. It sits in a small separate cache with the rotation already applied.
The final score is the sum of the two inner products. Decoupled RoPE keeps position-dependent components in a small separate cache, enabling matrix absorption for the non-positional component.
Conditions for comparing models
GQA shares KV heads; MLA shares a latent representation. Cache size alone cannot rank their quality. Comparisons with different models, training data, or procedures do not establish universal expressiveness or accuracy superiority.
| Comparison | Conditions to match |
|---|---|
| Cache bytes | Layers, KV dimensions, element precision, and metadata |
| Latency | Input and output lengths, batching, and kernels |
| Quality | Tasks and scoring criteria |
| Model conversion | Additional training, resulting quality, and execution support |
Converting an existing MHA or GQA checkpoint to MLA differs from repacking a cache. It requires compatible weights and quality evaluation. Quantization results from another model must not be attributed to DeepSeek-V3's per-token cache size.
Transfer representation in disaggregated serving
Separating prefill and decode makes the transferred representation relevant to network volume. When latent vectors and positional keys are transferred, their size is the starting payload. Expanded KV or replication across parallel devices changes that size.
Latent cache payload = tokens × L × (d_c + d_r) × bytes per element
Additional cost = parallel-placement replication + metadata + protocol overheadA compressed representation permits smaller transfers but does not eliminate network latency or reconstruction work. Confirm the implementation's transfer format, then measure queuing, transfer, and decoding together. This article does not reproduce MLA kernel or disaggregated-serving performance.
Summary
MLA caches latent vectors and small positional keys. Algebraic absorption of non-positional key and value projections, together with decoupled RoPE, supports this design. Cache savings and performance depend on model dimensions, storage formats, and kernels. Conversion or quantization results from another model and isolated transfer speedups are not guarantees for MLA in general.