Multi-head latent attention (MLA)
Multi-head latent attention is DeepSeek's variant of transformer attention that compresses each token's keys and values into one small latent vector, sharply cutting the memory needed to cache them while generating text.
When a transformer generates text, it keeps the keys and values computed for every earlier token in a KV cache so it does not have to recompute them. For long inputs and many simultaneous users, this cache takes up a large share of a GPU's memory and has to be read at every step. Shrinking it is one of the main ways to make a model cheaper to serve.
Multi-head latent attention, introduced in DeepSeek's DeepSeek-V2 paper in May 2024, shrinks it by compression. Each token's input is projected down into a single short latent vector shared by keys and values, and that vector is expanded back into full per-head keys and values when attention is computed. Only the latent vector needs to be cached. Position information, which uses rotary position embeddings, is carried by a small separate key component that is cached alongside it. In DeepSeek-V3 the latent vector for keys and values has 512 dimensions.
DeepSeek reported that DeepSeek-V2, a mixture-of-experts model with 236 billion parameters, 21 billion of them active per token, and a 128,000-token context, cut the KV cache by 93.3% and training costs by 42.5% compared with its earlier DeepSeek 67B. The KV cache figure comes chiefly from MLA, while the training saving reflects the overall design. DeepSeek-V3, published in December 2024 with 671 billion total and 37 billion active parameters, kept MLA, and DeepSeek said its full training took 2.788 million H800 GPU hours.
MLA takes a different route from grouped-query attention. Grouped-query attention saves memory by having several query heads share the same keys and values. MLA keeps distinct keys and values for each head but stores them in compressed form.
MLA is one reason DeepSeek's models are cheap to serve, but only one part of the picture: the same models also rely on mixture of experts, which activates only a fraction of parameters per token, and DeepSeek-V3 was trained largely in the low-precision FP8 number format. A smaller cache means more users and longer documents per GPU, which lowers the cost of each answer.
MLA stands for multi-head latent attention, the attention design DeepSeek introduced with DeepSeek-V2 in May 2024 and kept in DeepSeek-V3. It stores a compressed latent vector for each token instead of full keys and values, which greatly reduces the memory needed during generation. Grouped-query attention cuts memory by making groups of query heads share one set of keys and values. MLA keeps separate keys and values for every head but caches them in a compressed form and reconstructs them when needed. Both aim to shrink the KV cache. The KV cache limits how many requests and how much text a GPU can handle at once. DeepSeek reported a 93.3% smaller KV cache for DeepSeek-V2 than for its earlier 67B model, so each GPU can serve more users or longer contexts, which lowers the cost per answer.Common questions
What is MLA in DeepSeek models?
How is multi-head latent attention different from grouped-query attention?
Why does MLA make models cheaper to run?
Search for "multi-head latent attention", "DeepSeek MLA KV cache" or "MLA vs GQA" for explanations and diagrams. The DeepSeek-V2 and DeepSeek-V3 technical reports on arXiv are the primary sources and describe the design in detail. Inference engine documentation and engineering blogs from serving companies show how MLA is implemented and what it saves in practice.Finding more
Working out what this means for your business?
Aileron Shift builds the systems behind this site: AI newsrooms that research, write and publish on their own, marketing automation and WordPress hosting for companies that need to move faster than their competitors.