ExperimentRollbackController
python
ExperimentRollbackController(checkpoint_manager: CheckpointManager, monitor: AutoRollbackMonitor | None) -> NoneCoordinates checkpoint tracking and checkpoint selection for automatic rollback.
Initialize the rollback controller.
Parameters:
checkpoint_manager(CheckpointManager) – Checkpoint manager used to load and move checkpoints.monitor(AutoRollbackMonitor | None) – Optional automatic rollback monitor.
Properties
last_checkpoint_number
python
last_checkpoint_number: int | NoneGet the most recent checkpoint number seen by the controller.
Returns:
int | None– The latest checkpoint number, orNoneif no checkpoint is known.
monitor
python
monitor: AutoRollbackMonitor | NoneGet the configured automatic rollback monitor.
Returns:
AutoRollbackMonitor | None– The monitor, orNoneif automatic rollback is disabled.
Methods
mark_restored_checkpoint
python
mark_restored_checkpoint(checkpoint_number: int | None) -> NoneRecord that the experiment resumed from an existing checkpoint.
Parameters:
checkpoint_number(int | None) – The restored checkpoint number.
mark_rolled_back
python
mark_rolled_back(step: int) -> NoneNotify the monitor that a rollback completed.
Parameters:
step(int) – The actor step at which the rollback happened.
record_checkpoint
python
record_checkpoint(checkpoint_number: int, actor_step: int) -> NoneRecord a newly-saved checkpoint and the actor step at which it was written.
Parameters:
checkpoint_number(int) – The checkpoint number.actor_step(int) – The actor step at the time of saving.
record_metric
python
record_metric(step: int, value: float) -> NoneFeed an observed metric value into the rollback monitor.
Parameters:
step(int) – The actor step.value(float) – The observed metric value.
should_rollback
python
should_rollback() -> boolCheck whether the configured rollback monitor requests a rollback.
Returns:
bool–Trueif a rollback should occur, elseFalse.
try_prepare_rollback
python
try_prepare_rollback(current_step: int) -> tuple[int, Checkpoint] | NoneSelect and load the rollback target checkpoint for the current step.
Parameters:
current_step(int) – The current actor step.
Returns:
tuple[int, Checkpoint] | None–(checkpoint_number, checkpoint)if a rollback target was found, elseNone.
Raises:
RuntimeError– If automatic rollback is not configured.