On MLA
Multi-head Latent Attention (MLA) is a variant of multi-head attention which was introduced in the DeepSeek-V2 paper1. There are several variants of multi-head attention whose purpose is primarily to reduce the KV-cache size, which is a memory bottleneck that emerges from scaling large models. These methods, which include Group-Query Attention and Multi-Query Attention, are primarily considered performance tradeoffs, i.e. the performance is worse, but you get to scale them much further by reducing the memory overhead. In comparison, MLA accomplishes this by using a low-rank factorized projection matrix, operating a bit like multi-query attention where instead of repeating a single head several times, you decompress a latent vector to yield a unique, appropriate corresponding K and V head for each Q head. DeepSeek claims this not only helps the memory overhead, but also improves the model rather than suffering for its inclusion. The basic idea is as follows: There is also an additional
On MLA On MLA Table of Contents Understanding Multi-Head Latent Attention Why Low-Rank Factorization? Aside: Perturbations in Low-Rank Decomposition Related Work KV Cache MHA Variants Rotary Position Embeddings (RoPE) Experiments Experiment 1 Experiment 2 Experiment 3 Results Modeling Results Inference Time Experiments Discussion Appendix: Other Learnings Extra Experiments Interesting Pytorch Things Understanding Multi-Head Latent Attention Your browser does not support videos Multi-head Latent Attention (MLA) is a variant of multi-head attention which was introduced in the DeepSeek-V2 paper 1
related reading
- A Gentle Introduction to Multi-Head Latent Attention (MLA) - MachineLearningMastery.commachinelearningmastery.com
- The Big LLM Architecture Comparisonmagazine.sebastianraschka.com
- The Illustrated Transformer – Jay Alammar – Visualizing machine learning one concept at a time.jalammar.github.io
- Transformers Inference Optimization Toolset | AstraBlogastralord.github.io
- 2407.15891arxiv.org
- Kimi Linear: An Expressive, Efficient Attention Architecturearxiv.org
- ali (@waterloo_intern) on Xx.com
- Linear Attention Fundamentals | Hailey Schoelkopfhaileyschoelkopf.github.io
- DeepSeek-V3: A Large-Scale MoE Pretraining Benchmark for MLPerf Training v6.0mlcommons.org
- Multi Query Attention (MQA) and Grouped-Query Attention (GQA)tinkerd.net
- Paged Attention from First Principles: A View Inside vLLM – Hamza's Bloghamzaelshafie.bearblog.dev
- 2305.13245arxiv.org