accelmo.tracking.sgd.checkpointing¶
Checkpoint persistence and knob-remapping for the optimisation loop.
The OptimisationCheckpointer owns everything related to saving and
restoring an SGDLoop:
serialising loop/optimiser state to JSON, deciding when a checkpoint is due, and
remapping a saved optimiser state onto the loop’s current knob layout when the
two differ. It reads and writes the loop’s state directly through a back
reference so the loop itself stays focused on running epochs.
- class accelmo.tracking.sgd.checkpointing.CheckpointState[source]¶
Bases:
TypedDictContents of a checkpoint file.
- saved_epoch: int¶
- next_epoch: int¶
- current_knobs: dict[str, float]¶
- prev_loss: float | None¶
- class accelmo.tracking.sgd.checkpointing.OptimisationCheckpointer(loop, checkpoint_config=None)[source]¶
Bases:
objectSaves and restores optimisation-loop state to/from a JSON checkpoint.
- Parameters:
loop (SGDLoop)
checkpoint_config (CheckpointConfig | None)
- path: Path | None¶
- should_save_periodic(epoch)[source]¶
Return True when this epoch should trigger periodic checkpointing.
- Return type:
bool- Parameters:
epoch (int)
- should_save_final(last_completed_epoch)[source]¶
Return True when a final checkpoint should be written on loop exit.
- Return type:
bool- Parameters:
last_completed_epoch (int)
- save(epoch, current_knobs, prev_loss)[source]¶
Save optimisation state so the run can be resumed later.
- Return type:
None- Parameters:
epoch (int)
current_knobs (dict[str, float])
prev_loss (float | None)