Skip to content

checkpoint⚓︎

Checkpoint/restart machinery shared by PIPT and POPT.

Both the optimization schemes in :mod:popt.optimization_methods and the assimilation schemes in :mod:pipt.update_schemes are long-running iterative algorithms that need to survive interruption. The persistence logic is identical for both, so it lives here rather than being duplicated per package.

A host class must provide:

  • restart (bool): whether a checkpoint should be restored on startup.
  • restart_file (str): path to the checkpoint file.
  • logger: a :class:ensemble.logger.PetLogger or None.
  • _get_base_restart_state() / _set_base_restart_state(state): serialize and restore the state owned by the algorithm base class.
  • _get_restart_state() / _set_restart_state(state): the same, for state owned by the concrete subclass. Both default to storing nothing, so only a host that carries its own iteration state needs to implement them.

Checkpoints record the writing class, so a file written by one algorithm cannot silently be loaded into another.

RestartMixin ⚓︎

Reusable checkpoint and restart functionality for iterative algorithms.

clear_restart() ⚓︎

Delete the restart file if it exists.

load_restart() ⚓︎

Restore optimizer state from a restart file.

save_restart() ⚓︎

Save the current optimizer state to a restart file.