Debug Foundry

Eight heads used to keep eight copies of the past.

Turn it, pause it, drag through the steps. Then regroup the heads and watch the cache shrink.

Not a video. A small simulation of attention's memory — heads, their copies of the past, and what sharing does.

Drag to turn · scroll or pinch to zoom

Finished state of the attention variants simulation

Copies of the past per token
8

1/8First step sentence

    0.0s
    Replay the ending with
    Heads per group groups of 2

    What it's for

    Good to know

    GQA shares whole keys and values inside each head group: eight query heads keep 4, 2 or 1 KV copies instead of 8 — keeping all 8 is plain multi-head attention, keeping 1 is multi-query, the two endpoints. In the reported results for the models tested, training with sharing holds quality essentially even with private copies. MLA goes further: each token's keys and values are compressed into one small shared latent, and every head re-expands its own view on the fly — the cache stores the latent, not the eight expansions. The re-expand is real compute the model is trained for, not a free trick, and the positional part of the attention state is kept and accounted separately. Both are training-time choices; this page shows the serving-side memory they buy.

    How it works, step by step

      Why the steps go in this order

      Before you rely on it

      Eight heads and the per-token copy counts are a toy scale — real models use dozens of heads, and the exact MLA ratio depends on the model. The meter counts the KV cache only: keys and values per token, per layer, with head size and storage type held fixed — a model's query weights are not the cache. The direction and the mechanism are exactly as shown: sharing or compressing the cache multiplies how much past a GPU can hold. GQA and MLA are trained in, not serving-time switches — a live model cannot hop between them without trained or adapted weights.

      References