jaxdem.writers.checkpoints#
Orbax checkpoint writers and loaders for simulations and RL models.
Classes
|
Base class that provides context management and shared setup 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), raise aRuntimeErrorwhen the loader cannot re-import a custom force function recorded in the checkpoint. IfFalse, skip force functions that do not load, with a warning.
- Returns:
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, keep all checkpoints.
- clean: bool = False#
If True, erase and recreate the target directory on construction. If False (the default), keep existing checkpoints in the directory, 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
The writer serializes custom force functions passed via
force_manager_kwby their fully-qualified module path (e.g.mypackage.forces.trap). A different script cannot restore functions defined in the top-level script (__main__). The writer emits a warning at save time if any force function lives in__main__. To keep checkpoints portable, define force functions in an importable module.- max_to_keep: int | None = None#
Keep the last max_to_keep checkpoints. If None, keep all checkpoints.
- clean: bool = False#
If True, erase and recreate the target directory on construction. If False (the default), keep existing checkpoints in the directory, so a resumed run does not destroy earlier checkpoints.