Bookmarks

Model checkpoint

A saved state of a model at a given training step: the weights and, as a rule, everything needed to resume training from that point.

Also: checkpoint, training checkpoint, model checkpoint

checked 18 Nov

All terms

Training a large model takes days or weeks, and anything can break in that time: a server, a disk, a job in the queue. A checkpoint is a snapshot written to disk every few hundred or few thousand steps, so that you don’t have to start over and can later pick the best moment.

What is inside

The word “checkpoint” is used in two senses. A full training checkpoint is needed to resume work from the same point. A “weights only” checkpoint is needed to run the model or publish it.

PartWhat it is for
Model weightsthe parameters themselves: inference runs on them too
Optimiser stateaccumulated values (for AdamW, two numbers per parameter); without them the optimiser starts accumulating from scratch, and training cannot resume from the same point
Learning rate schedulerthe current step of the learning rate schedule
Random number state and stepso that the data and the order of batches are neither repeated nor thrown off

That is why a full checkpoint is noticeably larger than the published model: the optimiser usually keeps its numbers in FP32, and for a model with 9 billion parameters the two AdamW states add 9 × 8 = 72 GB to the 18 GB of BF16 weights.

Working with checkpoints in Transformers

The Trainer from the Transformers library saves directories such as checkpoint-500 according to save_strategy and save_steps. With save_only_model=True, only the weights go into the checkpoint: it is smaller, but training cannot be resumed from it. save_total_limit caps the number of checkpoints kept and deletes the old ones, load_best_model_at_end=True loads the best one by metric at the end (it is not deleted in the process), and an interrupted training run can be resumed like this:

python
trainer.train(resume_from_checkpoint=True)

The value True takes the latest checkpoint from output_dir, while a string names a specific directory. The final model is made from the best checkpoint (a LoRA adapter can be merged into the base model first): it is saved in safetensors and, if needed, converted to GGUF.

Sources

the term is written from these pages

Verified 18 Nov

Not to be confused with

what it is mixed up with and how it differs

  • safetensors format

    safetensors is a file format for storing weights, whereas a checkpoint is a model state that can be written in different formats.

In depth in the references

where the topic is covered in detail

Appears in the references