jaxdem.writers.checkpoints#
Orbax checkpoint writer and a loader.
CheckpointWriter: saves checkpoints with preservation/decision policies
CheckpointLoader: restores checkpoints (latest or specific step)
Classes
|
Base class providing context management and boilerplate for Orbax checkpointers. |
|
Thin wrapper around Orbax checkpoint restoring for jaxdem.state and jaxdem.system. |
|
Thin wrapper around Orbax checkpoint restoring for jaxdem.rl.models.Model. |
|
Thin wrapper around Orbax checkpoint saving for jaxdem.rl.models.Model. |
|
Thin wrapper around Orbax checkpoint saving. |
- class jaxdem.writers.checkpoints.CheckpointLoader(directory: Path | str = PosixPath('checkpoints'))#
Bases:
BaseCheckpointManagerThin wrapper around Orbax checkpoint restoring for jaxdem.state and jaxdem.system.
- load(step: int | None = None, *, strict: bool = True) tuple[State, System][source]#
Restore a checkpoint.
- Parameters:
step (Optional[int]) –
If None, load the latest checkpoint.
Otherwise, load the specified step.
strict (bool, optional) – If
True(default), fail with aRuntimeErrorwhen a custom force function recorded in the checkpoint cannot be re-imported, instead of silently loading the system without that physics. PassFalseto skip unloadable force functions with a warning.
- Returns:
A tuple containing the restored State and System.
- Return type:
- class jaxdem.writers.checkpoints.CheckpointModelLoader(directory: Path | str = PosixPath('checkpoints'))#
Bases:
BaseCheckpointManagerThin wrapper around Orbax checkpoint restoring for jaxdem.rl.models.Model.
- class jaxdem.writers.checkpoints.CheckpointModelWriter(directory: Path | str = PosixPath('checkpoints'), max_to_keep: int | None = None, save_every: int = 1, clean: bool = False)#
Bases:
BaseCheckpointManagerThin wrapper around Orbax checkpoint saving for jaxdem.rl.models.Model.
- max_to_keep: int | None = None#
Keep the last max_to_keep checkpoints. If None, everything is saved.
- clean: bool = False#
If True, the target directory is erased and recreated on construction. If False (the default), existing checkpoints in the directory are kept, so a resumed run does not destroy earlier checkpoints.
- class jaxdem.writers.checkpoints.CheckpointWriter(directory: Path | str = PosixPath('checkpoints'), max_to_keep: int | None = None, save_every: int = 1, clean: bool = False)#
Bases:
BaseCheckpointManagerThin wrapper around Orbax checkpoint saving.
Notes
Custom force functions passed via
force_manager_kware serialized by their fully-qualified module path (e.g.mypackage.forces.trap). Functions defined in the top-level script (__main__) cannot be restored from a different script. A warning is emitted at save time if any force function lives in__main__. To ensure portability, define force functions in an importable module.- max_to_keep: int | None = None#
Keep the last max_to_keep checkpoints. If None, everything is saved.
- clean: bool = False#
If True, the target directory is erased and recreated on construction. If False (the default), existing checkpoints in the directory are kept, so a resumed run does not destroy earlier checkpoints.