forward-pass
One prompt to one next token through a small real transformer: tokenise, embed, attend, feed forward, project, sample. Step it and watch the residual stream change at each stage.
This runs a whole small model from end to end, rather than taking one part of it apart on its own. A few words go in, get looked up as rows of numbers, compare themselves against each other, pass one at a time through a small two-layer network, and at the end every word the model knows is given a score and one of them is picked. The strip down the left side is the through-line: each stage reads it, works out a small correction, and adds that back rather than overwriting it. The model here is deliberately tiny and its numbers are random, so the word it predicts is meaningless β what is real is the sequence of steps, and that sequence is what runs every time you press enter.
backprop
Gradients flow backwards through a small graph by the chain rule. Switch on descent and watch the loss fall to zero β the whole of training, at a scale you can actually follow.
Most demonstrations show a model using what it already knows. This one shows it learning. The model makes a guess, the page measures how far off it was, and then works backwards through each step asking one question of every number in it: if this number were slightly larger, would the error get better or worse, and by how much? That answer is the number's slope, and shifting each one a little way down its own slope makes the next guess better. Switch on descent and watch the error fall toward zero; run that same loop over billions of numbers instead of the handful here and you have training, because there is nothing else to it.
lora
The update is the product of two thin matrices. Lower the rank and the stored count falls, while a full-rank change stays out of reach. Merged adapters add no serving multiply.
Changing a whole weight matrix means storing a new number for every entry. A low-rank adapter stores the change as the product of two thin matrices, so the count falls with the rank. The product cannot represent a change that needs more directions than that rank. At serving time the product can be added into the base weight, which costs nothing extra, or left separate so a request can swap adapters and pay one thin multiply.
muon
A matrix gradient is orthogonalised so its singular values move toward one. Embeddings, the output head, and per-channel gains stay on a second optimizer.
Most optimizers scale each number on its own. Muon treats a two-dimensional gradient as a matrix and pulls its singular values toward one, so every direction of the update has the same strength. The iteration does not apply to an embedding table, the output head, or a per-channel gain, so a real recipe runs this update beside a second optimizer.
activation-recompute
Store every activation and spend the memory, or store none and pay a second forward. The combined cost has a minimum at a segment length in between.
A backward pass needs the activations the forward pass produced. Storing all of them uses one slot per layer and no extra forward. Storing only the input uses one slot and recomputes the stack. Checkpointing every few layers sits between those extremes, and the sum of memory and extra forward has a minimum there.
quantization-aware-training
The forward pass rounds a high-precision weight onto a code and multiplies by the scale. The backward pass updates that high-precision weight as if the rounding derivative were 1, so the forward code stays put until a bin boundary.
The forward pass stores a high-precision weight, rounds it onto a code, and multiplies that code by the scale. The backward pass updates the high-precision weight by the full step, as if the rounding derivative were 1. Inside a flat bin the forward code stays put until the weight crosses a boundary. A scale of zero sends the forward value to zero, and the step still applies to the stored weight.
distillation
A soft target is the teacher distribution. When the teacher prefers the wrong class, the student is trained to copy that error. Temperature spreads the mass back.
A student can be trained to match the teacher's full distribution rather than a single correct label. When the teacher's top class is the wrong one, that soft target still puts most of its mass there, and the student copies the error at the same confidence. Raising the temperature spreads the mass, so the labelled truth gets a larger share.