Configuring an RL Agent
In the previous tutorial, we saw how to train an RL agent to solve the cartpole balancing task using the Stable-Baselines3 library. In this tutorial, we will see how to configure the training process to use different RL libraries and different training algorithms.
In the directory scripts/reinforcement_learning, you will find the scripts for
different RL libraries. These are organized into subdirectories named after the library name.
Each subdirectory contains the training and playing scripts for the library.
To configure a learning library with a specific task, you need to create a configuration file
for the learning agent. This configuration file is used to create an instance of the learning agent
and is used to configure the training process. Similar to the environment registration shown in
the Registering an Environment tutorial, you can register the learning agent with the
gymnasium.register method.
The Code
As an example, we will look at the configuration included for the task Isaac-Cartpole
in the isaaclab_tasks package. This is the same task that we used in the
Training with an RL Agent tutorial.
The Code Explained
Under the attribute kwargs, we can see the configuration for the different learning libraries.
The key is the name of the library and the value is the path to the configuration instance.
This configuration instance can be a string, a class, or an instance of the class.
For example, the value of the key "rl_games_cfg_entry_point" is a string that points to the
configuration YAML file for the RL-Games library. Meanwhile, the value of the key
"rsl_rl_cfg_entry_point" points to the configuration class for the RSL-RL library.
The pattern used for specifying an agent configuration class follows closely to that used for specifying the environment configuration entry point. This means that while the following are equivalent:
The first code block is the preferred way to specify the configuration entry point. The second code block is equivalent to the first one, but it leads to import of the configuration class which slows down the import time. This is why we recommend using strings for the configuration entry point.
The reinforcement learning entrypoints are configured by default to read the
<library_name>_cfg_entry_point from the kwargs dictionary to retrieve the configuration instance.
For instance, the following code block shows how the Stable-Baselines3 training implementation reads the configuration instance:
The argument --rl_library selects the reinforcement learning library. The --agent
argument selects the library-specific configuration entry point from the kwargs
dictionary, so you can manually specify alternate configuration instances.
The Code Execution
Since for the cartpole balancing task, RSL-RL library offers two configuration instances,
we can use the --agent argument to specify the configuration instance to use.
- Training with the standard PPO configuration:
uv (Recommended)
isaaclab.sh / isaaclab.bat
- Training with the PPO configuration with symmetry augmentation:
uv (Recommended)
isaaclab.sh / isaaclab.bat
The --run_name argument is used to specify the name of the run. This is used to
create a directory for the run in the logs/rsl_rl/cartpole directory.
When continuing RSL-RL training with a different policy learning rate, use
--checkpoint /path/to/model.pt --no-resume_optimizer_state. This restores model weights and the
iteration count while keeping the newly configured policy optimizer and its learning rate.
By default, --resume_optimizer_state restores the checkpoint’s optimizer state as usual. RND models and their
separate optimizer retain their checkpoint state.
For distillation, this option requires a student checkpoint containing both student and teacher;
omit it when initializing a new student from a PPO teacher checkpoint.
Installed downstream tasks are discovered through the isaaclab.tasks entry-point group.
Custom launchers can call isaaclab.cli.load_external_tasks() before looking up task IDs,
as the built-in CLI and direct RL workers do.