nemo_rl.environments.gym_checkpoint_adapter#
Thin NeMo RL adapter over one NeMo Gym v2 checkpoint coordinator.
Module Contents#
Classes#
Stable identity and filesystem namespace for one logical Gym actor. |
|
Actor-local Gym state selected by one checkpoint commit. |
|
Serializable result of preparing one actor’s Gym deployment. |
|
Delegate checkpoint operations for exactly one Gym deployment to Gym. |
Functions#
Turn Gym’s unpicklable |
Data#
API#
- nemo_rl.environments.gym_checkpoint_adapter.GymCheckpointEpisode#
None
- class nemo_rl.environments.gym_checkpoint_adapter.GymCheckpointInstance[source]#
Stable identity and filesystem namespace for one logical Gym actor.
- shard_name: str#
None
- replica_index: int#
None
- property instance_id: str#
- class nemo_rl.environments.gym_checkpoint_adapter.GymCheckpointCommitSummary[source]#
Actor-local Gym state selected by one checkpoint commit.
- exported_episodes: tuple[nemo_rl.environments.gym_checkpoint_adapter.GymCheckpointEpisode, ...]#
None
- staging_keys: tuple[str, ...]#
None
- participants: tuple[str, ...]#
None
- staging_keys_by_episode: collections.abc.Mapping[nemo_rl.environments.gym_checkpoint_adapter.GymCheckpointEpisode, tuple[str, ...]]#
‘field(…)’
- unowned_live_episodes: tuple[nemo_rl.environments.gym_checkpoint_adapter.GymCheckpointEpisode, ...]#
()
- class nemo_rl.environments.gym_checkpoint_adapter.GymCheckpointPrepareSummary[source]#
Serializable result of preparing one actor’s Gym deployment.
restartsare in-flight episodes some participant cannot capture: Gym refuses a commit that names one, and they start over after a crash.- prepared: bool#
None
- blockers: dict[str, tuple[str, ...]]#
None
- restarts: tuple[nemo_rl.environments.gym_checkpoint_adapter.GymCheckpointEpisode, ...]#
None
- classmethod from_result(
- result: nemo_gym._checkpoint.coordination.PrepareResult,
Bases:
RuntimeErrorGym’s control plane could not complete one checkpoint control call.
Raised in place of Gym’s
CoordinationError, which cannot be pickled and so reaches the driver as an untypedUnserializableException. The participants’ failures arrive as text, so this says only that the call failed, not why; nothing RL holds changed, and a later checkpoint may succeed.Initialization
Initialize self. See help(type(self)) for accurate signature.
Turn Gym’s unpicklable
CoordinationErrorintoGymCheckpointUnavailable.Every Gym coordination call goes through this, so its failure reaches the driver typed, with Gym’s message, instead of as
UnserializableException.
- class nemo_rl.environments.gym_checkpoint_adapter.GymCheckpointAdapter(
- *,
- instance: nemo_rl.environments.gym_checkpoint_adapter.GymCheckpointInstance,
- client: nemo_gym.server_utils.ServerClient,
- auth_token: str,
Delegate checkpoint operations for exactly one Gym deployment to Gym.
Initialization
- async restart_only_servers() list[str][source]#
Return the participants whose rollouts start over after a crash.
Gym reports their in-flight rollouts as restarts at every checkpoint, so turn-level recovery quietly becomes restart-from-task for them. Each participant declares this as its checkpoint
mode, which discovery already returned.
- async prepare(
- checkpoint_id: str,
- *,
- deadline_ts: float,
- static _episode_ids(
- episodes: collections.abc.Iterable[nemo_rl.environments.gym_checkpoint_adapter.GymCheckpointEpisode],
Convert the RL wire identity to Gym’s validated API model.
- _commit_summary(
- checkpoint_id: str,
- episode_ids: list[Any],
- replies: dict[str, dict[str, Any]],
Convert participant replies into an actor-local ownership summary.
- async retire(
- checkpoint_id: str,
- episodes: collections.abc.Iterable[nemo_rl.environments.gym_checkpoint_adapter.GymCheckpointEpisode],
- *,
- deadline_ts: float,
- async forget(
- checkpoint_id: str,
- rollout_ids: collections.abc.Iterable[str],
- *,
- deadline_ts: float,
- async commit(
- checkpoint_id: str,
- checkpoint_root: str | pathlib.Path,
- episodes: collections.abc.Iterable[nemo_rl.environments.gym_checkpoint_adapter.GymCheckpointEpisode],
- *,
- deadline_ts: float,
- async restore(
- checkpoint_id: str,
- checkpoint_root: str | pathlib.Path,
- episodes: collections.abc.Iterable[nemo_rl.environments.gym_checkpoint_adapter.GymCheckpointEpisode],
- *,
- participants: collections.abc.Iterable[str],
- source_checkpoint_id: str,
- deadline_ts: float,
Restore
episodesinto this deployment.participantsare the server names that committed the checkpoint. Gym restores only live participants, so one missing here would have its state silently dropped; Gym itself fails a live participant that has no saved state.