sequince.checkpoint#
Attributes#
Classes#
Base class for persisting committed SMC checkpoints. |
|
Checkpoint state associated with one configured SMC step. |
|
Detached end-of-iteration state for resuming an SMC run. |
|
Persist committed SMC checkpoints to HDF5 at a fixed cadence. |
|
Atomically persist committed SMC checkpoints as pickle files. |
Functions#
|
Capture mutable state from a configured step pipeline. |
|
Restore step state after validating pipeline identity and order. |
Module Contents#
- sequince.checkpoint.CHECKPOINT_VERSION = 1#
- class sequince.checkpoint.CheckpointWriter(*, every=1, save_rng=True)[source]#
Bases:
abc.ABCBase class for persisting committed SMC checkpoints.
- requires_detached_checkpoint = True#
Whether the writer may retain the checkpoint after
writereturns.
- every = 1#
- save_rng = True#
- write(checkpoint)[source]#
Apply this writer’s options and persist the checkpoint.
- Parameters:
checkpoint (SMCCheckpoint)
- Return type:
None
- class sequince.checkpoint.StepState[source]#
Checkpoint state associated with one configured SMC step.
- classmethod from_dict(payload)[source]#
- Parameters:
payload (collections.abc.Mapping[str, Any])
- Return type:
- sequince.checkpoint.capture_step_states(steps)[source]#
Capture mutable state from a configured step pipeline.
- Parameters:
steps (collections.abc.Sequence[Any])
- Return type:
- sequince.checkpoint.restore_steps(steps, states)[source]#
Restore step state after validating pipeline identity and order.
- Parameters:
steps (collections.abc.Sequence[Any])
states (collections.abc.Sequence[StepState])
- Return type:
None
- class sequince.checkpoint.SMCCheckpoint[source]#
Detached end-of-iteration state for resuming an SMC run.
- states: tuple[sequince.state.ParticleState, ...]#
- evaluation_counts: sequince.target.EvaluationCounts#
- observation: Any = None#
- initial_state: sequince.state.ParticleState | None = None#
- property state: sequince.state.ParticleState#
Return the current state represented by this checkpoint.
- Return type:
- classmethod from_runtime(state, context, result, steps, rng=None, *, detach=True)[source]#
Capture a checkpoint after a completed SMC iteration.
- Parameters:
state (sequince.state.ParticleState)
context (sequince.steps.context.StepContext)
result (sequince.result.SMCResult)
steps (collections.abc.Sequence[Any])
rng (Any | None)
detach (bool)
- Return type:
- classmethod from_dict(payload, *, copy_values=True)[source]#
Reconstruct a checkpoint from
to_dict()output.- Parameters:
payload (collections.abc.Mapping[str, Any])
copy_values (bool)
- Return type:
- restore_rng()[source]#
Return a live ORNG generator restored from this checkpoint.
- Return type:
Any | None
- result(shared_context=None)[source]#
Return the result states represented by this checkpoint.
- Parameters:
shared_context (collections.abc.Mapping[str, Any] | None)
- Return type:
- save_pickle(file_path, protocol=None)[source]#
Save this checkpoint as a versioned pickle payload.
- Parameters:
file_path (str | pathlib.Path)
protocol (int | None)
- Return type:
None
- classmethod load_pickle(file_path)[source]#
Load a trusted checkpoint from a pickle file.
- Parameters:
file_path (str | pathlib.Path)
- Return type:
- save_hdf5(h5_file, path='checkpoint', dsetname='runtime', protocol=None, *, replace_states=False)[source]#
Append states and commit their count with the runtime payload.
Interrupted writes leave the previous runtime readable. This protects against incomplete writes in a readable HDF5 file, not file corruption.
- class sequince.checkpoint.HDF5CheckpointWriter(file_path, *, every=1, path='checkpoint', dsetname='runtime', save_rng=True)[source]#
Bases:
CheckpointWriterPersist committed SMC checkpoints to HDF5 at a fixed cadence.
- requires_detached_checkpoint = False#
Whether the writer may retain the checkpoint after
writereturns.
- file_path#
- path = 'checkpoint'#
- dsetname = 'runtime'#
- class sequince.checkpoint.PickleCheckpointWriter(file_path, *, every=1, save_rng=True, protocol=None)[source]#
Bases:
CheckpointWriterAtomically persist committed SMC checkpoints as pickle files.
- Parameters:
file_path (str | pathlib.Path)
every (int)
save_rng (bool)
protocol (int | None)
- requires_detached_checkpoint = False#
Whether the writer may retain the checkpoint after
writereturns.
- file_path#
- protocol = None#