Loading the interactive visualization…

03 · Reference notes

← All visual guides

Multi-head Latent Attention Explained

Multi-head latent attention (MLA) reduces KV-cache memory by storing a compressed latent representation and reconstructing per-head keys and values during decoding.

01 · Definition

What is Multi-head Latent Attention?

Instead of keeping a complete key and value vector for every head and every past token, MLA saves a smaller shared latent. The model projects that latent into the head-specific views only when it needs them.

02 · Mechanism

The cache problem MLA targets

Standard multi-head attention keeps separate keys and values for each head. That preserves flexibility, but the cache grows with sequence length, layers, heads, and hidden size. For long-context inference, those stored vectors become a practical bottleneck.

03 · Mechanism

Compress once, reconstruct when needed

MLA writes a compact latent vector to the cache. At the next decoding step, learned projections recover the key and value information required by each head. The cache stores the compressed source rather than all expanded per-head representations.

04 · Mechanism

Why positional information needs care

Attention needs position-aware keys as well as content. MLA separates the parts that can be compressed from the positional components that must remain available, allowing compression without losing the model's ability to distinguish where tokens occurred.

05 · Mechanism

Where MLA pays off

MLA is most useful when KV-cache capacity or bandwidth constrains long-context serving. It trades some projection work at decode time for a much smaller persistent memory footprint.

Source · Original paper