Every network learns by repeating one step, and every building block in this topic is a choice made at exactly one of its seven moments; the choices come in matched sets because four threads tie the moments together. The step: take a batch, push it forward, score it with a loss, send the error backward for a gradient on every weight, update the weights, keep them from fitting noise (regularise), and measure on data the step did not see.
Fig. 1 runs one real step of a small network (16 layers of width 64, a batch of 32, 10 classes) through the seven moments, with the numbers each produces. Switch the recipe to run the same batch the classic way. Predict first: which recipe starts nearer the chance loss ln 10 = 2.30?
Bars and columns are the toy's numbers, each station on its own scale (the labels carry the values); dots show what moves at that moment and how many is schematic. One step shows what each moment computes, not which recipe is better: that takes thousands of steps, in the Training lab.
The toy: 16 layers of width 64; a batch of 32 random inputs (64 numbers each, standard normal) labelled into 10 classes by a fixed random linear "teacher"; a held-out batch of 256 from the same teacher. Classic: ReLU, He initialisation, BatchNorm, residual connections, SGD with momentum 0.9 at learning rate 0.1 and weight decay 10−4, as in ResNet (§3.4). 2026: pre-RMSNorm blocks with a SwiGLU feed-forward, AdamW with β = (0.9, 0.95), weight decay 0.1 and gradient clipping at 1.0, as in Llama 2 (§2.2) and DeepSeek-V3; the toy's learning rate (3 × 10−3, with no warmup) is illustrative. Every number is computed in your browser and matches an independent PyTorch run (src/read/recompute.py) to 10−7 or better.
| Moment, and what is chosen | Page that owns it | 2012 to 2016 | 2026 LLM |
|---|---|---|---|
| 1 Data, init batch size, input scaling, the starting weights' scale | Normalisation and initialisation | standardised inputs; He init | fan-in or σ = 0.02 init, residual branches scaled down |
| 2 Forward the nonlinearity; the norm and where it sits | Activation functions; norms on Normalisation and initialisation | ReLU, BatchNorm | SwiGLU, pre-RMSNorm |
| 3 Loss the loss, from the target's type | Loss functions | cross entropy | cross entropy on the next token |
| 4 Backward what keeps the gradient usable | no single owner: causes on the pages above, clipping on Optimisers | residuals, BatchNorm, no clipping | residuals, norms, clip at 1.0 |
| 5 Update optimiser and schedule, as a pair | Optimisers and learning-rate schedulers | SGD + momentum 0.9; step decay | AdamW (or Muon); warmup, cosine or WSD |
| 6 Regularise penalty, dropout, augmentation, stopping | Regularisation | L2 10−4 in the gradient, augmentation | decoupled weight decay 0.1, little else |
| 7 Measure the metric, on held-out data | Evaluation metrics | held-out accuracy | held-out loss (perplexity), benchmarks |
Three more pages sit beside the step rather than inside it (Beyond one network): Classical ML, Contrastive and self-supervised learning and Sequence models: the pre-transformer lineage. The recipes come from Defaults across models, which sources every cell for 21 landmark models.
You need gradient descent and the chain rule (Topic: math, sections on the gradient step and the chain rule; Calculus and optimisation for ML has the depth), and for the threads, likelihood and entropy (Probability for ML, Information theory for ML).
Mini-batch: the few dozen examples (or few million tokens) one gradient is computed on. Loss, cost: one example's error, and its batch mean (used interchangeably). Residual connection: x + F(x), an identity path around a layer. Pre-norm, post-norm: normalising the branch input, x + F(LN(x)), against the sum, LN(x + F(x)). Vanishing, exploding gradient: a product of per-layer factors that shrinks to nothing or grows without bound. Gradient clipping: scale the gradient down when its norm exceeds a threshold. Adaptive optimiser: one step size per parameter. Schedule: how the base learning rate moves over the run; warmup its ramp at the start, cooldown its decay at the end. Decoupled weight decay: shrinking the weights in the update, not through the loss. Held-out set: data the model never trains on, kept to measure it. Chance loss: what a model that knows nothing scores, ln K for K classes.
Numbers are published, with the source linked, unless marked derived (formula shown), illustrative, reported (the maker's own figure, not independently checked) or unconfirmed.
The batch is a compromise: the whole training set gives an exact but slow step (batch gradient descent), one example a cheap but very noisy one (stochastic gradient descent in the strict sense), and a mini-batch is efficient on hardware and only mildly noisy. Inputs are put on a common scale first (standardised, z = (x − μ)/σ, or min-max to [0, 1]) so no feature dominates because of its units.
The starting weights are random, never constant (equal weights get equal gradients and stay copies of each other), and their scale is the whole game: a layer with n inputs multiplies the signal's variance by about n · Var(w) times a factor set by its activation, so Var(w) is chosen to make that product 1. Xavier's 2/(nin + nout) suits sigmoid and tanh, He's 2/nin the ReLU family, LeCun's 1/nin SELU; large LLMs use a small fixed scale (OLMo 2 σ = 0.02, DeepSeek-V3 0.006) and scale residual branches down by 1/√N (GPT-2). Because the right scheme depends on the activation, init is chosen with it: thread 2.
Each layer is a linear map and a nonlinearity (without it the stack collapses to one linear map), and in every modern network also a normalisation and a residual connection. The activation rule is short: the ReLU family in hidden layers, the gated SwiGLU in transformer feed-forward blocks (a third matrix, so the hidden width is cut to ⅔ · 4d), and at the output whatever the target needs: a sigmoid per output for binary or multilabel, softmax for classes, nothing for regression. The norms differ by axis: BatchNorm normalises each feature across the batch (CNNs; it needs running averages at inference), LayerNorm and RMSNorm each example across its features (transformers; RMSNorm drops the mean and is in essentially every current LLM). Where the norm sits, before the branch (pre-norm, GPT-2 onwards) or after the sum (post-norm, 2017), is Normalisation, residuals and stability's subject.
Fig. 2: the same batch goes through five 16-layer networks, each a different pairing of activation, initialisation and normalisation, forward (top: how spread out each layer's output is) and backward (bottom: the size of each layer's weight gradient). Both axes are logarithmic: one gridline is a factor of 10. Predict: which network's first layer gets the smallest gradient? Pick a network above the chart; the grey dots are the one chosen under "compare with".
Width 64, batch 32, 16 layers, 10 classes, at initialisation. Activation spread: the standard deviation of every number a layer outputs (for residual networks, the residual stream). Gradient: the Frobenius norm of ∂loss/∂W for the layer's weights (for SwiGLU blocks, of all three matrices together). The "ReLU, init too small" network uses LeCun's 1/n with ReLU, half of He's variance, so its signal loses half its second moment at every layer. Inputs and weights are seeded and illustrative; the per-layer numbers are exact and match PyTorch autograd to 10−8 (src/read/recompute.py).
The loss follows from the target. A number gets a regression loss: MSE by default (it estimates the mean), MAE (the median) or Huber when outliers are real. A class gets cross entropy, minus the log of the probability given to the right class, so minimising it is maximum likelihood; label smoothing, class weights and focal loss only reweight its terms, and the hinge loss is the margin-based outsider (the SVM's). An order gets a ranking loss, a distribution KL divergence (VAEs, distillation, the RLHF anchor), and a GAN an adversarial game. L1 and L2 penalties are added to the loss but belong to regularisation.
Fig. 3: slide the probability the model gives the right class (10 classes, the rest shared equally) and compare what each loss charges and how hard it pushes. The gradient is with respect to the right class's logit: the size of the push. Predict: where does label smoothing's loss bottom out?
Check where the loss starts. A K-class classifier that knows nothing should score ln K: ln 10 = 2.303 for the toy. Its pre-norm network starts at 2.60 and the "init too small" one at 2.3025, but the BatchNorm residual network starts at 5.42, because its residual stream grows to a standard deviation of 2.47 by the last layer and nothing normalises it before the output (Fig. 2 shows the growth). A starting loss far from ln K is the first thing to check in When training goes wrong.
Exact formulas; the gradients match PyTorch autograd. Label smoothing uses Szegedy et al.'s target, 1 − ε + ε/K on the right class and ε/K on each other, so its loss is lowest at p = 0.91, not at 1; some texts put 1 − ε on the right class and ε/(K − 1) on the others, which moves that minimum to 0.9. Focal loss, −(1 − p)γ log p, down-weights the easy examples (Lin et al. 2017).
Backpropagation applies the chain rule from the loss back to every weight, so a weight in layer 1 of 16 receives a product of 15 layer factors: below 1 the product vanishes, above 1 it explodes, the same arithmetic in a deep stack and in a recurrent network unrolled through time (thread 3). The bottom panel of Fig. 2 is this step: in the sigmoid network the first layer's gradient is 9.5 × 10−11 against 0.18 for the last, about 2 billion times smaller derived (each sigmoid layer multiplies by its slope, at most 0.25); in the pre-norm SwiGLU network the ratio is 1.45 to 1.17, because the residual path carries the gradient down untouched.
The causes live on four different pages, which is why this table belongs here:
| Cause | Fix, by the stage it belongs to |
|---|---|
| Saturating activations | ReLU family or smooth ReLUs (step 2, Activation functions) |
| Wrong initial scale | Xavier for sigmoid and tanh, He for ReLU (step 1, Normalisation and initialisation) |
| Depth itself | residual connections (an identity path for the gradient) and normalisation layers (step 2); or fewer layers |
| Recurrence through time | the LSTM's additive cell state, a skip connection through time (Sequence models: the pre-transformer lineage) |
| A rare huge gradient | gradient clipping: if the gradient's norm exceeds a threshold, scale it down to the threshold (Pascanu et al. 2013); LLM runs typically clip at 1.0, as Llama 2 and DeepSeek-V3 do |
In Fig. 1 (step 4), the 2026 recipe's gradient norm is 5.50 and clipping scales it to 1.0 before the update, while the classic recipe (no clipping) passes its 13.4 straight on. How a vanishing or exploding gradient shows in a loss curve is in When training goes wrong.
The update turns a gradient into a weight change through three choices made together: smoothing over steps (momentum), a step size per parameter (adaptive methods), and the base rate's path over the run (the schedule). Adaptive methods only rescale relative to the base rate, so an optimiser and a schedule are always chosen as a pair. The families, by what they change:
| Family | What it changes | Where it is the default | Owner's section |
|---|---|---|---|
| SGD + momentum (Nesterov) | direction smoothed over steps; one step size for all | vision, ResNet-style training | 1 |
| Adam, AdamW | per-parameter steps from a running RMS of the gradient, bias-corrected; AdamW decouples the weight decay | essentially every LLM | 2 |
| Shampoo, SOAP | full-matrix (Kronecker-factored) preconditioning | AlgoPerf winners; little LLM use | 3 |
| Muon, Lion | the update's shape: Muon orthogonalises each hidden matrix's momentum (Newton-Schulz), Lion takes its sign | Muon pretrains Kimi K2 (1T parameters, as MuonClip) | 4 |
| Schedule-free, WSM | remove the decay curve: iterate averaging, or merging checkpoints | runs whose length is not known | 8 |
Schedules differ on one question: does the schedule need the run's length in advance? Warmup then cosine to about 10% of the peak needs it, so a cosine run stopped early sits at an untuned rate; WSD (warmup, stable, decay) holds the rate flat and decays over the last 10 to 20%, so the end can be chosen late. At a fixed, known budget the shapes nearly tie. Warmup exists because Adam's second-moment estimate rests on a handful of gradients in the first steps.
Regularisation trades a little training fit for better performance on unseen data. Each kind acts at a different moment of the step:
| Kind | Acts at | How |
|---|---|---|
| Penalty | the loss (step 3) or the update (step 5) | L1 (lasso) zeroes some weights, L2 (ridge) shrinks all, elastic net adds both |
| Dropout | the forward pass (step 2) | drop each unit with probability p in training, so no unit relies on one partner; survivors are rescaled in training, so inference drops nothing |
| Augmentation | the data (step 1) | random but realistic transforms enlarge the training set |
| Early stopping | the measurement (step 7) | stop when validation loss turns up; keep the best checkpoint |
LLM pretraining uses almost none of this: it sees most data about once, so there is little to overfit. What remains is weight decay, a regulariser by intent and an optimiser property by implementation (thread 4): in Fig. 1 the classic recipe folds 10−4·w into the gradient, while the 2026 recipe shrinks every weight by ηλ = 3 × 10−4 of itself, separately.
The toy's single step shows why measuring needs held-out data: under the 2026 recipe, the loss on the batch it trained on fell from 2.60 to 0.22 and accuracy on that batch went from 9.4% to 100%, while on the 256 held-out examples the loss moved from 2.77 to 2.71 and accuracy from 11.3% to 11.7%. One step memorised its batch and learned almost nothing general.
What to measure falls into three families. Classification numbers come from the confusion matrix at a threshold (precision, recall, F1) or across all thresholds (ROC-AUC, precision-recall); when positives are rare, ROC barely moves while precision-recall collapses, because the false positive rate divides by the whole negative class. Text scores compare an output with a reference (BLEU on clipped n-gram precision, ROUGE on recall, METEOR with stems and synonyms, BERTScore on embeddings), and perplexity, exp(mean negative log-likelihood per token), is the loss itself read as a measurement, comparable only under the same tokenizer. Information quantities (entropy, cross entropy, KL) are thread 1. Judging LLM output has moved to LLM judges and task benchmarks (Topic: evaluation-and-llm-judges).
Followed one stage at a time, the components look like separate menus. Four threads run through several stages at once, and they are the reason the choices come in matched sets.
Entropy H(P) = −Σ P log P is the average cost of encoding samples from P with P's own best code; cross entropy H(P, Q) = −Σ P log Q is the cost with a code built for Q; their difference is the KL divergence, DKL(P‖Q) = H(P, Q) − H(P) = Σ P log(P/Q), the extra paid for using the wrong code. KL is asymmetric and breaks the triangle inequality, so it is distance-like, not a distance. Since H(P) does not depend on the model, minimising cross entropy and minimising KL are the same thing, and that one fact runs through four stages:
Fig. 4: pick a target, then slide how much probability the model puts on the right answer. The bar is cross entropy split into the part no model can remove (H(P)) and the part training removes (KL).
Initialisation (step 1) and normalisation (step 2) chase one invariant: activation and gradient variance roughly constant from layer to layer, at step zero and for the rest of training. Initialisation sets it for step zero, and only for the activation it was derived for; normalisation re-imposes it at every step, which is why deep normalised networks are far less sensitive to the initial scale. So the three are chosen as a set:
| Activation | Initialisation that keeps the variance | Normalisation it is usually paired with |
|---|---|---|
| Sigmoid, tanh | Xavier, 2/(nin + nout) | none (pre-2015 networks), or the LSTM's own gates |
| ReLU family | He, 2/nin | BatchNorm in CNNs |
| SELU | LeCun, 1/nin | none: the activation itself pulls activations towards mean 0, variance 1 |
| GELU, SwiGLU in transformers | small fixed or fan-in scale, residual outputs scaled down | LayerNorm, now RMSNorm, before each block; QK-norm in attention |
Load the matching pairs into Fig. 2 and compare:
One failure shows up in four stages, and each stage has its own fix. In every case the gradient reaching an early layer is a product of per-layer (or per-time-step) factors:
Fig. 5: the fourth way, on one 60-step input sequence. Move the recurrent weight: the tanh network's gradient vanishes for every value, small weights shrinking it directly and large ones saturating the tanh, whose slope then shrinks it. The LSTM's cell path keeps its gradient alive while the forget gate stays near 1; lower its bias and it vanishes too.
All four are why "fix vanishing gradients" never has one answer, and why a symptom in the loss curve has to be traced back through every stage (When training goes wrong).
A scalar tanh RNN, at = tanh(w at−1 + xt), whose factor per step is w(1 − at2); and an LSTM cell path whose factor is the forget gate ft = σ(bf + xt), on the same seeded inputs xt ~ N(0, 0.52) illustrative; the products are exact. Exploding gradients need the factor to stay above 1, which a saturating unit resists; they appear in larger networks and are handled by clipping (step 4). Initialising the forget bias to 1 or more is a standard recommendation (Jozefowicz et al. 2015).
Weight decay is meant as a regulariser (step 6) but is implemented in the update (step 5), two ways. As L2 in the loss, λ/2 · ‖w‖2 adds λw to the gradient; as decoupled decay, w ← w − ηλw beside the gradient step. For plain SGD they are identical. For Adam they are not: the L2 term is divided by √v̂ like every gradient component, so weights with large, noisy gradients are barely decayed and weights with tiny gradients are pulled to zero at full speed. Decoupling restores one decay for every weight, and that is the whole of AdamW (Loshchilov and Hutter 2017).
The step above is supervised deep learning. Three neighbouring paradigms reuse its parts and add one idea each.
| Paradigm | The one idea it adds | What it shares with the step | Owner |
|---|---|---|---|
| Classical ML | models that are not trained by backpropagation: trees and ensembles, kernels, neighbours, clusters | losses (MSE, log-loss, hinge), L1 and L2, the metrics | Classical ML |
| Contrastive and self-supervised | labels made from the data itself: pairs, masks, predicted representations | InfoNCE is cross entropy (thread 1); augmentation becomes the task | Contrastive and self-supervised learning |
| Sequence models before the transformer | one state carried through time | vanishing gradients through time (thread 3); gating, the ancestor of SwiGLU | Sequence models: the pre-transformer lineage |
Bagging (random forests) cuts variance, boosting (each tree fits the loss's gradient) cuts bias, and gradient-boosted trees (XGBoost, LightGBM, CatBoost) were long the strong default on tabular data, generally ahead of deep networks there (Grinsztajn et al. 2022). Tabular foundation models now report beating tuned boosted trees on small datasets reported (TabPFN v2, Nature 2025); on the TabArena leaderboard (2 October 2026) they hold the top places, while at 100k to 1M rows tuned boosted trees and RealMLP sit within overlapping intervals. For tuning any model, random search beats grid search at equal budget (Bergstra and Bengio 2012). The dated evidence (section 4) and every method (sections 1 to 10) are on Classical ML.
InfoNCE classifies the one matching pair among the N items of a batch, so a model that knows nothing scores ln N: ln 32,768 = 10.4 for CLIP's batch derived (CLIP). Because the batch is the set of negatives, its size changes the task itself, which is why MoCo built a queue. The architecture follows the objective: a contrastive loss wants one vector per input, so it produces encoders, and in 2026 contrastive training is the standard recipe that turns any backbone, increasingly a decoder-only LLM, into an embedding model. Margins and triplets, the six designs, collapse and its defences, MAE and JEPA are on Contrastive and self-supervised learning.
The pre-transformer lineage earns its place because the transformer is what is left of it.
| Year | Model | Idea, and what survived |
|---|---|---|
| 1980s | RNN | at = f(Uxt + Wat−1), weights shared across time, trained by backpropagation through time; long-range gradients vanish or explode (thread 3) |
| 1997 | LSTM (Hochreiter and Schmidhuber) | sigmoid input and output gates around an additively updated cell state (the forget gate came in 2000, Gers et al.): a skip connection through time; its gating is the ancestor of SwiGLU |
| 2013, 2014 | word2vec (Mikolov et al.), GloVe (Pennington et al.) | one static vector per word, predicted from context (skip-gram, CBOW, negative sampling) or fitted to log co-occurrence counts; king − man + woman ≈ queen; superseded by contextual embeddings (ELMo, BERT) |
| 2014 | GRU (Cho et al.) | two gates, cell and hidden state merged, ht = (1 − zt) ⊙ ht−1 + zt ⊙ h̃t: the same additive trick with about a quarter fewer parameters |
| 2014 | seq2seq (Sutskever et al.) | an encoder RNN squeezes the source into one vector for a decoder RNN; quality collapses on long inputs (the bottleneck) |
| 2014, 2015 | attention (Bahdanau et al., Luong et al.) | keep every encoder state; at each output step, score them against the decoder state, softmax, take the weighted sum: the bottleneck disappears |
| 2016 | WaveNet (van den Oord et al.) | dilated causal convolutions, a receptive field growing exponentially with depth and no recurrence; its gated unit tanh ⊙ σ prefigures the GLU family |
| 2017 | Transformer | drops recurrence and keeps only attention, fully parallel over the sequence (Attention Is All You Need); everything after it is Topic: llm-architecture, Topic: llm-landscape and Topic: llm-training-and-post-training |
| 2023 to 2026 | state-space models | recurrence partly returns: Mamba and hybrid SSM-attention stacks get RNN-like constant cost per generated token with parallel training (Mamba) |
Every training failure lands on one of the seven stages, so debugging reads as the step run backwards from the symptom: a loss flat from the start points at the update or the backward pass (a rate off by 10, frozen layers, a loss that does not match the output activation), a loss that turns to not-a-number at numerics in the loss, oscillation at the learning rate or batch size, a plateau at vanishing gradients or dead ReLUs, training loss falling while validation loss rises at regularisation, good accuracy that is useless on the minority class at the metric. The symptom-to-cause-to-fix tables and the standing checklist are in When training goes wrong; the Training lab lets you cause each failure on purpose.
In the order of the step; reading times as each page's header states them.
Feature scaling, initialisation schemes (Xavier, He, LeCun, orthogonal, μP), and BatchNorm, LayerNorm, RMSNorm, GroupNorm and weight standardisation as one recipe on different axes. Steps 1 and 2, thread 2. Figures: Fig. 1, one batch through 20 layers, Fig. 3, one loss, three units, Fig. 5, one tensor, five choices of axes. (24 min, plus 14 in closed details)
Saturation, the ReLU family and dead units measured, smooth rectifiers, the gated units and the 2/3 rule, what real models use, the output layer. Step 2. Figures: Fig. 1, folding the plane with two ReLUs, Fig. 2, 384 hidden units, measured, Fig. 3, one token through two feed-forward blocks. (27 min, plus 5 in closed details)
What a loss makes a model estimate: regression losses as noise models, cross entropy and its gradient, focal loss and label smoothing, margins, ranking losses, the adversarial loss. Step 3. Figures: Fig. 1, a real padded batch, Fig. 2, one bad target, three losses, Fig. 3, one real next-token prediction, Fig. 4, every logit shifted together. (32 min, plus 5 in closed details)
Momentum, Adam and AdamW, Shampoo and SOAP, Muon and Lion, the evidence under a tuned baseline, batch size and the learning rate, schedules, schedule-free and WSM; an optimiser race. Step 5. Figures: Fig. 1, three optimisers on one ravine, Fig. 2, per-coordinate steps, Fig. 3, optimiser state beside one expert matrix, Fig. 4, Newton-Schulz on one real gradient, Fig. 5, the noise floor, Fig. 6, three endpoints. (33 min, plus 14 in closed details)
Penalties and their geometry, weight decay and AdamW, dropout, augmentation and mixing, early stopping, what each buys, and regularisation in networks that can memorise. Step 6, thread 4. Figures: Fig. 2, L1 and L2 on two coefficients, Fig. 3, weight decay on pure noise, Fig. 4, one digit through dropout. (32 min, plus 8 in closed details)
Thresholds, ROC and precision-recall, calibration, multi-class averaging, regression and ranked-list metrics, text metrics, perplexity, error bars, on real model outputs. Step 7. Figures: Fig. 1, one threshold, four counts, Fig. 2, one query, ten results, Fig. 3, one text, three tokenizers. (29 min, plus 7 in closed details)
Linear models, trees and ensembles, the dated tabular evidence, SVMs, kNN, clustering, anomaly detection, PCA and t-SNE, hyperparameter search; a boundary lab. Figures: Fig. 1, a tree grown depth by depth, Fig. 2, one tree, a forest and boosting, Fig. 3, the SVM score as a height, Fig. 4, PCA on three measurements. (31 min, plus 8 in closed details)
Margin and triplet losses, InfoNCE, six designs (SimCLR to VICReg), alignment and uniformity, collapse, MAE and JEPA, CLIP and embedding models. Figures: Fig. 1, eight sentence pairs, Fig. 2, one anchor, 48 candidates, Fig. 3, two branches, six designs, Fig. 4, digits on the unit sphere. (32 min, plus 8 in closed details)
Recurrence, the gradient through time, the LSTM gate by gate, GRU, seq2seq and attention, WaveNet, why the transformer replaced them, static word vectors. Thread 3. Figures: Fig. 2, a trained RNN, unrolled, Fig. 3, one LSTM cell, Fig. 4, two encoder-decoders, Fig. 5, one output traced back. (24 min, plus 5 in closed details)
Built from the old page "Topic: ml-fundamentals" (last edited 22 September 2026, fetched 3 October 2026) and its ten child pages, with every figure rechecked against its source on 3 October 2026; the page "Debugging training" is folded into this page. Rebuilt on 24 October 2026 as a map once its nine children were rebuilt. Toy computations: src/read/recompute.py (PyTorch and NumPy) and src/read/check_engine.mjs.
Each preset sets up both runs to make one point, says what you should see, and states on how many of seeds 1 to 10 it actually happens (measured with this page's own code, and re-checkable below).
Per layer, log scale; L1 is next to the input, "out" is the output layer. Activations: root mean square of each layer's output on the last training batch. Gradients: norm of each layer's weight-matrix gradient from the last step, before the optimiser touches it. Weights: norm of each layer's weight matrices. Vanishing shows as gradient bars shrinking towards L1; exploding as bars growing.
Every component of A and B can be set separately; rows where they differ are highlighted. Changing anything restarts both runs from the same seed. A preset is just a set of these values.
A single run can mislead: one seed's data, starting weights and batch order. This repeats the current comparison on seeds 1 to 10 without drawing, and checks each of the preset's claims on every seed. It takes from a few seconds to about a minute on a phone.
Twenty-one models from AlexNet (2012) to Kimi K2 and SmolLM3 (July 2025), on the same twenty building blocks: activation, normalisation, initialisation, optimiser, learning-rate schedule, weight decay, dropout, clipping, loss tweaks, batch and precision. Every cell gives its source (paper, official code or official config.json), the source's date, and whether the value is published, derived here by arithmetic (formula shown), inherited from a predecessor the paper says it follows, or unconfirmed. A cell the maker left empty says not disclosed and is coloured, because what a lab stays quiet about is part of the picture.
Each column header links to the child page that explains it: Activations, Normalisation and initialisation, Optimisers (optimiser, learning rate, clipping, batch), Regularisation, Loss functions, and for number formats Quantization and Precision on the training topic.
Pick a starting model and an end model. Each step swaps one building block from the first recipe to the second, says which model in the table first used the new choice, and keeps count. A block the end model does not disclose stays hatched: you cannot copy a recipe that was never written down.
One dot per model, in date order, coloured by the family of its choice; a hatched ring means the model does not disclose it. The lines under the chart name the first model in this table to use each family. The families are this tab's grouping, not the labs'.
One numeric setting at a time, every model that discloses it, on a logarithmic axis against the date. Rings are derived, inherited or unconfirmed values; models that do not disclose the setting are listed underneath.
For each column, how the models shown above split between published, derived, inherited, unconfirmed, not disclosed and does-not-apply. Bars count models, so each sums to the number of rows shown; the percentage is published plus derived over the models the column applies to. The Models filter above applies.
Things often said about these defaults, against the primary source.
A training curve that looks wrong usually has one of a handful of causes, and each cause lives in one band of the training step: the data, the initialisation, the activation, normalisation, the loss, the optimiser and its learning rate, the schedule, regularisation, or the metric. Pick what you see; the causes are listed most likely first, each with the check that confirms it, the fix, and the page that owns that band.
Every curve on this tab is a real run recorded offline for it (small networks on scikit-learn's 8x8 handwritten digits, and a two-layer character Transformer on Tiny Shakespeare), bug and fix with the same seed and the same batches; the scripts and logs are in src/debug/. The order of causes is a judgement from the sources cited (Karpathy's recipe, Google's Tuning Playbook) and these runs: no study counts how often each cause is the culprit.
Rows are symptoms, columns are bands; a number is the cause's rank for that symptom (1 = check first). Click a row or a number.
The same network, the same seed and the same batches, with the bug and with the fix, replayed from the recorded logs. The bars are the gradient norm of each layer's weights on a log scale (first layer on the left): a healthy deep network keeps them within a few orders of magnitude of each other; a vanishing one slopes down towards the input, an exploding one shoots off the top.
Every pathology as a real curve. Solid: training loss; dashed: validation loss; log scale. Click a curve to open its symptom above.
Andrej Karpathy's A Recipe for Training Neural Networks (2019) starts from two observations: neural network training is a leaky abstraction, and it fails silently ("Everything could be correct syntactically, but the whole thing isn't arranged properly, and it's really hard to tell"). Its answer is to build up from checks that cannot fail silently. The standing checklist:
y_hat = model(x), after the whole pipeline.Other items of the recipe: fix the random seed; "init well" (for a 1:10 imbalanced dataset, set the output bias so the network predicts 0.1 at initialisation); use backpropagation to chart dependencies (make the loss the sum of example i's outputs and check that only input i gets a gradient); Adam at 3e-4 is a safe first optimiser; add complexity one signal at a time; do not trust learning-rate decay defaults; and to regularise, first add more real data.
| Recorded run (10 classes) | Loss at step 1 | Reading |
|---|
The failure that only large runs used to show: after a long healthy stretch the loss jumps, sometimes recovers, sometimes diverges. Five sources, each linked:
Training the 540B model, Google "observed spikes in the loss roughly 20 times during training, despite the fact that gradient clipping was enabled", at irregular intervals, sometimes late, never in the smaller models. The fix: restart from a checkpoint about 100 steps before the spike and skip roughly 200 to 500 data batches. Replaying those batches from an earlier checkpoint did not spike, so the cause was "the combination of specific data batches with a particular model parameter state", not bad data alone. PaLM also added z-loss, 10-4 · log2 Z, to keep the softmax normaliser near 1, and clipped the global gradient norm at 1.0 (PaLM §5, §5.1).
Ai2 defined a spike score: "the percentage of values in a time series that are at least seven standard deviations away from a rolling average of the last 1,000 values", on the loss and the gradient norm. Each fix came with a before and after: normal initialisation N(0, 0.02) took the gradient-norm spike score from 0.40 to 0.03; reordered norm plus QK-norm from 0.108 to 0.069 (neither helped alone); no weight decay on embeddings from 0.16 to 0.092; plus z-loss, AdamW ε = 10-8 instead of 10-5, and a filter for repeated n-grams. The OLMo 2 paper page replays every ablation from the paper's vector figures with the spike score live; the Ai2 OLMo section of Other notable providers does it on the released training logs. (The z-loss weight is printed as 10-5 in OLMo 2's Table 1 and 10-4 in its §3.3.3 formula.)
Small-scale proxies for large-scale Transformer training instabilities showed that two instabilities seen at scale, attention logits that grow without bound (Dehghani et al. 2023) and output logits that diverge from the log-probabilities (PaLM), "also appear in small models when training at high learning rates", and that QK-norm and z-loss are "equally effective in this regime". That makes spikes debuggable on a laptop; the toy runs below do exactly that.
Meta called its 405B recipe "very stable: we observed few loss spikes and did not require interventions to correct for model training divergence" (§3.4.1). Its interruptions were hardware: 466 in a 54-day snapshot, 419 unexpected; that story is on Fault tolerance at scale and the Llama 3 Herd paper page. One numerical instability did appear: gradient accumulation in bf16 once the image encoder was added, fixed by accumulating in FP32 (§7.3).
The Deep Learning Tuning Playbook separates instability at initialisation from sudden instability mid-training, and finds it with a learning-rate sweep (plot the loss for rates just above the best). Its fixes, in order: warmup (best for early instability; sweep warmup over orders of magnitude, at most 10% of training), gradient clipping (threshold near the 90th percentile of logged norms; more than 50% of steps clipped means lower the rate instead), a different optimiser, architecture best practice (residuals, normalisation inside the residual, x + f(Norm(x))), and lowering the rate only as a last resort.
A two-layer character Transformer (about 0.4M parameters, context 64) trained for 1,500 steps on Tiny Shakespeare with AdamW and 50 warmup steps, swept over the peak learning rate, with and without QK-norm plus z-loss: Wortsman et al.'s experiment shrunk to a laptop. Left: final validation loss. Right: the largest attention logit seen in the run.
OLMo 2's spike score run on the toy's per-step logs at peak rate 1e-1, the rate where the sweep shows the damage (at 3e-2 the logits ran away too, but the loss never spiked and the gradient norm stayed below 1, so clipping at 1.0 never acted). The paper uses a 1,000-value window on runs of hundreds of thousands of steps; these runs have 1,500, so the window defaults to 100. Note what the gradient norm separates and the final loss alone would not: at the default window and threshold the gradient norm spikes 8 times with no fix, 13 with z-loss alone (the attention logits, not the output logits, are what run away here), 11 with clipping (which still lowers the loss spike, 3.84 against 4.82, and the final loss), and 0 with QK-norm, alone or with z-loss.
Folded in from the former child page "Debugging training" (every fact of it is carried here; the short version is in the Reading tab). Recorded runs: src/debug/runs_digits.py, runs_imbalance.py, runs_spike.py (PyTorch, CPU, 2 threads, fixed seeds); data: scikit-learn digits and Tiny Shakespeare.
The Reading tab maps one training step and compares the components at the moment each acts; the three tabs on this page let you run, look up and debug them across every stage; the nine pages under this one each own one family of components in depth. Links open in a new tab, with reading times.
A small network trained live in your browser: swap the loss, activation, initialisation, normalisation, optimiser, schedule and regularisation and watch the run change. Behind every stage of the Reading tab.
What landmark models actually chose at each stage, from AlexNet to DeepSeek-V3. Behind the two recipes of the Reading tab's Fig. 1.
Symptom to cause to fix: fit problems, gradient pathologies, loss-curve shapes, imbalanced data, and the standing checklist. The old "Debugging training" page lives here now.
In the order of the step; reading times as each page's header states them.
Feature scaling, initialisation schemes (Xavier, He, LeCun, orthogonal, μP), and BatchNorm, LayerNorm, RMSNorm, GroupNorm and weight standardisation as one recipe on different axes. Steps 1 and 2, thread 2. (24 min, plus 14 in closed details)
Saturation, the ReLU family and dead units measured, smooth rectifiers, the gated units and the 2/3 rule, what real models use, the output layer. Step 2. (25 min, plus 5 in closed details)
What a loss makes a model estimate: regression losses as noise models, cross entropy and its gradient, focal loss and label smoothing, margins, ranking losses, the adversarial loss. Step 3. (32 min, plus 5 in closed details)
Momentum, Adam and AdamW, Shampoo and SOAP, Muon and Lion, the evidence under a tuned baseline, batch size and the learning rate, schedules, schedule-free and WSM; an optimiser race. Step 5. (33 min, plus 14 in closed details)
Penalties and their geometry, weight decay and AdamW, dropout, augmentation and mixing, early stopping, what each buys, and regularisation in networks that can memorise. Step 6, thread 4. (32 min, plus 8 in closed details)
Thresholds, ROC and precision-recall, calibration, multi-class averaging, regression and ranked-list metrics, text metrics, perplexity, error bars, on real model outputs. Step 7. (29 min, plus 7 in closed details)
Linear models, trees and ensembles, the dated tabular evidence, SVMs, kNN, clustering, anomaly detection, PCA and t-SNE, hyperparameter search; a boundary lab. (31 min, plus 8 in closed details)
Margin and triplet losses, InfoNCE, six designs (SimCLR to VICReg), alignment and uniformity, collapse, MAE and JEPA, CLIP and embedding models. (31 min, plus 8 in closed details)
Recurrence, the gradient through time, the LSTM gate by gate, GRU, seq2seq and attention, WaveNet, why the transformer replaced them, static word vectors. Thread 3. (24 min, plus 5 in closed details)
What happens when this one step is run trillions of times on a language model: pretraining, mid-training, post-training, compression, and the machinery under them, compared on four axes. (27 min, plus 22 in closed details)
The labs and models the components on this page end up in, compared on thinking, serving cost and openness.
Where Muon came from (the nanoGPT speedrun), the anneal as a data lever, and run stability at scale. Step 5. (30 min, plus 4 in closed details)
Soft targets, forward against reverse KL, and a toy student distilled live: thread 1 in depth. (25 min, plus 8 in closed details)
Muon's Newton-Schulz step, qk-clip and MuonClip at trillion-parameter scale. Step 5. (38 min, plus 10 in closed details)
Where evaluation goes after the metrics of step 7: benchmarks and LLM judges.
Each links to its page in the Papers database, which checks the paper's claims and usually runs a toy of it; each page states its own reading time.
Where the sequence lineage ends; post-norm, Adam with warmup and inverse-square-root decay, label smoothing 0.1; its Then and now tab turns the 2017 block into a 2026 one.
An encoder trained by masked-token prediction; behind BERTScore and the encoder half of contrastive learning.
Symmetric InfoNCE over a batch of 32,768, run live in a tiny CLIP; and the vision transformer that most contrastive and self-supervised backbones now use.
Replacing the learning-rate decay by merging checkpoints; and why a cosine schedule must match the run's length.
Three disclosed 2024 to 2025 recipes: initialisation scale, norm placement and QK-norm, warmup-cosine, constant-then-decay, clipping.
Recurrence returns as a selective state-space model: the postscript to the sequence lineage.
Why training fails silently, and the habits that catch it: the practical companion to When training goes wrong. (about 35 min)
A systematic method for hyperparameter tuning and debugging, from the folded "Debugging training" page. (about 2h for the main document)
The focal loss of step 3 and the reference for training on extreme class imbalance. (45 min)
The canonical survey, SGD through Adam and Nadam: the families of step 5 in full. (about 40 min)
Surveys spanning contrastive and self-supervised learning and beyond. (about 3h for the core surveys)
The textbook behind every stage of the step. (about 20h)
Each is linked where it is used; reading times as the child pages record them where they list the source.