Skip to content
All articles

AI Training · Checkpoints

A checkpoint is more than the weights

A training step changes far more state than the parameters. Leave the optimizer, scheduler, scaler, random state or data cursor out of a checkpoint and a resumed run can drift.

· 4 min read

One training step drawn as a loop: batch (tokens, masks, labels), forward (activations), loss (the objective), backward (gradients), gradient sync (all-reduce across ranks), optimizer step (parameters and state), then back to the next batch. To resume the same run, a checkpoint must save all nine: the weights, optimizer state, LR scheduler, loss scaler, RNG states, data cursor, sampler epoch, global step and configuration. Leave one out and it can still resume, as a plausible but different run.

A framework's training call hides most of what one step touches. That is fine until you checkpoint, restart, or spread the work across many ranks, and state you never looked at has to stay consistent.

What one step actually does

A loader produces token IDs, masks, labels and optional metadata. The forward pass computes activations and the loss. Automatic differentiation walks the graph backward to produce gradients, and across ranks a gradient synchronization (an all-reduce or a reduce-scatter) makes the ranks agree on the gradients each one needs. The optimizer turns those gradients and its own internal state into parameter updates, while a scheduler changes the learning rate. Gradient accumulation may repeat forward and backward several times before one optimizer step.

Mixed precision adds more state: autocast, loss scaling, overflow detection, unscaling and master-precision copies, depending on the format and the optimizer. FP16 commonly uses loss scaling; BF16 usually does not need it. Dropout and data augmentation consume random numbers that depend on the seed and the rank.

What a checkpoint has to capture

The course lists nine things to capture:

StateWhat it holds
Parametersthe weights
Optimizer statethe optimizer's internal state, which shapes every update
Schedulerhow far the learning-rate schedule has run
Scalerthe loss-scaling state, when the precision format uses one
Random generatorsthe streams that dropout and augmentation draw from
Data cursorwhere the loader has reached
Sampler epochwhich epoch's order the sampler is on
Global stepthe number of optimizer steps taken so far
Configurationthe settings the run started with

Omit one and the run can still resume, but, in the course's words, it can create a plausible but different continuation.

Engineering Insight

Time the phases separately: data wait, host-to-device copy, forward, backward, gradient synchronization, optimizer, checkpoint and idle barrier. Accelerator kernels run asynchronously, so synchronize the timing correctly. Then validate the loss and gradients on a tiny deterministic batch. If that baseline is not trustworthy, distributed equivalence cannot be established.

Get one diagram a week

A short article built around one engineering diagram, from the same library as these courses.

One diagram-led article a week on AI and systems engineering. We email you once to confirm, and every newsletter has an unsubscribe link. Privacy policy