What is multi-head latent attention?

Multi-head latent attention is an attention layout that projects each token's hidden state directly into a shared low-dimensional latent vector, storing that vector at inference instead of all keys and values while regenerating head-specific keys and values from it when attention is computed.

Unlike grouped-query attention, which reduces the number of key and value heads, it keeps the head count but compresses stored information into a single vector. The aim is a smaller KV cache with quality close to full multi-head attention.

Topic
Machine learning, models and training
Also known as
MLA, latent attention
Origin
2024, DeepSeek-AI, DeepSeek-V2

How multi-head latent attention works

  1. Each token's hidden representation is projected down to a low-dimensional latent vector by a learned transformation.
  2. At inference the KV cache stores this latent vector plus a small RoPE key per token.
  3. During attention, head-specific keys and values come from the latent vector via up-projections, which can be merged into other weights for efficiency.
  4. Position information is added through RoPE as a separate small component so it stays compatible with the compression.

In more detail

Weight absorption and decoupled RoPE

A key efficiency trick in MLA is weight matrix absorption: because the key and value up-projection matrices are linear, the key one can be folded into the query projection and the value one into the output projection at inference. This allows attention scores and outputs to be computed directly against the compressed latent vector in the KV cache without materialising full-size keys and values in memory.

Query compression during training

During training, MLA also applies low-rank compression to queries (Q) to cut activation memory, though only the compressed KV latent vector and decoupled RoPE key are cached during autoregressive inference.

Adoption in DeepSeek models, memory savings and engine support

Introduced in DeepSeek-V2 (2024) and scaled in DeepSeek-V3 and DeepSeek-R1 (2024 to 2025), MLA shrank the KV cache by over 90% relative to the earlier DeepSeek 67B model, as the DeepSeek-V2 paper reports. Major engines such as vLLM, SGLang and TensorRT-LLM, aided by specialised kernels like FlashMLA, support fused MLA decoding natively.

Commonly confused terms

TermHow it differs
Multi-query attentionMQA forces all query heads to share a single key and value head (extreme KV compression at some quality cost), whereas MLA achieves comparable or smaller KV cache footprints while reconstructing head-specific keys and values for higher representational capacity.
KV cache quantisationKV cache quantisation (e.g., FP8 or INT4) lowers numerical precision of already-computed keys and values at inference, whereas MLA is an architectural low-rank projection trained end-to-end and can be combined with KV quantisation.

Why multi-head latent attention matters for on-premises AI

Since the KV cache takes much of GPU memory in long-context, multi-user inference, multi-head latent attention's smaller cache means longer contexts or more concurrent requests on the same hardware. If an open-weight model using this design is chosen in-house, the inference engine's efficient support for it is checked first; without support, the expected memory gain may not materialise.

ON-PREMISES EXAMPLE

Evaluating an open-weight model with multi-head latent attention to summarise internal audit reports with long context, a bank confirms its inference engine supports this attention type, measuring context length per GPU.

Common questions

How does multi-head latent attention differ from grouped-query attention?

Grouped-query attention reduces key and value head count. Multi-head latent attention keeps the heads but compresses stored keys and values into one vector.

Does multi-head latent attention work in every inference engine?

Not every engine supports it efficiently. To get the memory gain, the chosen engine's support is checked beforehand.

Sources

In the glossary: Glossary, M to Q

What does this term mean for your infrastructure?

We can work out together in a technical assessment how it maps onto your data, hardware and security requirements.

Request a technical assessment →

This site sets no cookies. Visitor numbers are counted in aggregate using a cookieless method that does not identify anyone. See the Privacy Policy for details.