Multi-head latent attention

Transformer components · component · 2024 · text

What it is

Compresses keys and values into a low-rank latent vector before caching, cutting the KV cache far beyond GQA.

When to use it

Long-context and large-MoE serving; the attention design that made DeepSeek-V2/V3 cheap to run.

Caveats

It complicates the implementation: rotary position encoding has to be decoupled from the compressed part, and inference engines need specific support. The low-rank compression is lossy if the latent dimension is set too small.

Key ideas

  • Compresses keys and values into one low-rank latent vector per token
  • Only the latent is cached, which shrinks the KV cache several-fold
  • Position information is carried by a separate, decoupled rotary component
  • Introduced in DeepSeek-V2

Related architectures

Original paper

DeepSeek-V2: A Strong, Economical, and Efficient Mixture-of-Experts Language Model (2024, arXiv)

Lessons that cover it

Browse all 198 architectures

The architecture landscape, in one place.

Two things get called “ML architecture”: the classical statistical model families, and the neural network wirings. Both are here, tagged by what they are and what data they eat.

Start from your problem

Architectures

0 shortlisted