Skip to main content
QUICK REVIEW

[Paper Review] TransMLA: Multi-Head Latent Attention Is All You Need

Fanxu Meng, Tang, Pingzhi|ArXiv.org|Feb 11, 2025
Topic ModelingComputer Science5 citations
TL;DR

The paper proves MLA has greater expressiveness than GQA for the same KV cache and introduces TransMLA, a post-training method to convert GQA-based pre-trained models into MLA-based models, followed by fine-tuning to improve downstream performance without increasing KV cache size.

ABSTRACT

In this paper, we present TransMLA, a framework that seamlessly converts any GQA-based pre-trained model into an MLA-based model. Our approach enables direct compatibility with DeepSeek's codebase, allowing these models to fully leverage DeepSeek-specific optimizations such as vLLM and SGlang. By compressing 93% of the KV cache in LLaMA-2-7B, TransMLA achieves a 10.6x inference speedup at an 8K context length while preserving meaningful output quality. Additionally, the model requires only 6 billion tokens for fine-tuning to regain performance on par with the original across multiple benchmarks. TransMLA offers a practical solution for migrating GQA-based models to the MLA structure. When combined with DeepSeek's advanced features, such as FP8 quantization and Multi-Token Prediction, even greater inference acceleration can be realized.

Motivation & Objective

  • Motivate reducing KV cache bottlenecks in self-attention for large language models.
  • Establish theoretical expressiveness advantages of MLA over GQA under equal KV cache costs.
  • Provide a practical conversion workflow (TransMLA) to transform popular GQA-based models into MLA-based models.
  • Demonstrate that fine-tuned TransMLA models outperform their GQA counterparts on downstream tasks with minimal KV cache overhead.

Proposed method

  • Define and compare MHA, GQA, MQA, and MLA in terms of KV cache and representations.
  • Show that GQA can be transformed into MLA with the same KV cache via replication and low-rank factorization arguments.
  • Reveal an SVD-based low-rank decomposition to express GQA as MLA with latent KV representations.
  • Introduce TransMLA as a post-training conversion that keeps KV cache fixed while expanding expressiveness through W_K^a, W_K^b, W_V^a, W_V^b parameterization.
  • Describe an absorb operation that merges certain matrices to maintain a fixed latent KV dimension during inference.
  • Provide an experimental setup converting Qwen2.5 and similar models from GQA to MLA and fine-tuning on SmolTalk for math/code tasks.
(a) Group Query Attention (GQA)
(a) Group Query Attention (GQA)

Experimental results

Research questions

  • RQ1Can MLA match or exceed GQA performance with the same KV cache size?
  • RQ2Is it possible to transform GQA-based pre-trained models into MLA-based models without increasing KV cache overhead?
  • RQ3Does fine-tuning TransMLA after conversion yield measurable gains on downstream tasks such as math and code benchmarks?
  • RQ4What is the role of orthogonal decomposition in the performance gains observed for TransMLA?

Key findings

  • MLA is more expressive than GQA when KV cache size is fixed, and every GQA configuration can be transformed into an MLA representation.
  • A practical, low-overhead conversion (TransMLA) can convert popular GQA-based models (e.g., LLaMA, Qwen, Mixtral) into MLA without increasing KV cache size.
  • Fine-tuned TransMLA models show improved performance on downstream tasks compared to their GQA counterparts, especially in math and coding tasks.
  • The performance boost is attributed to the expanded expressive power from latent KV representations and the orthogonal decomposition in the factorization, not merely parameter count increase.
  • An identity-map-like dim expansion without orthogonal decomposition yields only marginal gains, underscoring the importance of the latent decomposition approach.
(b) Multi-Head Attention (MHA)
(b) Multi-Head Attention (MHA)

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.