2025-02-13 · 专家 · 自然语言处理 · 机器学习

TransMLA: Multi-head Latent Attention Is All You Need

这篇论文提出了TransMLA,一种将基于GQA的预训练模型转换为基于MLA的模型的方法,从而在不增加KV缓存大小的前提下提升模型的表达能力。

更新于 2026-04-30。作者:Fanxu Meng、Zengwei Yao、Muhan Zhang。

中文摘要

现代大型语言模型(LLMs)在当前硬件上往往面临的是通信瓶颈,而非纯粹的计算限制。多头潜在注意力(MLA)通过在键值(KV)层使用低秩矩阵来应对这一挑战,从而使得压缩后的潜在KV状态能够被缓存。这种方法相对于传统的多头注意力,显著减小了KV缓存的大小,从而提高了推理速度。此外,MLA采用向上投影矩阵来增加表达能力,以减少通信开销为代价进行额外计算。尽管MLA在Deepseek V2/V3/R1中展示了效率和有效性,但许多主要的模型提供商仍然依赖分组查询注意力(GQA),并未宣布任何采用MLA的计划。在这篇论文中,我们表明GQA总能通过MLA来表示,同时保持相同的KV缓存开销,但反之则不成立。为了鼓励更广泛地使用MLA,我们引入了**TransMLA**,这是一种后训练方法,可以将广泛使用的基于GQA的预训练模型(例如,LLaMA、Qwen、Mixtral)转换为基于MLA的模型。转换后,模型可以经过额外的训练来提升表达能力,而无需增加KV缓存的大小。此外,我们计划开发针对MLA的特定推理加速技术,以保持转换模型的低延迟,从而实现Deepseek R1更高效的蒸馏。

英文摘要

Modern large language models (LLMs) often encounter communication bottlenecks on current hardware, rather than purely computational constraints. Multi-head Latent Attention (MLA) tackles this challenge by using low-rank matrices in the key-value (KV) layers, thereby allowing compressed latent KV states to be cached. This approach significantly reduces the KV cache size relative to traditional multi-head attention, leading to faster inference. Moreover, MLA employs an up-projection matrix to increase expressiveness, trading additional computation for reduced communication overhead. Although MLA has demonstrated efficiency and effectiveness in Deepseek V2/V3/R1, many major model providers still rely on Group Query Attention (GQA) and have not announced any plans to adopt MLA. In this paper, we show that GQA can always be represented by MLA while maintaining the same KV cache overhead, but the converse does not hold. To encourage broader use of MLA, we introduce **TransMLA**, a post-training method that converts widely used GQA-based pre-trained models (e.g., LLaMA, Qwen, Mixtral) into MLA-based models. After conversion, the model can undergo additional training to boost expressiveness without increasing the KV cache size. Furthermore, we plan to develop MLA-specific inference acceleration techniques to preserve low latency in transformed models, thus enabling more efficient distillation of Deepseek R1.

解读

一句话总结

这篇论文提出了TransMLA,一种将基于GQA的预训练模型转换为基于MLA的模型的方法,从而在不增加KV缓存大小的前提下提升模型的表达能力。

问题1:这篇论文想要解决什么具体问题?

问题2:论文的核心创新点是什么?

问题3:实验结果如何验证了方法的有效性?

问题4:这个研究的实际应用价值是什么?

来源