Comparing what the cache stores
A memory saving depends on its baseline. GQA already shares much of the history. Compare the complete latent representation and positional branch against the architecture the deployment actually uses.
#Section 14MLA vs MHA
Two models have the same number of query heads, yet one cache is far smaller. The cache stores keys and values, so counting query heads misses the difference.
Full independent KV heads and cache size
Multi-head attention, or MHA, gives every query head its own key and value projections. For heads of width the cache holds 2Hd_h features per token per layer: 2 × 8 × 64 = 1,024. Our MLA fixture stores r+d_R=64+16=80.
Representation capacity
MHA's projected states are free of a joint low-rank constraint. MLA can produce different head features, but all of them come from one latent, and being able to write the reconstruction does not make quality equal. MHA heads are "independent" only in having separate projections; they all read the same hidden vector.
#Section 15MLA vs MQA
One shared key and value can serve every query head. The heads still ask different questions, but they search the same keys and retrieve the same values.
Shared KV and latent compression
Multi-query attention, or MQA, uses one KV head for all query heads, so the cache holds 2d_h = 128 features and the fixture payload is 2 × 8 × 4,096 × 128 × 2 = 16,777,216 bytes, or 16 MiB. Shazeer proposed it in 2019 to cut the memory bandwidth spent on K/V during incremental decoding. Multi-query attention paper.
MLA is smaller than MQA only when its latent and positional widths together are smaller than the shared key/value representation.
Quality vs memory
MQA shares explicit head states; MLA shares a latent but transforms it per head. These are different restrictions, so cache size cannot rank their quality. Compare trained models at a declared budget on the runtime you will actually use.
#Section 16MLA vs GQA
Finch-24 already shares KV across query groups. Comparing MLA only against MHA would overstate its saving against the model we actually start from.
Grouped KV heads and compressed latent KV
Grouped-query attention, or GQA, uses fewer KV heads than query heads, each KV head serving a group. Finch has 8 query heads and 2 KV heads, so groups of 4, a cached width of 2 × 2 × 64 = 256, and a 32 MiB fixture payload. Ainslie and colleagues (2023) studied it as the middle ground between MHA and MQA. GQA paper.
Cache-size differences and computational trade-offs
The MLA fixture is 256/80=3.2 times smaller than GQA. The crossover is
A latent cache saves payload only while its content and positional features together remain narrower than the baseline keys and values.
GQA reuses familiar head layouts; MLA moves work into latent projections and absorbed paths. Strong GQA kernels against a slow MLA reference can favor GQA despite the larger payload, so compare prefill and decode separately at equal context and batch, and report the kernels.
| Design | Cached features per token/layer | Payload in the fixture | Main sharing rule |
|---|---|---|---|
| MHA | 1,024 | 128 MiB | Separate K/V per query head |
| GQA | 256 | 32 MiB | One KV head per query group |
| MQA | 128 | 16 MiB | One KV head for all queries |
| MLA fixture | 80 | 10 MiB | Shared content latent plus positional key |
#Section 17MLA and RoPE
The absorption identity in Section 13 worked because the up-projection was one fixed linear map. A key rotated by its position applies a different map at every historical position, which changes what can be moved onto the query.
Positional information and the difficulty with naive compression
Rotary position embedding, or RoPE, rotates paired query and key coordinates by position-dependent angles. With key rotation and query rotation , a naive rotated-content score is
Read this as the relative rotation sits between the query and the key up-projection. It depends on the historical position , so no single query transform can absorb it for every cached token. Compression is still possible; this simple absorption is what fails.
Separating positional and content components
Decoupled RoPE splits a content-key path from a rotary positional-key path, and each head's score adds the two:
Read this as add the content and positional dot products, then apply the declared scale. marks content, the rotary branch, a head, and the query and key positions. The content term keeps the absorption identity; the rotary key is cached explicitly and shared across heads.
#Section 18DeepSeek architecture connection
Many readers, many tokens, and a cache fetched for every new query: cutting bytes per historical token is the architectural case for MLA, strongest when context and batch grow together.
Why MLA is used and architectural motivation
DeepSeek-V2 combines joint low-rank KV compression with a separate rotary branch, keeping head-specific content transforms with a small cache. It also uses mixture-of-experts feed-forward layers, so its throughput cannot be credited to MLA alone. DeepSeek-V2 architecture and evaluations.
KV-cache efficiency and long-context inference
Fewer cache bytes help when cache reads dominate. Projection work, kernel overhead, or weight reads can reduce or eliminate that advantage.
MLA compresses features per token; it does not bound the number of tokens. The latent cache still grows linearly with length and dense prefill is still quadratic. Sparse patterns and latent memory attack different dimensions of the problem.