From 0ffd84f4193411fd7fd4db62ed9742ab194e9a5c Mon Sep 17 00:00:00 2001 From: ClemensSchwarke Date: Thu, 30 Jul 2026 15:51:35 +0200 Subject: [PATCH 1/2] fix template for new rsl_rl --- tools/template/cli.py | 19 ++++++----- tools/template/common.py | 2 +- .../templates/agents/rsl_rl_distillation_cfg | 34 +++++++++++++++++++ .../template/templates/agents/rsl_rl_ppo_cfg | 1 + tools/template/templates/tasks/__init__task | 3 +- 5 files changed, 48 insertions(+), 11 deletions(-) create mode 100644 tools/template/templates/agents/rsl_rl_distillation_cfg diff --git a/tools/template/cli.py b/tools/template/cli.py index d922025e070f..eea46ec0388a 100644 --- a/tools/template/cli.py +++ b/tools/template/cli.py @@ -7,6 +7,7 @@ import importlib import os from collections.abc import Callable +from textwrap import fill import rich.console import rich.table @@ -213,21 +214,21 @@ def main() -> None: # - show supported RL libraries and features rl_library_table = rich.table.Table(title="Supported RL libraries") rl_library_table.add_column("RL/training feature", no_wrap=True) - rl_library_table.add_column("rl_games") - rl_library_table.add_column("rsl_rl") - rl_library_table.add_column("skrl") - rl_library_table.add_column("sb3") + rl_library_table.add_column("rl_games", overflow="fold") + rl_library_table.add_column("rsl_rl", overflow="fold") + rl_library_table.add_column("skrl", overflow="fold") + rl_library_table.add_column("sb3", overflow="fold") rl_library_table.add_row("ML frameworks", "PyTorch", "PyTorch", "PyTorch, JAX", "PyTorch") rl_library_table.add_row("Relative performance", "~1X", "~1X", "~1X", "~0.03X") rl_library_table.add_row( "Algorithms", - ", ".join(algorithms_per_rl_library.get("rl_games", [])), - ", ".join(algorithms_per_rl_library.get("rsl_rl", [])), - ", ".join(algorithms_per_rl_library.get("skrl", [])), - ", ".join(algorithms_per_rl_library.get("sb3", [])), + fill(", ".join(algorithms_per_rl_library.get("rl_games", [])), width=12, break_long_words=False), + fill(", ".join(algorithms_per_rl_library.get("rsl_rl", [])), width=12, break_long_words=False), + fill(", ".join(algorithms_per_rl_library.get("skrl", [])), width=12, break_long_words=False), + fill(", ".join(algorithms_per_rl_library.get("sb3", [])), width=12, break_long_words=False), ) rl_library_table.add_row("Multi-agent support", State.No, State.No, State.Yes, State.No) - rl_library_table.add_row("Distributed training", State.Yes, State.No, State.Yes, State.No) + rl_library_table.add_row("Distributed training", State.Yes, State.Yes, State.Yes, State.No) rl_library_table.add_row("Vectorized training", State.Yes, State.Yes, State.Yes, State.No) rl_library_table.add_row("Fundamental/composite spaces", State.No, State.No, State.Yes, State.No) cli_handler.output_table(rl_library_table) diff --git a/tools/template/common.py b/tools/template/common.py index 08d2732a1911..b6f375b130b6 100644 --- a/tools/template/common.py +++ b/tools/template/common.py @@ -11,5 +11,5 @@ TEMPLATE_DIR = os.path.join(ROOT_DIR, "tools", "template", "templates") # RL algorithms -SINGLE_AGENT_ALGORITHMS = ["AMP", "PPO"] +SINGLE_AGENT_ALGORITHMS = ["AMP", "PPO", "DISTILLATION"] MULTI_AGENT_ALGORITHMS = ["IPPO", "MAPPO"] diff --git a/tools/template/templates/agents/rsl_rl_distillation_cfg b/tools/template/templates/agents/rsl_rl_distillation_cfg new file mode 100644 index 000000000000..0cc44a9b2d1a --- /dev/null +++ b/tools/template/templates/agents/rsl_rl_distillation_cfg @@ -0,0 +1,34 @@ +# Copyright (c) 2022-2026, The Isaac Lab Project Developers (https://github.com/isaac-sim/IsaacLab/blob/main/CONTRIBUTORS.md). +# All rights reserved. +# +# SPDX-License-Identifier: BSD-3-Clause + +from isaaclab.utils.configclass import configclass + +from isaaclab_rl.rsl_rl import RslRlDistillationAlgorithmCfg, RslRlDistillationRunnerCfg, RslRlMLPModelCfg + + +@configclass +class DistillationRunnerCfg(RslRlDistillationRunnerCfg): + num_steps_per_env = 60 + max_iterations = 150 + save_interval = 50 + experiment_name = "cartpole_direct" + obs_groups = {"student": ["policy"], "teacher": ["policy"]} + student = RslRlMLPModelCfg( + hidden_dims=[32, 32], + activation="elu", + obs_normalization=False, + distribution_cfg=RslRlMLPModelCfg.GaussianDistributionCfg(init_std=1.0), + ) + teacher = RslRlMLPModelCfg( + hidden_dims=[32, 32], + activation="elu", + obs_normalization=False, + distribution_cfg=RslRlMLPModelCfg.GaussianDistributionCfg(init_std=0.0), + ) + algorithm = RslRlDistillationAlgorithmCfg( + num_learning_epochs=2, + learning_rate=1.0e-3, + gradient_length=15, + ) diff --git a/tools/template/templates/agents/rsl_rl_ppo_cfg b/tools/template/templates/agents/rsl_rl_ppo_cfg index 4e7d73970784..39b88fff9572 100644 --- a/tools/template/templates/agents/rsl_rl_ppo_cfg +++ b/tools/template/templates/agents/rsl_rl_ppo_cfg @@ -14,6 +14,7 @@ class PPORunnerCfg(RslRlOnPolicyRunnerCfg): max_iterations = 150 save_interval = 50 experiment_name = "cartpole_direct" + obs_groups = {"actor": ["policy"], "critic": ["policy"]} actor = RslRlMLPModelCfg( hidden_dims=[32, 32], activation="elu", diff --git a/tools/template/templates/tasks/__init__task b/tools/template/templates/tasks/__init__task index e8890743df1d..0161c5f4be13 100644 --- a/tools/template/templates/tasks/__init__task +++ b/tools/template/templates/tasks/__init__task @@ -27,7 +27,8 @@ gym.register( {% for algorithm in rl_library.algorithms %} {# configuration file #} {% if rl_library.name == "rsl_rl" %} - {% set agent_config = "." ~ rl_library.name ~ "_" ~ algorithm ~ "_cfg:" ~ algorithm|upper ~ "RunnerCfg" %} + {% set runner_prefix = {"distillation": "Distillation"}.get(algorithm, algorithm|upper) %} + {% set agent_config = "." ~ rl_library.name ~ "_" ~ algorithm ~ "_cfg:" ~ runner_prefix ~ "RunnerCfg" %} {% else %} {% set agent_config = ":" ~ rl_library.name ~ "_" ~ algorithm ~ "_cfg.yaml" %} {% endif %} From 69cacbe550bc53f4e17df2479a9c13c1c0edf35a Mon Sep 17 00:00:00 2001 From: Kelly Guo Date: Sun, 2 Aug 2026 17:11:30 -0700 Subject: [PATCH 2/2] Update RSL-RL template generator tests Cover Distillation in algorithm discovery, generated config files, and registry entry points so the tests match the newly supported RSL-RL workflow. --- .../changelog.d/fix-rsl-rl-template-tests.skip | 1 + source/isaaclab_rl/test/test_template_generator.py | 10 +++++++--- 2 files changed, 8 insertions(+), 3 deletions(-) create mode 100644 source/isaaclab_rl/changelog.d/fix-rsl-rl-template-tests.skip diff --git a/source/isaaclab_rl/changelog.d/fix-rsl-rl-template-tests.skip b/source/isaaclab_rl/changelog.d/fix-rsl-rl-template-tests.skip new file mode 100644 index 000000000000..8630019053a5 --- /dev/null +++ b/source/isaaclab_rl/changelog.d/fix-rsl-rl-template-tests.skip @@ -0,0 +1 @@ +Internal: updated template generator tests for RSL-RL Distillation support. diff --git a/source/isaaclab_rl/test/test_template_generator.py b/source/isaaclab_rl/test/test_template_generator.py index b19874432599..f95dc64d0c32 100644 --- a/source/isaaclab_rl/test/test_template_generator.py +++ b/source/isaaclab_rl/test/test_template_generator.py @@ -25,7 +25,7 @@ _SINGLE_AGENT_RL_LIBRARIES = [ {"name": "rl_games", "algorithms": ["ppo"]}, - {"name": "rsl_rl", "algorithms": ["ppo"]}, + {"name": "rsl_rl", "algorithms": ["distillation", "ppo"]}, {"name": "skrl", "algorithms": ["amp", "ppo"]}, {"name": "sb3", "algorithms": ["ppo"]}, ] @@ -106,7 +106,7 @@ def _unregister(task_id: str) -> None: False, { "rl_games": ["PPO"], - "rsl_rl": ["PPO"], + "rsl_rl": ["DISTILLATION", "PPO"], "skrl": ["AMP", "PPO"], "sb3": ["PPO"], }, @@ -126,7 +126,7 @@ def _unregister(task_id: str) -> None: True, { "rl_games": ["PPO"], - "rsl_rl": ["PPO"], + "rsl_rl": ["DISTILLATION", "PPO"], "skrl": ["AMP", "IPPO", "MAPPO", "PPO"], "sb3": ["PPO"], }, @@ -181,6 +181,10 @@ def test_generator_registers_single_agent_rl_config_entry_points_for_all_librari assert spec.kwargs["env_cfg_entry_point"] == f"{module_name}.{task_folder}_env_cfg:{task_class}EnvCfg" assert spec.kwargs["rl_games_cfg_entry_point"] == f"{agents_module}:rl_games_ppo_cfg.yaml" + assert ( + spec.kwargs["rsl_rl_distillation_cfg_entry_point"] + == f"{agents_module}.rsl_rl_distillation_cfg:DistillationRunnerCfg" + ) assert spec.kwargs["rsl_rl_cfg_entry_point"] == f"{agents_module}.rsl_rl_ppo_cfg:PPORunnerCfg" assert spec.kwargs["skrl_amp_cfg_entry_point"] == f"{agents_module}:skrl_amp_cfg.yaml" assert spec.kwargs["skrl_cfg_entry_point"] == f"{agents_module}:skrl_ppo_cfg.yaml"