Skip to content

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.

Source

Methods ​

restore_for_rollback ​

python
restore_for_rollback(checkpoint: Checkpoint) -> int

Restore 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.

Source

restore_trajectory_store_file ​

python
restore_trajectory_store_file(checkpoint_file: CheckpointFile | None, checkpoint_number: int | None) -> bool

Restore 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 – True when the store was restored.

Source

tester_totals ​

python
tester_totals() -> AgentEpisodeTotalsState

Capture the tester's episode totals for checkpointing.

Returns:

  • AgentEpisodeTotalsState – The tester's episode totals, or all zeros when no tester is configured.

Source

trajectory_store_checkpoint_files ​

python
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, or None when 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.

Source