Zenaique

Match MLA, GQA and MQA to their mechanisms, cache reduction and quality posture

Match pairs·Hard·4.0 · 0·~2 min·Asked atAccentureBytedanceLepton Ai·Relevant atNVIDIA
Attempt it

Drag each answer to line up with its matching prompt

MLA (DeepSeek)

Unique to MLA: an absorbed up projection matmul fuses into the attention path

GQA (Llama-3 style)

Single K and V head shared across all Q heads; max compression but quality regression on hard tasks

MQA (PaLM style)

MLA in DeepSeek-V3; GQA still dominant in most other open frontier models

Reconstruction cost

Structural sharing: multiple Q heads attend to one K/V head per group; G× cache reduction (G=8 typical)

Empirical 2026 winner

Low rank LATENT projection shared across heads; learned end to end; ~10× cache reduction vs MHA

TL;DR

MQA shares one KV head, GQA shares KV heads per group, and MLA stores a learned low-rank latent that reconstructs K and V on demand: three ways to shrink the KV cache.

Memory aid
Sign in to see the mnemonic that makes this stick.
Easy to grasp

Picture a library where every reader carries a full set of reference notes. That is multi-head attention: lots of duplicated notes, huge shelves. MQA says everyone share one single set of notes, cheapest but coarse. GQA says split readers into a few teams and give each team one shared set, a sensible middle ground. MLA says do not store the bulky notes at all, store a tiny compressed summary, then unpack the details only when a reader actually needs them. The summary fits in a drawer instead of a shelf. Unpacking costs a little extra work each time, but the storage savings are enormous, which is exactly the trade modern serving systems want.

Concept explanation~2 min read

Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example. Click to expand.

Multi-head Latent Attention, Grouped-Query Attention, and Multi-Query Attention are three answers to one question: how do you shrink the KV cache so that decode stops being memory-bandwidth bound? In full multi-head attention every query head carries its own key and value head, and the cache scales with the head count times the layer count times the sequence length. At long context that cache can exceed the model weights in HBM, and because decode reads the entire cache for every new token, the GPU spends its time streaming memory rather than computing.

The three methods sit on a spectrum but split into two families. MQA and GQA are structural: they keep real key and value heads, just fewer of them, shared across query heads. MLA is a compression scheme: it stores a learned low-rank latent per token and reconstructs the full keys and values on demand. Understanding that the families split, rather than treating the three as a single dial turned to different settings, is the entire point of this question.

This deep dive walks through each mechanism, the cache math, the quality tradeoffs, MLA's unique reconstruction cost and its RoPE complication, and the 2026 landscape of who uses what. By the end you should be able to match each method to its mechanism, its cache reduction factor, and its quality posture without hesitation.

The shared bottleneck: KV cache memory

During autoregressive decode the attention layer at every level reads the keys and values of all prior tokens. Those are cached so they are not recomputed, and the cache size follows a simple formula.

cache bytes=2LHkvdhTb\text{cache bytes} = 2 \cdot L \cdot H_{kv} \cdot d_h \cdot T \cdot b

Here L is layers, H_kv is the number of KV heads, d_h is head dimension, T is sequence length, and b is bytes per element. The factor of 2 counts keys and values. The single lever all three methods pull is H_kv, the KV head count. Full multi-head attention sets H_kv equal to the query head count. Every method below drives H_kv down, or in MLA's case replaces the per-head storage entirely with a much smaller latent dimension.

The reason this matters is bandwidth, not compute. Decode reads the whole cache per token, so halving the cache nearly halves decode latency. That is why frontier models stopped shipping plain multi-head attention years ago.

It also reframes what these three methods are doing. None of them changes the attention math the model learns; they change how the key and value information is stored and retrieved. MQA and GQA cut H_kv by hard-wiring fewer physical heads. MLA leaves H_kv conceptually intact but stores a compressed surrogate, then expands it. Keeping that distinction in mind is what lets you reason about quality and runtime cost rather than just memorizing reduction factors.

MQA and GQA: store fewer real heads
MLA: compress to a latent, reconstruct on demand
MLA's runtime catch: reconstruction and operator absorption
The 2026 landscape and how to match them
Sign in to unlock the full deep dive.

Situations where this technique stops working.

Sign in to see when this approach fails.

2–4 min · Everything important, quickly.

Sign in to see the quick scan of the deep dive.
MethodWhat is storedCache reductionQuality postureRuntime catch
MHAFull K and V per head1x baselineReference qualityLargest cache, decode is bandwidth-bound
MQAOne shared K and V headn_heads xRegresses on hard tasksCoarsest single history view
GQAOne K and V head per groupG x (G=8 typical)Near full qualityNone beyond standard attention
MLALow-rank latent per token~10xMatches GQAUp-projection matmul, decoupled RoPE

Real products, models, and research that use this idea.

  • DeepSeek-V3 ships Multi-head Latent Attention to cut per-request cache about tenfold versus full multi-head attention while matching GQA-level quality.
  • Llama-3 and Llama 4 use Grouped-Query Attention with 8 KV groups, the de facto default across most open frontier models in 2026.
Sign in to see more production examples.

What an interviewer would ask next. Try answering before peeking at the approach.

QWhy does MQA regress on hard reasoning tasks while GQA largely does not?
A

Think about representational capacity. One shared KV head forces all query heads through a single view of history, collapsing head diversity. GQA keeps several KV heads, preserving enough distinct views that quality holds while still cutting the cache by the group count.

3 more follow-ups an interviewer would ask next. Sign in to reveal them.

Red flags & common mistakes

The phrases that signal junior thinking. Click to expand.

Most common mistake

Treating MLA as just aggressive GQA. MLA stores a low-rank latent and reconstructs K and V at runtime; GQA stores real shared heads with no reconstruction step.

Sign in to see all red flags and common mistakes.

60 second bullets to scan on the way to the call.

  • What each method physically stores in the cache versus reconstructs

  • Why MQA regresses on hard tasks but GQA mostly does not

Sign in to unlock the revision sheet.

Primary sources. Browse if you want the original framing.

Similar questions

Same topic, related formats. Practice these next.

4 curated
Next question
What is the KV cache in transformer inference?
Flashcard·Easy