Note: The next release will be 2.0.0 (unreleased). It migrates fully from gym to gymnasium and requires Python >= 3.11 (CI runs 3.11 and 3.12). EnvPool support has been restored: envpool >= 1.2.6 on Python 3.12+, with an envpool 1.2.5 fallback on Python 3.11 (NumPy 2.x, MuJoCo 3.x compatible; MyoSuite target randomization requires 1.2.6 and therefore Python >= 3.12).




WujiHand in-hand cube reorientation (wuji-mjlab): on the unmodified task, rl_games trains to 19.1–20.1 goal reaches per episode (three seeds) vs 16.9 for the reference rsl-rl fork at the same training budget, reaches the reference's final score in 1.3–1.4 h instead of 2.1 h, and scales to 21.1 on 2 GPUs (reference score in 1.0 h). Full comparison, the training recipe and the stability notes in docs/MJLAB.md.

SAC matches or exceeds published reference scores on MuJoCo continuous control (envpool, 1M frames, 3 seeds). Full table, plots and reproduction in docs/SAC_BENCHMARKS.md.
| Task | rl_games SAC | Reference SAC (1M) |
|---|---|---|
| HalfCheetah | 11,140 ± 665 | 10,469 ± 1,123 |
| Ant | 4,706 ± 1,379 | 4,623 ± 984 |
| Humanoid | 5,195 ± 198 | 5,044 ± 390 |
Humanoid keeps improving well past the standard 1M-frame budget — a single run extended to 5M frames reaches 7,066, about 40% above the reference mean.

Implemented in Tensorflow 1.x (was removed in this version):
Explore RL Games quick and easily in colab notebooks:
For maximum training performance, PyTorch >= 2.2 with CUDA is recommended.
pip install rl-games
Or clone the repo and install the latest version from source:
pip install -e .
With optional extras (e.g. Atari, Mujoco, EnvPool):
pip install -e ".[atari,mujoco,envpool]"
Available extras: atari, mujoco, envpool. (pufferlib is no longer an
extra: its current releases pin numpy<2 / old gymnasium, conflicting with this
project's floors — pip install pufferlib --no-deps; the extra returns with
pufferlib 4.0.)
For high-throughput vectorized MuJoCo / Atari / DM Control training, install the envpool extra and see docs/ENVPOOL.md.
uv is a fast Python package manager. To create a virtual environment and install rl_games:
# 3.12+ resolves envpool 1.2.6; a 3.11 venv falls back to envpool 1.2.5
uv venv --python 3.12
source .venv/bin/activate
uv pip install -e ".[mujoco,envpool]"
If you use rl-games in your research please use the following citation:
@misc{rl-games2021,
title = {rl-games: A High-performance Framework for Reinforcement Learning},
author = {Makoviichuk, Denys and Makoviychuk, Viktor},
month = {May},
year = {2021},
publisher = {GitHub},
journal = {GitHub repository},
howpublished = {\url{https://github.com/Denys88/rl_games}},
}
uv venv --python 3.11 # project floor (Isaac Lab); .[envpool] resolves envpool 1.2.5 here
source .venv/bin/activate
uv pip install -e ".[atari,mujoco]"
NVIDIA Isaac Gym (legacy)
Isaac Gym Preview is end-of-life and not supported by current rl_games
(it requires Python <= 3.8). To run legacy Isaac Gym / IsaacGymEnvs
projects use the last supporting release, rl-games==1.6.5, and its
documentation: https://github.com/Denys88/rl_games/tree/v1.6.5 — see
docs/ISAAC_GYM.md. For current GPU-accelerated
training see MJLab (MuJoCo Warp) and Isaac Lab.
Other
Atari Pong
python runner.py --train --file rl_games/configs/atari/ppo_pong.yaml
python runner.py --play --file rl_games/configs/atari/ppo_pong.yaml --checkpoint nn/PongNoFrameskip.pth
rl_games support experiment tracking with Weights and Biases.
python runner.py --train --file rl_games/configs/atari/ppo_breakout_torch.yaml --track
WANDB_API_KEY=xxxx python runner.py --train --file rl_games/configs/atari/ppo_breakout_torch.yaml --track
python runner.py --train --file rl_games/configs/atari/ppo_breakout_torch.yaml --wandb-project-name rl-games-special-test --track
python runner.py --train --file rl_games/configs/atari/ppo_breakout_torch.yaml --wandb-project-name rl-games-special-test -wandb-entity openrlbenchmark --track
rl_games includes the DexPBT-lineage PBT observers
(previously maintained downstream in IsaacGymEnvs and Isaac Lab), usable with any backend
via rl_games.common.pbt — see docs/PBT.md.
We use torchrun to orchestrate any multi-gpu runs.
torchrun --standalone --nnodes=1 --nproc_per_node=2 runner.py --train --file rl_games/configs/ppo_cartpole.yaml
When Triton is installed, rl_games automatically uses custom Triton kernels for performance-critical operations like GAE (Generalized Advantage Estimation). This replaces the Python for-loop with a single fused GPU kernel.
Triton is enabled by default. To disable:
RLG_NO_TRITON=1 python runner.py --train --file rl_games/configs/mujoco/ant.yaml
Run the benchmark to see speedups on your hardware:
python benchmarks/bench_triton_gae.py
| Field | Example Value | Default | Description |
|---|---|---|---|
| seed | 8 | None | Seed for pytorch, numpy etc. |
| algo | Algorithm block. | ||
| name | a2c_continuous | None | Algorithm name. Possible values are: sac, a2c_discrete, a2c_continuous |
| model | Model block. | ||
| name | continuous_a2c_logstd | None | Possible values: continuous_a2c_logstd (Gaussian, log-std parametrization), continuous_a2c_tanh, discrete_a2c, multi_discrete_a2c, soft_actor_critic |
| network | Network description. | ||
| name | actor_critic | Possible values: actor_critic or soft_actor_critic. | |
| separate | False | Whether use or not separate network with same same architecture for critic. In almost all cases if you normalize value it is better to have it False | |
| space | Network space | ||
| continuous | continuous or discrete | ||
| mu_activation | None | Activation for mu. In almost all cases None works the best, but we may try tanh. | |
| sigma_activation | None | Activation for sigma. Will be threated as log(sigma) or sigma depending on model. | |
| mu_init | Initializer for mu. | ||
| name | default | ||
| sigma_init | Initializer for sigma. if you are using logstd model good value is 0. | ||
| name | const_initializer | ||
| val | 0 | ||
| fixed_sigma | True | If true then sigma vector doesn't depend on input. | |
| cnn | Convolution block. | ||
| type | conv2d | Type: right now two types supported: conv2d or conv1d | |
| activation | elu | activation between conv layers. | |
| initializer | Initialier. I took some names from the tensorflow. | ||
| name | glorot_normal_initializer | Initializer name | |
| gain | 1.4142 | Additional parameter. | |
| convs | Convolution layers. Same parameters as we have in torch. | ||
| filters | 32 | Number of filters. | |
| kernel_size | 8 | Kernel size. | |
| strides | 4 | Strides | |
| padding | 0 | Padding | |
| filters | 64 | Next convolution layer info. | |
| kernel_size | 4 | ||
| strides | 2 | ||
| padding | 0 | ||
| filters | 64 | ||
| kernel_size | 3 | ||
| strides | 1 | ||
| padding | 0 | ||
| mlp | MLP Block. Convolution is supported too. See other config examples. | ||
| units | Array of sizes of the MLP layers, for example: [512, 256, 128] | ||
| d2rl | False | Use d2rl architecture from https://arxiv.org/abs/2010.09163. | |
| activation | elu | Activations between dense layers. | |
| initializer | Initializer. | ||
| name | default | Initializer name. | |
| rnn | RNN block. | ||
| name | lstm | RNN Layer name. lstm and gru are supported. | |
| units | 256 | Number of units. | |
| layers | 1 | Number of layers | |
| before_mlp | False | False | Apply rnn before mlp block or not. |
| config | RL Config block. | ||
| reward_shaper | Reward Shaper. Can apply simple transformations. | ||
| min_val | -1 | You can apply min_val, max_val, scale and shift. | |
| scale_value | 0.1 | 1 | |
| normalize_advantage | True | True | Normalize Advantage. |
| gamma | 0.995 | Reward Discount | |
| tau | 0.95 | Lambda for GAE. Called tau by mistake long time ago because lambda is keyword in python :( | |
| learning_rate | 3e-4 | Learning rate. | |
| name | walker | Name which will be used in tensorboard. | |
| save_best_after | 10 | How many epochs to wait before start saving checkpoint with best score. | |
| score_to_win | 300 | If score is >=value then this value training will stop. | |
| grad_norm | 1.5 | Grad norm. Applied if truncate_grads is True. Good value is in (1.0, 10.0) | |
| entropy_coef | 0 | Entropy coefficient. Good value for continuous space is 0. For discrete is 0.02 | |
| truncate_grads | True | Apply truncate grads or not. It stabilizes training. | |
| env_name | BipedalWalker-v3 | Envinronment name. | |
| e_clip | 0.2 | clip parameter for ppo loss. | |
| clip_value | False | Apply clip to the value loss. If you are using normalize_value you don't need it. | |
| num_actors | 16 | Number of running actors/environments. | |
| horizon_length | 4096 | Horizon length per each actor. Total number of steps will be num_actors*horizon_length * num_agents (if env is not MA num_agents==1). | |
| minibatch_size | 8192 | Minibatch size. Total number number of steps must be divisible by minibatch size. | |
| minibatch_size_per_env | 8 | Minibatch size per env. If specified will overwrite total number number the default minibatch size with minibatch_size_per_env * nume_envs value. | |
| mini_epochs | 4 | Number of miniepochs. Good value is in [1,10] | |
| critic_coef | 2 | Critic coef. by default critic_loss = critic_coef * 1/2 * MSE. | |
| lr_schedule | adaptive | None | Scheduler type. Could be None, linear or adaptive. Adaptive is the best for continuous control tasks. Learning rate is changed changed every miniepoch |
| kl_threshold | 0.008 | KL threshould for adaptive schedule. if KL < kl_threshold/2 lr = lr * 1.5 and opposite. | |
| normalize_input | True | Apply running mean std for input. | |
| bounds_loss_coef | 0.0 | Coefficient to the auxiary loss for continuous space. | |
| max_epochs | 10000 | Maximum number of epochs to run. | |
| max_frames | 5000000 | Maximum number of frames (env steps) to run. | |
| normalize_value | True | Use value running mean std normalization. | |
| use_diagnostics | True | Adds more information into the tensorboard. | |
| value_bootstrap | True | Bootstraping value when episode is finished. Very useful for different locomotion envs. | |
| bound_loss_type | regularisation | None | Adds aux loss for continuous case. 'regularisation' is the sum of sqaured actions. 'bound' is the sum of actions higher than 1.1. |
| bounds_loss_coef | 0.0005 | 0 | Regularisation coefficient |
| use_smooth_clamp | False | Use smooth clamp instead of regular for cliping | |
| zero_rnn_on_done | False | True | If False RNN internal state is not reset (set to 0) when an environment is rest. Could improve training in some cases, for example when domain randomization is on |
| player | Player configuration block. | ||
| render | True | False | Render environment |
| deterministic | True | True | Use deterministic policy ( argmax or mu) or stochastic. |
| use_vecenv | True | auto | Use vecenv to create environment for player. Auto: True when the env is registered without an env_creator (envpool, pufferlib, plain gymnasium entries, config-registered vecenv_type envs); False for creator-based and unregistered names, so a subclass create_env() override runs |
| games_num | 200 | Number of games to run in the player mode. | |
| env_config | Env configuration block. It goes directly to the environment. This example was take for my atari wrapper. | ||
| skip | 4 | Number of frames to skip | |
| name | BreakoutNoFrameskip-v4 | The exact name of an (atari) gym env. An example, depends on the training env this parameters can be different. | |
| evaluation | True | False | Enables the evaluation feature for inferencing while training. |
| update_checkpoint_freq | 100 | 100 | Frequency in number of steps to look for new checkpoints. |
| dir_to_monitor | Directory to search for checkpoints in during evaluation. |
simple test network
This network takes dictionary observation.
To register it you can add code in your init.py
from rl_games.envs.test_network import TestNetBuilder
from rl_games.algos_torch import model_builder
model_builder.register_network('testnet', TestNetBuilder)
simple test environment example environment
Additional environment supported properties and functions
| Field | Default Value | Description |
|---|---|---|
| use_central_value | False | If true than returned obs is expected to be dict with 'obs' and 'state' |
| value_size | 1 | Shape of the returned rewards. Network wil support multihead value automatically. |
| concat_infos | False | Should default vecenv convert list of dicts to the dicts of lists. Very usefull if you want to use value_boostrapping. in this case you need to always return 'time_outs' : True or False, from the env. |
| get_number_of_agents(self) | 1 | Returns number of agents in the environment |
| has_action_mask(self) | False | Returns True if environment has invalid actions mask. |
| get_action_mask(self) | None | Returns action masks if has_action_mask is true. Good example is SMAC Env |
1.6.5
reduce-overhead for balanced compilation time and runtime performancetorch_compile parameter in yaml configs (true/false/"default"/"reduce-overhead"/"max-autotune")update_lr() method__iter__ method to PPODataset classRunningMeanStd to use population variancegamma_tensor initialization bugcast_obsray_config parameterclose() method for Ray actors1.6.1
1.6.0
zero_rnn_on_done.1.5.2
1.5.1
1.5.0
horovod in favor of torch.distributed (#171).1.4.0
1.3.2
1.3.1
1.3.0
1.2.0
1.1.4
1.1.3
clip_actions for switching off internal action clipping and rescaling1.1.0
pip install rl-gamesIn addition to the built-in score_to_win, max_epochs, and max_frames stop conditions, training can be terminated by a user-defined callback. The callback receives the algorithm instance and returns True to stop. It is checked once per epoch on rank 0 and broadcast to other ranks under multi-GPU. Works with PPO (continuous and discrete) and SAC.
The signature:
def my_stop(algo) -> bool:
# algo exposes: epoch_num, frame, last_mean_rewards, mean_rewards,
# game_rewards, game_lengths, config, ...
return algo.last_mean_rewards > 18.0 and algo.epoch_num >= 100
There are two ways to wire it in.
Build the agent yourself, set the callback, then call train():
import yaml
from rl_games.torch_runner import Runner
with open('rl_games/configs/atari/ppo_pong.yaml') as f:
cfg = yaml.safe_load(f)
runner = Runner()
runner.load(cfg)
runner.load_config(runner.default_config)
agent = runner.algo_factory.create(
runner.algo_name, base_name='run', params=runner.params
)
agent.stop_fn = lambda algo: algo.last_mean_rewards > 18.0 and algo.epoch_num >= 100
agent.train()
Runner.runPass the callable in the runtime args dict (programmatic), or reference it from YAML by import path (string).
Programmatic:
def my_stop(algo):
return algo.last_mean_rewards > 18.0 and algo.epoch_num >= 100
runner = Runner()
runner.load(cfg)
runner.run({'train': True, 'stop_fn': my_stop})
YAML — set config.stop_fn to either pkg.mod:function or pkg.mod.function:
params:
config:
stop_fn: my_project.stops:reward_plateau
The string is resolved by importlib at training start. args['stop_fn'] (programmatic) takes precedence over config['stop_fn'] (YAML) if both are set.
stop_fn must be a callable taking the algo and returning bool; an ValueError is raised at startup otherwise.
steps_num should be changed to horizon_length amd lr_threshold to kl_thresholdOverall
Maintained
Code review
PyPI
Latest release
Releases this year
315 followers · starred May 2022
11 followers · starred Dec 2024
230 followers · starred Aug 2025
10 followers · starred Aug 2025
Note: The next release will be 2.0.0 (unreleased). It migrates fully from gym to gymnasium and requires Python >= 3.11 (CI runs 3.11 and 3.12). EnvPool support has been restored: envpool >= 1.2.6 on Python 3.12+, with an envpool 1.2.5 fallback on Python 3.11 (NumPy 2.x, MuJoCo 3.x compatible; MyoSuite target randomization requires 1.2.6 and therefore Python >= 3.12).




WujiHand in-hand cube reorientation (wuji-mjlab): on the unmodified task, rl_games trains to 19.1–20.1 goal reaches per episode (three seeds) vs 16.9 for the reference rsl-rl fork at the same training budget, reaches the reference's final score in 1.3–1.4 h instead of 2.1 h, and scales to 21.1 on 2 GPUs (reference score in 1.0 h). Full comparison, the training recipe and the stability notes in docs/MJLAB.md.

SAC matches or exceeds published reference scores on MuJoCo continuous control (envpool, 1M frames, 3 seeds). Full table, plots and reproduction in docs/SAC_BENCHMARKS.md.
| Task | rl_games SAC | Reference SAC (1M) |
|---|---|---|
| HalfCheetah | 11,140 ± 665 | 10,469 ± 1,123 |
| Ant | 4,706 ± 1,379 | 4,623 ± 984 |
| Humanoid | 5,195 ± 198 | 5,044 ± 390 |
Humanoid keeps improving well past the standard 1M-frame budget — a single run extended to 5M frames reaches 7,066, about 40% above the reference mean.

Implemented in Tensorflow 1.x (was removed in this version):
Explore RL Games quick and easily in colab notebooks:
For maximum training performance, PyTorch >= 2.2 with CUDA is recommended.
pip install rl-games
Or clone the repo and install the latest version from source:
pip install -e .
With optional extras (e.g. Atari, Mujoco, EnvPool):
pip install -e ".[atari,mujoco,envpool]"
Available extras: atari, mujoco, envpool. (pufferlib is no longer an
extra: its current releases pin numpy<2 / old gymnasium, conflicting with this
project's floors — pip install pufferlib --no-deps; the extra returns with
pufferlib 4.0.)
For high-throughput vectorized MuJoCo / Atari / DM Control training, install the envpool extra and see docs/ENVPOOL.md.
uv is a fast Python package manager. To create a virtual environment and install rl_games:
# 3.12+ resolves envpool 1.2.6; a 3.11 venv falls back to envpool 1.2.5
uv venv --python 3.12
source .venv/bin/activate
uv pip install -e ".[mujoco,envpool]"
If you use rl-games in your research please use the following citation:
@misc{rl-games2021,
title = {rl-games: A High-performance Framework for Reinforcement Learning},
author = {Makoviichuk, Denys and Makoviychuk, Viktor},
month = {May},
year = {2021},
publisher = {GitHub},
journal = {GitHub repository},
howpublished = {\url{https://github.com/Denys88/rl_games}},
}
uv venv --python 3.11 # project floor (Isaac Lab); .[envpool] resolves envpool 1.2.5 here
source .venv/bin/activate
uv pip install -e ".[atari,mujoco]"
NVIDIA Isaac Gym (legacy)
Isaac Gym Preview is end-of-life and not supported by current rl_games
(it requires Python <= 3.8). To run legacy Isaac Gym / IsaacGymEnvs
projects use the last supporting release, rl-games==1.6.5, and its
documentation: https://github.com/Denys88/rl_games/tree/v1.6.5 — see
docs/ISAAC_GYM.md. For current GPU-accelerated
training see MJLab (MuJoCo Warp) and Isaac Lab.
Other
Atari Pong
python runner.py --train --file rl_games/configs/atari/ppo_pong.yaml
python runner.py --play --file rl_games/configs/atari/ppo_pong.yaml --checkpoint nn/PongNoFrameskip.pth
rl_games support experiment tracking with Weights and Biases.
python runner.py --train --file rl_games/configs/atari/ppo_breakout_torch.yaml --track
WANDB_API_KEY=xxxx python runner.py --train --file rl_games/configs/atari/ppo_breakout_torch.yaml --track
python runner.py --train --file rl_games/configs/atari/ppo_breakout_torch.yaml --wandb-project-name rl-games-special-test --track
python runner.py --train --file rl_games/configs/atari/ppo_breakout_torch.yaml --wandb-project-name rl-games-special-test -wandb-entity openrlbenchmark --track
rl_games includes the DexPBT-lineage PBT observers
(previously maintained downstream in IsaacGymEnvs and Isaac Lab), usable with any backend
via rl_games.common.pbt — see docs/PBT.md.
We use torchrun to orchestrate any multi-gpu runs.
torchrun --standalone --nnodes=1 --nproc_per_node=2 runner.py --train --file rl_games/configs/ppo_cartpole.yaml
When Triton is installed, rl_games automatically uses custom Triton kernels for performance-critical operations like GAE (Generalized Advantage Estimation). This replaces the Python for-loop with a single fused GPU kernel.
Triton is enabled by default. To disable:
RLG_NO_TRITON=1 python runner.py --train --file rl_games/configs/mujoco/ant.yaml
Run the benchmark to see speedups on your hardware:
python benchmarks/bench_triton_gae.py
| Field | Example Value | Default | Description |
|---|---|---|---|
| seed | 8 | None | Seed for pytorch, numpy etc. |
| algo | Algorithm block. | ||
| name | a2c_continuous | None | Algorithm name. Possible values are: sac, a2c_discrete, a2c_continuous |
| model | Model block. | ||
| name | continuous_a2c_logstd | None | Possible values: continuous_a2c_logstd (Gaussian, log-std parametrization), continuous_a2c_tanh, discrete_a2c, multi_discrete_a2c, soft_actor_critic |
| network | Network description. | ||
| name | actor_critic | Possible values: actor_critic or soft_actor_critic. | |
| separate | False | Whether use or not separate network with same same architecture for critic. In almost all cases if you normalize value it is better to have it False | |
| space | Network space | ||
| continuous | continuous or discrete | ||
| mu_activation | None | Activation for mu. In almost all cases None works the best, but we may try tanh. | |
| sigma_activation | None | Activation for sigma. Will be threated as log(sigma) or sigma depending on model. | |
| mu_init | Initializer for mu. | ||
| name | default | ||
| sigma_init | Initializer for sigma. if you are using logstd model good value is 0. | ||
| name | const_initializer | ||
| val | 0 | ||
| fixed_sigma | True | If true then sigma vector doesn't depend on input. | |
| cnn | Convolution block. | ||
| type | conv2d | Type: right now two types supported: conv2d or conv1d | |
| activation | elu | activation between conv layers. | |
| initializer | Initialier. I took some names from the tensorflow. | ||
| name | glorot_normal_initializer | Initializer name | |
| gain | 1.4142 | Additional parameter. | |
| convs | Convolution layers. Same parameters as we have in torch. | ||
| filters | 32 | Number of filters. | |
| kernel_size | 8 | Kernel size. | |
| strides | 4 | Strides | |
| padding | 0 | Padding | |
| filters | 64 | Next convolution layer info. | |
| kernel_size | 4 | ||
| strides | 2 | ||
| padding | 0 | ||
| filters | 64 | ||
| kernel_size | 3 | ||
| strides | 1 | ||
| padding | 0 | ||
| mlp | MLP Block. Convolution is supported too. See other config examples. | ||
| units | Array of sizes of the MLP layers, for example: [512, 256, 128] | ||
| d2rl | False | Use d2rl architecture from https://arxiv.org/abs/2010.09163. | |
| activation | elu | Activations between dense layers. | |
| initializer | Initializer. | ||
| name | default | Initializer name. | |
| rnn | RNN block. | ||
| name | lstm | RNN Layer name. lstm and gru are supported. | |
| units | 256 | Number of units. | |
| layers | 1 | Number of layers | |
| before_mlp | False | False | Apply rnn before mlp block or not. |
| config | RL Config block. | ||
| reward_shaper | Reward Shaper. Can apply simple transformations. | ||
| min_val | -1 | You can apply min_val, max_val, scale and shift. | |
| scale_value | 0.1 | 1 | |
| normalize_advantage | True | True | Normalize Advantage. |
| gamma | 0.995 | Reward Discount | |
| tau | 0.95 | Lambda for GAE. Called tau by mistake long time ago because lambda is keyword in python :( | |
| learning_rate | 3e-4 | Learning rate. | |
| name | walker | Name which will be used in tensorboard. | |
| save_best_after | 10 | How many epochs to wait before start saving checkpoint with best score. | |
| score_to_win | 300 | If score is >=value then this value training will stop. | |
| grad_norm | 1.5 | Grad norm. Applied if truncate_grads is True. Good value is in (1.0, 10.0) | |
| entropy_coef | 0 | Entropy coefficient. Good value for continuous space is 0. For discrete is 0.02 | |
| truncate_grads | True | Apply truncate grads or not. It stabilizes training. | |
| env_name | BipedalWalker-v3 | Envinronment name. | |
| e_clip | 0.2 | clip parameter for ppo loss. | |
| clip_value | False | Apply clip to the value loss. If you are using normalize_value you don't need it. | |
| num_actors | 16 | Number of running actors/environments. | |
| horizon_length | 4096 | Horizon length per each actor. Total number of steps will be num_actors*horizon_length * num_agents (if env is not MA num_agents==1). | |
| minibatch_size | 8192 | Minibatch size. Total number number of steps must be divisible by minibatch size. | |
| minibatch_size_per_env | 8 | Minibatch size per env. If specified will overwrite total number number the default minibatch size with minibatch_size_per_env * nume_envs value. | |
| mini_epochs | 4 | Number of miniepochs. Good value is in [1,10] | |
| critic_coef | 2 | Critic coef. by default critic_loss = critic_coef * 1/2 * MSE. | |
| lr_schedule | adaptive | None | Scheduler type. Could be None, linear or adaptive. Adaptive is the best for continuous control tasks. Learning rate is changed changed every miniepoch |
| kl_threshold | 0.008 | KL threshould for adaptive schedule. if KL < kl_threshold/2 lr = lr * 1.5 and opposite. | |
| normalize_input | True | Apply running mean std for input. | |
| bounds_loss_coef | 0.0 | Coefficient to the auxiary loss for continuous space. | |
| max_epochs | 10000 | Maximum number of epochs to run. | |
| max_frames | 5000000 | Maximum number of frames (env steps) to run. | |
| normalize_value | True | Use value running mean std normalization. | |
| use_diagnostics | True | Adds more information into the tensorboard. | |
| value_bootstrap | True | Bootstraping value when episode is finished. Very useful for different locomotion envs. | |
| bound_loss_type | regularisation | None | Adds aux loss for continuous case. 'regularisation' is the sum of sqaured actions. 'bound' is the sum of actions higher than 1.1. |
| bounds_loss_coef | 0.0005 | 0 | Regularisation coefficient |
| use_smooth_clamp | False | Use smooth clamp instead of regular for cliping | |
| zero_rnn_on_done | False | True | If False RNN internal state is not reset (set to 0) when an environment is rest. Could improve training in some cases, for example when domain randomization is on |
| player | Player configuration block. | ||
| render | True | False | Render environment |
| deterministic | True | True | Use deterministic policy ( argmax or mu) or stochastic. |
| use_vecenv | True | auto | Use vecenv to create environment for player. Auto: True when the env is registered without an env_creator (envpool, pufferlib, plain gymnasium entries, config-registered vecenv_type envs); False for creator-based and unregistered names, so a subclass create_env() override runs |
| games_num | 200 | Number of games to run in the player mode. | |
| env_config | Env configuration block. It goes directly to the environment. This example was take for my atari wrapper. | ||
| skip | 4 | Number of frames to skip | |
| name | BreakoutNoFrameskip-v4 | The exact name of an (atari) gym env. An example, depends on the training env this parameters can be different. | |
| evaluation | True | False | Enables the evaluation feature for inferencing while training. |
| update_checkpoint_freq | 100 | 100 | Frequency in number of steps to look for new checkpoints. |
| dir_to_monitor | Directory to search for checkpoints in during evaluation. |
simple test network
This network takes dictionary observation.
To register it you can add code in your init.py
from rl_games.envs.test_network import TestNetBuilder
from rl_games.algos_torch import model_builder
model_builder.register_network('testnet', TestNetBuilder)
simple test environment example environment
Additional environment supported properties and functions
| Field | Default Value | Description |
|---|---|---|
| use_central_value | False | If true than returned obs is expected to be dict with 'obs' and 'state' |
| value_size | 1 | Shape of the returned rewards. Network wil support multihead value automatically. |
| concat_infos | False | Should default vecenv convert list of dicts to the dicts of lists. Very usefull if you want to use value_boostrapping. in this case you need to always return 'time_outs' : True or False, from the env. |
| get_number_of_agents(self) | 1 | Returns number of agents in the environment |
| has_action_mask(self) | False | Returns True if environment has invalid actions mask. |
| get_action_mask(self) | None | Returns action masks if has_action_mask is true. Good example is SMAC Env |
1.6.5
reduce-overhead for balanced compilation time and runtime performancetorch_compile parameter in yaml configs (true/false/"default"/"reduce-overhead"/"max-autotune")update_lr() method__iter__ method to PPODataset classRunningMeanStd to use population variancegamma_tensor initialization bugcast_obsray_config parameterclose() method for Ray actors1.6.1
1.6.0
zero_rnn_on_done.1.5.2
1.5.1
1.5.0
horovod in favor of torch.distributed (#171).1.4.0
1.3.2
1.3.1
1.3.0
1.2.0
1.1.4
1.1.3
clip_actions for switching off internal action clipping and rescaling1.1.0
pip install rl-gamesIn addition to the built-in score_to_win, max_epochs, and max_frames stop conditions, training can be terminated by a user-defined callback. The callback receives the algorithm instance and returns True to stop. It is checked once per epoch on rank 0 and broadcast to other ranks under multi-GPU. Works with PPO (continuous and discrete) and SAC.
The signature:
def my_stop(algo) -> bool:
# algo exposes: epoch_num, frame, last_mean_rewards, mean_rewards,
# game_rewards, game_lengths, config, ...
return algo.last_mean_rewards > 18.0 and algo.epoch_num >= 100
There are two ways to wire it in.
Build the agent yourself, set the callback, then call train():
import yaml
from rl_games.torch_runner import Runner
with open('rl_games/configs/atari/ppo_pong.yaml') as f:
cfg = yaml.safe_load(f)
runner = Runner()
runner.load(cfg)
runner.load_config(runner.default_config)
agent = runner.algo_factory.create(
runner.algo_name, base_name='run', params=runner.params
)
agent.stop_fn = lambda algo: algo.last_mean_rewards > 18.0 and algo.epoch_num >= 100
agent.train()
Runner.runPass the callable in the runtime args dict (programmatic), or reference it from YAML by import path (string).
Programmatic:
def my_stop(algo):
return algo.last_mean_rewards > 18.0 and algo.epoch_num >= 100
runner = Runner()
runner.load(cfg)
runner.run({'train': True, 'stop_fn': my_stop})
YAML — set config.stop_fn to either pkg.mod:function or pkg.mod.function:
params:
config:
stop_fn: my_project.stops:reward_plateau
The string is resolved by importlib at training start. args['stop_fn'] (programmatic) takes precedence over config['stop_fn'] (YAML) if both are set.
stop_fn must be a callable taking the algo and returning bool; an ValueError is raised at startup otherwise.
steps_num should be changed to horizon_length amd lr_threshold to kl_thresholdOverall
Maintained
Code review
PyPI
Latest release
Releases this year
315 followers · starred May 2022
11 followers · starred Dec 2024
230 followers · starred Aug 2025
10 followers · starred Aug 2025