StateAdapter
Shared checkpoint capture/restore plumbing for algorithm-specific state adapters.
Subclasses (DQNStateAdapter, PPOStateAdapter) hold the algorithm-specific models and runtime protocols; this base owns the pieces that are identical across algorithms: tester-totals capture and reusable trajectory-store restore.
Deliberately has no __init__ and no attribute declarations of its own: it reads self._config/self._trainer/self._tester directly, trusting each subclass to set them (with its own more specific types, for example DQNExperimentConfiguration vs PPOExperimentConfiguration). Declaring these names here too -- even as bare type annotations with no assignment -- would make a static type checker infer one (wrongly narrow) type per attribute name across the whole hierarchy, since it unifies every declaration of a given attribute name found anywhere in the class's MRO.
Methods
restore_for_rollback
restore_for_rollback(checkpoint: Checkpoint) -> intRestore only the state needed to continue training after an automatic rollback.
Parameters:
checkpoint(Checkpoint) – The checkpoint to roll back to.
Returns:
int– The global step the checkpoint was saved at.
restore_trajectory_store_file
restore_trajectory_store_file(checkpoint_file: CheckpointFile | None, checkpoint_number: int | None) -> boolRestore the reusable trajectory store from a separate checkpoint file.
Parameters:
checkpoint_file(CheckpointFile | None) – The checkpoint file to inspect.checkpoint_number(int | None) – The originating checkpoint number, when known.
Returns:
bool–Truewhen the store was restored.
tester_totals
tester_totals() -> AgentEpisodeTotalsStateCapture the tester's episode totals for checkpointing.
Returns:
AgentEpisodeTotalsState– The tester's episode totals, or all zeros when no tester is configured.
trajectory_store_checkpoint_files
trajectory_store_checkpoint_files(trajectory_store_file: CheckpointFile | None, archived_route_ids: list[int]) -> list[CheckpointFile]Build the trajectory-store checkpoint file plus its optional debug sidecars.
Parameters:
trajectory_store_file(CheckpointFile | None) – The trajectory-store checkpoint file, orNonewhen trajectory training is disabled.archived_route_ids(list[int]) – The trajectory ids currently held in the live best-route archive.
Returns:
list[CheckpointFile]– The trajectory-store file and, when configured, its debug sidecars.