What is a checkpoint

A checkpoint is a save point of a machine learning model at a specific moment during training. It stores the model's state, including weights, optimizer configuration, training step, and sometimes epoch metrics. With a checkpoint, you can resume training from that point or evaluate the model without starting from scratch.

How a checkpoint works

During training, the loop periodically saves the model's state. The checkpoint is saved to a file within a checkpoints directory, with each file representing an iteration or epoch. When resuming, the trainer loads the checkpoint, reinitializes the optimizer with the saved state, and continues the process. This way, training can be interrupted and resumed without losing significant progress.

Practical example

If a model's training takes days and is interrupted by an issue, the checkpoint allows restarting from the last saved state instead of starting from zero. Unlike a final model, a checkpoint is used mid-process to continue or evaluate. In production, the model is a checkpoint that can be served or retrained with new data.

What a checkpoint is for

Checkpoints prevent progress loss, allow resuming training after interruptions, and enable comparing models at different stages. In production, checkpoints facilitate deploying different versions and rolling back older models. They are essential in long-duration training scenarios and workflows involving multiple experiments.

Versioning strategies

Keeping checkpoints well organized helps navigate the training space. Naming checkpoints with validation metrics and training steps makes comparison easier. Versioning checkpoints alongside code and data enables reproducing results and comparing alternatives. In production environments, it is important to ensure that checkpoints used to serve the model have been evaluated and approved, preventing untested versions from reaching production.