astronomix.setup_helpers.restart#
Restart a simulation from the latest on-disk Orbax checkpoint.
Convenience around the disk-checkpointing (snapshot_storage_mode == TO_DISK)
path of the time integration: it reads the most recent checkpoint written to a
directory and returns everything needed to continue the run.
Module Contents#
Functions#
Load the latest (or a specific) checkpoint and prepare a resumed run. |
|
The most recent checkpoint step in |
API#
- astronomix.setup_helpers.restart.restart_from_latest_checkpoint(directory, params: astronomix.option_classes.simulation_params.SimulationParams, *, step: Optional[int] = None, sharding: Optional[jax.sharding.Sharding] = None) Tuple[jax.Array, astronomix.option_classes.simulation_params.SimulationParams, astronomix.time_stepping.time_integration.LoopState][source]#
Load the latest (or a specific) checkpoint and prepare a resumed run.
- Args:
directory: The checkpoint directory used as
snapshot_storage_path. params: The simulation parameters of the run to resume. Returned witht_startset to the checkpoint’s time so the integration picks up where it left off.- step: The checkpoint step to restore.
None(default) restores the latest one.
- sharding: Optional target sharding for the restored state / forcing
(e.g. when resuming on a different device topology). When
Nonethe sharding stored in the checkpoint is recovered.
- step: The checkpoint step to restore.
- Returns:
(primitive_state, params, restart_state)whereprimitive_stateis the restored (unpadded) state to pass as the first argument oftime_integration(),paramshast_startset to the checkpoint time, andrestart_stateis theLoopStatecarrying the PRNG key and OU forcing field to pass viarestart_state=.
Example:
ps, params, restart = restart_from_latest_checkpoint( path, params, sharding=sharding ) final = time_integration( ps, config, params, registered_variables, sharding=sharding, restart_state=restart, )