Module 03 · AI · Past the basics · about 23 min to read
Continue where you left off ×
When the long run breaks: training diagnostics at scale
From Transformer to LLM · Open board
The board that draws how a transformer becomes a language model. This lesson is about the long pretraining step on that board, and what you do when it stops, slows or blows up.
Before you start. From What the model ate: pretraining data and the recipe : a loss spike is a sudden jump in the loss, and clipping caps the length of one step but does not stop every spike. From Four Ways to Split a Model : training keeps a 4-byte copy of each weight plus two optimizer numbers, and bf16 is a 2-byte format with wide range but little detail. From How It Learns (loss, gradient descent, backprop) : a step moves the weights to lower the loss. From The GPU (thousands of cores, and the memory that feeds them) : GPU memory is fast but small.
The idea in 30 seconds
Gradient accumulation adds up several small micro-batch gradients, each divided by the number of micro-batches, to make the step of one big batch.
Activation checkpointing stores a few activations and recomputes the rest, trading about one extra forward pass for far less memory.
A bf16 running total can stall, so sums are made in 4 bytes, and FP8 needs one scale per small tile so an outlier cannot flatten its neighbours.
The gradient norm, logged beside the loss, jumps on the step of a bad batch, and clipping, skipping or rewinding handle it.
A checkpoint holds the weights, the optimizer’s two numbers per weight, the step count and the data position, and missing any one makes a resumed run drift.
At 16,384 chips a stop came about every three hours, so a run is built to be stopped and restarted.
Read the story
Lesson 39 of 83 in AI
The rest of this lesson is part of a plan.
A plan opens every lesson, board, video, lab and paper on chalk. Yearly is $39/year .
See plans Already a member? Sign in
Or start free : a free account opens lessons 2 and 3 of every track.
In this lesson 54 days, 419 unexpected stops Gradient accumulation: many small pots, one serving Activation checkpointing: write down only some of the steps The accumulator: where bf16 quietly stops adding FP8 and the tile scale: one big number ruins its neighbours The gradient norm: the number that moves before the loss Checkpoint and resume: the state is more than the weights Symptoms, causes and fixes Accumulation and the cost of syncing Checkpointing: choosing what to recompute Number formats: three different failures Spikes: what to log and what to do Checkpoint and resume: the full list All of it in code Terms it explains: gradient accumulation, micro-batch, activations, activation checkpointing, accumulator, FP8, scale, checkpoint, Common mistakes, alignment, autoregressive, base model, Chinchilla, decoder-only, distribution, emergent ability, in-context learning, logits, next-token prediction, parameters / data / compute, pretraining, scaling laws, self-supervised.
Review AI
Mark as read Saved in this browser, and to your account when you sign in.