Runner

Utility that configures and instantiates skrl’s components to run training/evaluation workflows in a few lines of code.



Usage

Hint

The Runner classes encapsulates, and greatly simplifies, the definitions and instantiations needed to execute RL tasks. However, such simplification hides and makes difficult the modification and readability of the code (models, agents, etc.).

For more control and readability over the RL system setup refer to the Examples section’s training scripts (recommended!).


from skrl.utils.runner.torch import Runner
from skrl.envs.wrappers.torch import wrap_env

# load and wrap some environment
env = ...
env = wrap_env(env)

# load the experiment config and instantiate the runner
cfg = Runner.load_cfg_from_yaml("path/to/cfg.yaml")
runner = Runner(env, cfg)

# load a checkpoint to continue training or for evaluation (optional)
runner.agent.load("path/to/checkpoints/agent.pt")

# run the training
runner.run("train")  # or "eval" for evaluation

API


PyTorch

Runner

Experiment runner.

class skrl.utils.runner.torch.Runner(env: Wrapper | MultiAgentEnvWrapper, cfg: dict[str, Any], *, verbose: bool = False)[source]

Bases: object

Experiment runner.

Configure and instantiate skrl components to execute training/evaluation workflows in a few lines of code.

Parameters:
  • env – Environment to train on.

  • cfg – Runner configuration.

  • verbose – Whether to print extra information about the setup.

Methods:

load_cfg_from_yaml(path)

Load a runner configuration from a yaml file.

run([mode])

Run the training/evaluation.

Attributes:

agent

Agent instance.

trainer

Trainer instance.

static load_cfg_from_yaml(path: str) dict[source]

Load a runner configuration from a yaml file.

Parameters:

path – File path.

Returns:

Loaded configuration, or an empty dict if an error has occurred.

run(mode: Literal['train', 'eval'] = 'train') None[source]

Run the training/evaluation.

Parameters:

mode – Running mode: "train" for training or "eval" for evaluation.

Raises:

ValueError – The specified running mode is not valid.

property agent: Agent[source]

Agent instance.

property trainer: Trainer[source]

Trainer instance.


JAX

Runner

Experiment runner.

class skrl.utils.runner.jax.Runner(env: Wrapper | MultiAgentEnvWrapper, cfg: dict[str, Any], *, verbose: bool = False)[source]

Bases: object

Experiment runner.

Configure and instantiate skrl components to execute training/evaluation workflows in a few lines of code.

Parameters:
  • env – Environment to train on.

  • cfg – Runner configuration.

  • verbose – Whether to print extra information about the setup.

Methods:

load_cfg_from_yaml(path)

Load a runner configuration from a yaml file.

run([mode])

Run the training/evaluation.

Attributes:

agent

Agent instance.

trainer

Trainer instance.

static load_cfg_from_yaml(path: str) dict[source]

Load a runner configuration from a yaml file.

Parameters:

path – File path.

Returns:

Loaded configuration, or an empty dict if an error has occurred.

run(mode: Literal['train', 'eval'] = 'train') None[source]

Run the training/evaluation.

Parameters:

mode – Running mode: "train" for training or "eval" for evaluation.

Raises:

ValueError – The specified running mode is not valid.

property agent: Agent[source]

Agent instance.

property trainer: Trainer[source]

Trainer instance.


Warp

Runner

Experiment runner.