One equation for a Transformer training step 01 | A training step is a map What does it mean to put a transformer training step in one equation? Not that the network is a single matrix. It means we can name every operation that carries a batch and its current state to a new state. Read the equation in three passes. First run the forward graph. Then measure errors at selected positions. Finally send those errors backwards to update the weights and the optimiser’s memory. 02 | Words become vectors Begin with the phrase, the cat sat. Each token ID selects a row from a learned table. We keep the order of these rows; the vectors carry the features the model can use. In a multimodal model, a vision encoder and projection can supply additional vectors. Assembling the inputs does not yet let the cat read the other words. The token graph determines who can read whom. 03 | Compare, then forbid the future Make three views of each token: a query, a key, and a value. The query is what the position asks for. The key is what another position offers to match. A dot product gives a score, scaled by the square root of the head width. The camera follows the middle row. Cat may look at the and at itself, but not at sat. The mask removes future columns before softmax, so their final weight is exactly zero. 04 | Turn scores into a weighted read Within that permitted row, scores zero and log three become positive weights one and three before normalisation. Divide by their sum and we get one quarter and three quarters. These are illustrative numbers, not a model measurement. Take a quarter of the first value and three quarters of the second. That is the new information for this position. A practical softmax first subtracts the largest permitted score. That leaves the weights unchanged and keeps exponentials in range. 05 | Keep a path around each update Token attention mixes positions. Depth is a separate graph: it connects module outputs across the network. One familiar block normalises its input, applies attention, and adds the result back to the original vector. A feed forward module then transforms each position’s features, again with a normalisation and a skip path in this example. Some designs instead mix earlier depth summaries by attention. If a block loops with shared weights, every visit counts in the gradient. 06 | Route each token to a few modules Another graph routes tokens to experts. In this toy example four experts are available and two are selected. A routing bias can change which experts win, without entering the mixture weights we use to combine their outputs. Selected experts are weighted and added. A shared expert can also contribute without competing for those slots. The gradient can flow through the selected branches, but it does not automatically teach the hard selection boundaries. Those need separately specified training rules. 07 | Only valid targets count The head produces one score per candidate next token. Cross entropy asks what probability the model gave the correct answer. If that probability is one quarter, the loss at this position is log four. Higher probability means lower loss. Average over the valid target positions across the batch. Padding and unsupervised positions contribute no direct loss. But an unsupervised prompt token may still influence a supervised prediction through attention, so masking the loss is not the same as deleting the prompt. 08 | Run the graph in reverse Now reverse the arrows. At each arrow, the chain rule maps the downstream sensitivity to its input. When a tensor feeds two paths, their contributions add. This applies to residual branches, and to any repeated uses of shared weights. An optimiser turns those gradients into a new state. Adam W, for example, keeps moving averages of gradients and squared gradients, corrects their initial bias, and applies decoupled weight decay. It illustrates our equation; it is not a claim about Kimi’s optimiser. 09 | A proof is not a benchmark Kimi K three point one Pro provides a concrete public wiring example. Its published configuration lists ninety three text layers: sixty nine Kimi Delta Attention layers and twenty four gated sparse attention layers. It selects sixteen routed experts from eight hundred and ninety six, plus two shared experts. That tells us how the architecture is wired, not how to reproduce its training. Lean can check an algebraic rewrite; satisfiability can check a discrete design constraint. Neither tells us how fast the whole step runs. Compare logits, losses, gradients and the update, then actually measure time and memory.