The Lab
Everything here asks you to commit to an answer first.
Investigations rather than lessons. Each one puts a mechanism in front of you, takes your prediction, and only then shows the calculation — because a prediction you have already made is the only thing that makes the result informative.
What an investigation looks like
Before the list, one worked example. Everything below is live: the numbers inside the sentences are controls, so drag them and read what changes. Nothing is saved, and there is no answer to get right.
A transformer serving one sequence keeps a key and a value for every token it has already read, at every layer. Take a model of with , serving in . If every query head keeps its own key and value, that cache is 4.0 GiB — for one user.
Now share one key/value pair across . The model still runs 32 query heads, but it now stores only 8 key/value heads per layer, and the cache falls to 1.0 GiB — 75% less.
8 key/value heads per layer.
2 bytes per stored value.
bytes = 2 × layers × kv_heads × head_dim × tokens × bytes_per_value head_dim = d_model / query_heads (4096 / 32 = 128) kv_heads = query_heads / group_size (32 / 4 = 8) the 2 = one key and one value per token
Transformer systems
One track, worked in order. It starts at a single gradient update and ends with you making a defensible claim about a serving tradeoff. Each station is self-contained enough to open on its own, but the sequence is the argument.
Guided paths
Longer routes that thread the atlas and the stations together, for when you want the whole territory rather than one mechanism.
Single-sitting checks
Small, complete, and stateless. Useful when you have ten minutes and want to find out whether you actually understand something you believe you understand.