unilab.training.experiment.patch_rsl_rl_resume_state

unilab.training.experiment.patch_rsl_rl_resume_state()[source]

Persist and restore UniLab progress through rsl-rl checkpoints.

Without this patch, rsl-rl’s Logger.__init__ writes tot_time = 0 and tot_timesteps = 0 and OnPolicyRunner.load never refreshes them, so the Train/mean_reward/time and Train/mean_episode_length/time TensorBoard scalars (which use int(self.tot_time) as their step) restart from 0 on every resumed run and visually overlap the original segment. See issue #441.

The patch wraps OnPolicyRunner.save / OnPolicyRunner.load to round-trip plain progress in the saved dict: :rtype: None

  • unilab_logger_state: Logger.tot_time / tot_timesteps (required);

  • unilab_env_training_state: the wrapped TorchEnv’s versioned training state, written only when the environment publishes one.

Loading fails closed (issue #2416). A checkpoint must carry a valid unilab_logger_state; pre-patch rsl-rl checkpoints without it are rejected with a message describing the minimum supported format instead of silently restarting progress from 0. When the active environment publishes training state, the checkpoint must also carry its versioned unilab_env_training_state; environments without exportable state neither write nor require the key, and no placeholder value is fabricated.

Checkpoints are immutable load inputs. The loader never repairs, rewrites, upgrades, or migrates a checkpoint file. Environment state is plain versioned JSON data; no Torch tensor, backend, environment, or manager object is serialized through this path.