Repository navigation
Refactor train and play into rl subpackage - #6553
Conversation
Greptile SummaryThis PR refactors the per-library RL launcher scripts (
Confidence Score: 3/5The refactor is structurally sound for CLI use, but the new programmatic API has two concrete defects that will surface at runtime. Training backends call set_hydra_args() which replaces sys.argv with the Hydra overrides and never restores it. Play backends are already protected by a try/finally block in _run_backend, but the training path has no equivalent guard. Any caller of the new train() API that reads sys.argv afterward — or makes a second train() or play() call — will see stale data. Separately, _training_argv in api.py unconditionally appends --distributed for all backends, but SB3 registers no such argument (include_distributed=False), so train(TrainingRequest(backend='sb3', distributed=True, ...)) fails with an argparse error before training begins. source/isaaclab_rl/isaaclab_rl/entrypoints/dispatch.py (training path in _run_backend) and source/isaaclab_rl/isaaclab_rl/entrypoints/api.py (_training_argv) need the fixes before the programmatic API is exercised in production. Important Files Changed
Sequence Diagram%%{init: {'theme': 'neutral'}}%%
sequenceDiagram
participant Caller as Caller / CLI
participant API as api.py train()/play()
participant Dispatch as dispatch.py run_cli()
participant Backend as Train Backend run(argv)
participant PlayB as Play Backend (runpy)
Caller->>API: train(TrainingRequest)
API->>API: _training_argv(request) → argv[]
API->>Dispatch: run_train_cli(argv)
Dispatch->>Dispatch: _fuse_kit_args(argv)
Dispatch->>Dispatch: parse --rl_library
Dispatch->>Backend: "_run_backend(module, argv, run_as_script=False)"
Note over Backend: runner(argv) called set_hydra_args() mutates sys.argv and sys.argv NOT restored after return
Backend-->>Dispatch: return
Dispatch-->>API: return 0
API-->>Caller: return 0 (sys.argv now altered)
Caller->>API: play(PlaybackRequest)
API->>API: _playback_argv(request) → argv[]
API->>Dispatch: run_play_cli(argv)
Dispatch->>Dispatch: parse --rl_library
Dispatch->>PlayB: "_run_backend(module, argv, run_as_script=True)"
Note over PlayB: original_argv = sys.argv then sys.argv = module + argv then runpy.run_module() then finally sys.argv = original_argv
PlayB-->>Dispatch: return
Dispatch-->>Caller: return 0
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
sequenceDiagram
participant Caller as Caller / CLI
participant API as api.py train()/play()
participant Dispatch as dispatch.py run_cli()
participant Backend as Train Backend run(argv)
participant PlayB as Play Backend (runpy)
Caller->>API: train(TrainingRequest)
API->>API: _training_argv(request) → argv[]
API->>Dispatch: run_train_cli(argv)
Dispatch->>Dispatch: _fuse_kit_args(argv)
Dispatch->>Dispatch: parse --rl_library
Dispatch->>Backend: "_run_backend(module, argv, run_as_script=False)"
Note over Backend: runner(argv) called set_hydra_args() mutates sys.argv and sys.argv NOT restored after return
Backend-->>Dispatch: return
Dispatch-->>API: return 0
API-->>Caller: return 0 (sys.argv now altered)
Caller->>API: play(PlaybackRequest)
API->>API: _playback_argv(request) → argv[]
API->>Dispatch: run_play_cli(argv)
Dispatch->>Dispatch: parse --rl_library
Dispatch->>PlayB: "_run_backend(module, argv, run_as_script=True)"
Note over PlayB: original_argv = sys.argv then sys.argv = module + argv then runpy.run_module() then finally sys.argv = original_argv
PlayB-->>Dispatch: return
Dispatch-->>Caller: return 0
|
| def _run_backend(module_name: str, argv: list[str], *, run_as_script: bool) -> None: | ||
| """Run a backend module while isolating its command-line arguments.""" | ||
| if not run_as_script: | ||
| module = importlib.import_module(module_name) | ||
| runner = getattr(module, "run", None) | ||
| if not callable(runner): | ||
| raise TypeError(f"Training backend {module_name!r} does not define run(argv).") | ||
| runner(argv) | ||
| return | ||
| original_argv = sys.argv | ||
| try: | ||
| sys.argv = [module_name] + argv | ||
| runpy.run_module(module_name, run_name="__main__") | ||
| finally: | ||
| sys.argv = original_argv |
There was a problem hiding this comment.
Train backends mutate
sys.argv without restoration
Play backends get full sys.argv save/restore via the try/finally block below, but the training path (lines 88–93) calls runner(argv) with no such protection. Inside every training backend, _parse_args calls set_hydra_args(hydra_args), which executes sys.argv = [sys.argv[0]] + hydra_args and leaves that value in place when runner returns.
For the new programmatic API (train(TrainingRequest(...))), this means sys.argv is permanently altered after the call returns — replacing it with the Hydra overrides from the training request. Any code that reads sys.argv afterward (e.g. Hydra re-initialization, subsequent play() calls, downstream libraries) will see stale data. The fix is to guard the training path the same way the play path is already guarded.
AntoineRichard
left a comment
There was a problem hiding this comment.
Small comments, I would consider allowing resuming from checkpoints in the training CLI
| cfg["runner_args"]["enable_cameras_singleton"] = "--enable_cameras" | ||
| """ | ||
| assert "runner_args" in cfg, "No runner arguments specified." | ||
| cfg["runner_args"].setdefault("--rl_library", "rl_games") |
There was a problem hiding this comment.
shoud we change the default to rsl_rl?
| @@ -362,6 +362,7 @@ def __init__(self, cfg: dict): | |||
| cfg["runner_args"]["enable_cameras_singleton"] = "--enable_cameras" | |||
There was a problem hiding this comment.
Do we still need "--enable_cameras"?
| @@ -362,6 +362,7 @@ def __init__(self, cfg: dict): | |||
There was a problem hiding this comment.
Do we still need "headless"?
| @dataclass(frozen=True) | ||
| class TrainingRequest: | ||
| """Parameters shared by the unified training workflows. | ||
|
|
||
| Args: | ||
| backend: Reinforcement learning backend to run. | ||
| task: Registered Gym task identifier. | ||
| agent: Optional task agent configuration entry point. | ||
| num_envs: Number of environments to simulate. | ||
| seed: Environment and agent seed. | ||
| max_iterations: Maximum training iterations. | ||
| device: Simulation device identifier. | ||
| video: Whether to record training video. | ||
| distributed: Whether to enable distributed training. | ||
| backend_args: Backend-specific command-line arguments. | ||
| hydra_args: Hydra overrides and typed preset selectors. | ||
| """ |
There was a problem hiding this comment.
Could this also have a checkpoint? To resume a training for instance?
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com> Signed-off-by: Mustafa H <[email protected]>
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com> Signed-off-by: Mustafa H <[email protected]>
|
Thanks for the reviews! All comments addressed, and skills/AGENTS.md updated to take advantage of the new tooling |
7660de0 to
7de78a6
Compare
# Description Promotes the benchmark framework from `isaaclab.test.benchmark` to the public `isaaclab.benchmark` package. Runtime, startup, training, play, and RL backend workflows become library entrypoints with typed in-process dispatch. The transitional import and script shims were removed from this PR to keep the move reviewable and leave one implementation for each workflow. This is an intentional breaking change: callers must replace `isaaclab.test.benchmark` imports with `isaaclab.benchmark` and use `isaaclab benchmark` instead of the former runtime, startup, training, and play scripts. ## Highlights - Adds typed runtime, startup, training, and play request objects and `run_benchmark` convenience APIs. - Returns workflow-specific result types such as `BenchmarkResult[RuntimeBundle]`. - Adds in-process `isaaclab benchmark` CLI dispatch. - Moves the supported benchmark workflows and RL backend adapters into the package. - Removes the duplicate `isaaclab.test.benchmark` namespace and standalone workflow forwarding scripts. - Restores process-global Torch, SKRL, and RL Games state and closes environments safely across repeated calls. - Rejects schema finalization without an attached typed bundle instead of reporting a nonexistent output. - Carries forward #6474 validation: positive workloads, non-negative warm-up counts, one default train/play warm-up step, and `--measure_sync_step`. - Adds public API documentation, migration guidance, tests, and changelog fragments. ## Dependencies - Direct dependency: #6474. - Satisfied prerequisite: #6553, already merged, provides reusable RL train/play entrypoints. ## Breaking migration - `from isaaclab.test.benchmark ...` becomes `from isaaclab.benchmark ...`. - `scripts/benchmarks/{runtime,startup,training,play}.py` becomes `isaaclab benchmark {runtime,startup,training,play}`. - Per-library train/play scripts become the unified training/play commands with `--rl_library`. - Independent camera, loading, Hydra, and other standalone benchmarks remain unchanged. ## Type of change - New feature - Breaking API migration - Documentation update ## Validation - Focused benchmark API, CLI, parser, adapter, and early-stop suite: 265 passed, 4 simulator smoke cases deselected. - Focused public API and CLI entrypoint suite: 26 passed. - `./isaaclab.sh -f`: all applicable hooks pass. The conflict-marker hook was skipped because current `develop` contains literal `=======` headings in three third-party license files. - `tools/changelog/cli.py check develop`: passed. - Runtime/startup smoke tests now invoke `uv run isaaclab benchmark`; the local clean-`uv` bootstrap exceeded the validation window while downloading the CUDA environment, so CI remains the end-to-end CLI confirmation. ## Checklist - [x] I have read and understood the contribution guidelines - [x] I have run the pre-commit checks - [x] I have made corresponding documentation changes - [x] My changes generate no new warnings - [x] I have added tests for the public API and canonical CLI paths - [x] I have added the required changelog fragments - [x] I have documented the intentional breaking migration - [x] My name already exists in `CONTRIBUTORS.md` --------- Co-authored-by: Mustafa Haiderbhai <[email protected]>
# Description The reusable reinforcement learning entrypoints introduced in #6553 restore `sys.argv` after in-process calls, but backend-specific global settings can still leak into the caller. This PR scopes those mutations to each invocation: - RSL-RL training parses arguments before temporarily enabling its Torch backend flags and restores all four flags on success or failure. - SKRL training restores `skrl.config.jax.backend`, including deleting it when the attribute did not exist before the call. - SKRL playback scopes the same state inside `main()`, covering both unified dispatch and direct imported calls. - Adds failure-path regressions for rejected RSL-RL requests and exceptional SKRL train/play calls. ## Relationship - Focused follow-up to #6553. - Independent of the benchmark PR stack. ## Type of change - Bug fix ## Validation - `./isaaclab.sh -p -m pytest source/isaaclab_rl/test/test_entrypoints.py -q` (11 passed) - `./isaaclab.sh -p tools/changelog/cli.py check develop` - `./isaaclab.sh -f` The full `source/isaaclab_rl/test` directory was also attempted locally but did not complete or emit results within the five-minute command timeout. ## Checklist - [x] I have read and understood the contribution guidelines - [x] I have run the pre-commit checks - [x] I have added regression tests - [x] I have added the required changelog fragment - [x] My name already exists in `CONTRIBUTORS.md`
# Description This PR moves the reinforcement-learning training and playback logic out of the `scripts/reinforcement_learning/` launcher scripts and into a reusable `isaaclab_rl.entrypoints` subpackage. The per-library launcher scripts (`rl_games/`, `rlinf/`, `rsl_rl/`, `sb3/`, `skrl/`) were thin wrappers that couldn't be imported or reused by downstream applications; the actual backend logic now lives in the `isaaclab_rl` package and is exercised through a single dispatcher. **What changed** - Added an `isaaclab_rl.entrypoints` subpackage that owns the backend implementations (`entrypoints/backends/train_*.py`, `play_*.py`), the shared `common.py` helpers, and a `dispatch.py` that selects a backend from `--rl_library` and forwards the remaining arguments. - Added a typed **programmatic API** so downstream code can launch training and playback without building an `argparse.Namespace`: ```python from isaaclab_rl import TrainingRequest, train train(TrainingRequest(backend="rsl_rl", task="Isaac-Cartpole", max_iterations=100)) ``` `PlaybackRequest` / `play` provide the same for playback. Backend-specific options go through `backend_args`, and Hydra / preset selectors through `hydra_args`. - Reduced the top-level `scripts/reinforcement_learning/train.py` and `play.py` to thin executables that call `run_train_cli` / `run_play_cli`. - Removed the deprecated per-library scripts under `scripts/reinforcement_learning/<library>/` (`train.py`, `play.py`, `cli_args.py`). Use the unified `train.py`/`play.py` with `--rl_library`, or the programmatic API instead. - Updated all internal callers — benchmarks, demos, Ray runners, AutoMate contrib launchers, the project template generator, and CI workflows — to use the unified entrypoints. - Fixed `--deterministic` not configuring PyTorch deterministic operations in the RL-Games, RSL-RL, SB3, and skrl backends. - Removed the `--use_last_checkpoint` flag from the RL-Games `play` entrypoint; use `--checkpoint latest` instead. Fixes # (issue) ## Type of change - Bug fix (non-breaking change which fixes an issue) - New feature (non-breaking change which adds functionality) - Breaking change (existing functionality will not work without user modification) - Documentation update **Breaking:** The per-library scripts under `scripts/reinforcement_learning/<library>/` and the RL-Games `--use_last_checkpoint` flag have been removed. Migrate to the unified `train.py`/`play.py` with `--rl_library <library>` (and `--checkpoint latest`). ## Screenshots N/A — no user-facing visual changes. ## Checklist - [x] I have read and understood the [contribution guidelines](https://isaac-sim.github.io/IsaacLab/main/source/refs/contributing.html) - [x] I have run the [`pre-commit` checks](https://pre-commit.com/) with `./isaaclab.sh --format` - [x] I have made corresponding changes to the documentation - [x] My changes generate no new warnings - [x] I have added tests that prove my fix is effective or that my feature works - [x] I have added a changelog fragment under `source/<pkg>/changelog.d/` for every touched package (do **not** edit `CHANGELOG.rst` or bump `extension.toml` — CI handles that) - [x] I have added my name to the `CONTRIBUTORS.md` or my name already exists there --------- Signed-off-by: Mustafa H <[email protected]> Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
# Description Promotes the benchmark framework from `isaaclab.test.benchmark` to the public `isaaclab.benchmark` package. Runtime, startup, training, play, and RL backend workflows become library entrypoints with typed in-process dispatch. The transitional import and script shims were removed from this PR to keep the move reviewable and leave one implementation for each workflow. This is an intentional breaking change: callers must replace `isaaclab.test.benchmark` imports with `isaaclab.benchmark` and use `isaaclab benchmark` instead of the former runtime, startup, training, and play scripts. ## Highlights - Adds typed runtime, startup, training, and play request objects and `run_benchmark` convenience APIs. - Returns workflow-specific result types such as `BenchmarkResult[RuntimeBundle]`. - Adds in-process `isaaclab benchmark` CLI dispatch. - Moves the supported benchmark workflows and RL backend adapters into the package. - Removes the duplicate `isaaclab.test.benchmark` namespace and standalone workflow forwarding scripts. - Restores process-global Torch, SKRL, and RL Games state and closes environments safely across repeated calls. - Rejects schema finalization without an attached typed bundle instead of reporting a nonexistent output. - Carries forward isaac-sim#6474 validation: positive workloads, non-negative warm-up counts, one default train/play warm-up step, and `--measure_sync_step`. - Adds public API documentation, migration guidance, tests, and changelog fragments. ## Dependencies - Direct dependency: isaac-sim#6474. - Satisfied prerequisite: isaac-sim#6553, already merged, provides reusable RL train/play entrypoints. ## Breaking migration - `from isaaclab.test.benchmark ...` becomes `from isaaclab.benchmark ...`. - `scripts/benchmarks/{runtime,startup,training,play}.py` becomes `isaaclab benchmark {runtime,startup,training,play}`. - Per-library train/play scripts become the unified training/play commands with `--rl_library`. - Independent camera, loading, Hydra, and other standalone benchmarks remain unchanged. ## Type of change - New feature - Breaking API migration - Documentation update ## Validation - Focused benchmark API, CLI, parser, adapter, and early-stop suite: 265 passed, 4 simulator smoke cases deselected. - Focused public API and CLI entrypoint suite: 26 passed. - `./isaaclab.sh -f`: all applicable hooks pass. The conflict-marker hook was skipped because current `develop` contains literal `=======` headings in three third-party license files. - `tools/changelog/cli.py check develop`: passed. - Runtime/startup smoke tests now invoke `uv run isaaclab benchmark`; the local clean-`uv` bootstrap exceeded the validation window while downloading the CUDA environment, so CI remains the end-to-end CLI confirmation. ## Checklist - [x] I have read and understood the contribution guidelines - [x] I have run the pre-commit checks - [x] I have made corresponding documentation changes - [x] My changes generate no new warnings - [x] I have added tests for the public API and canonical CLI paths - [x] I have added the required changelog fragments - [x] I have documented the intentional breaking migration - [x] My name already exists in `CONTRIBUTORS.md` --------- Co-authored-by: Mustafa Haiderbhai <[email protected]>
# Description The reusable reinforcement learning entrypoints introduced in isaac-sim#6553 restore `sys.argv` after in-process calls, but backend-specific global settings can still leak into the caller. This PR scopes those mutations to each invocation: - RSL-RL training parses arguments before temporarily enabling its Torch backend flags and restores all four flags on success or failure. - SKRL training restores `skrl.config.jax.backend`, including deleting it when the attribute did not exist before the call. - SKRL playback scopes the same state inside `main()`, covering both unified dispatch and direct imported calls. - Adds failure-path regressions for rejected RSL-RL requests and exceptional SKRL train/play calls. ## Relationship - Focused follow-up to isaac-sim#6553. - Independent of the benchmark PR stack. ## Type of change - Bug fix ## Validation - `./isaaclab.sh -p -m pytest source/isaaclab_rl/test/test_entrypoints.py -q` (11 passed) - `./isaaclab.sh -p tools/changelog/cli.py check develop` - `./isaaclab.sh -f` The full `source/isaaclab_rl/test` directory was also attempted locally but did not complete or emit results within the five-minute command timeout. ## Checklist - [x] I have read and understood the contribution guidelines - [x] I have run the pre-commit checks - [x] I have added regression tests - [x] I have added the required changelog fragment - [x] My name already exists in `CONTRIBUTORS.md`
#7611) # Description The symptoms addressed by #7045 and the now-merged #7532 are real, but the selection mechanism grew into a parallel configuration system: task registrations described preset-to-agent relationships, the preset CLI rediscovered those relationships and rewrote `args.agent`, every backend had to opt into that mutation, and the documentation browser copied the same mapping again. Because #7532 has since merged, this branch also fully removes its live sentinel, second parse, mutation guard, benchmark wiring, and associated compatibility tests. Historical compiled changelog entries remain as release history. This PR makes the existing preset resolver the only owner of environment-coupled selection: ```text presets=resnet18 | v resolve_task_config(task, <library>_cfg_entry_point) | +-- environment PresetCfg root -> ResNet18 observations | `-- agent PresetCfg root -> feature-policy configuration ``` The Gym registry now selects a library or a genuinely independent training recipe. A library's canonical entry point owns any agent variants coupled to environment presets, so the same `presets=` broadcast selects both roots in one resolution pass. The final diff is **687 additions / 787 deletions: net -100 lines**. ## Before and after ### 1. Environment-coupled agent variants #### Before: repeat the pairing, then teach the CLI to translate it The camera task registered separate raw and feature agent keys, then repeated their relationship to environment presets in another dictionary: ```python _RAW_CAMERA_PRESETS = ("albedo", "depth", "rgb", ...) gym.register( ..., kwargs={ "env_cfg_entry_point": "...:CartpoleCameraEnvCfg", "rsl_rl_cfg_entry_point": "...:CartpoleCameraPPORunnerCfg", "rsl_rl_feature_cfg_entry_point": "...:CartpoleCameraFeaturePPORunnerCfg", "agent_preset_compatibility": { "rsl_rl_cfg_entry_point": _RAW_CAMERA_PRESETS, "rsl_rl_feature_cfg_entry_point": ("resnet18", "theia_tiny"), # The same pairings were repeated for RL Games. }, }, ) ``` The showcase tasks amplified this into one registry key per observation/action-space combination—24 noncanonical SKRL keys across the two tasks—plus another compatibility map: ```python "skrl_cfg_entry_point": "...:skrl_box_box_ppo_cfg.yaml", "skrl_box_box_cfg_entry_point": "...:skrl_box_box_ppo_cfg.yaml", "skrl_box_discrete_cfg_entry_point": "...:skrl_box_discrete_ppo_cfg.yaml", "skrl_box_multidiscrete_cfg_entry_point": "...:skrl_box_multidiscrete_ppo_cfg.yaml", # ... one key for every remaining space combination ... "agent_preset_compatibility": { "skrl_cfg_entry_point": ("box_box",), "skrl_box_discrete_cfg_entry_point": ("box_discrete",), # ... repeat every pairing again ... }, ``` #### After: the canonical agent entry point is a preset root The agent package owns the variants directly: ```python @configclass class CartpoleCameraPPORunnerPresetsCfg(PresetCfg): default = CartpoleCameraPPORunnerCfg() resnet18 = CartpoleCameraFeaturePPORunnerCfg() theia_tiny = CartpoleCameraFeaturePPORunnerCfg() gym.register( ..., kwargs={ "env_cfg_entry_point": "...:CartpoleCameraEnvCfg", "rsl_rl_cfg_entry_point": "...:CartpoleCameraPPORunnerPresetsCfg", }, ) ``` RL Games uses the same canonical-root shape with `preset(default=..., resnet18=..., theia_tiny=...)`. The showcase YAML family is likewise exposed behind its sole canonical key: ```python def skrl_cfg(): configs = { path.stem.removeprefix("skrl_").removesuffix("_ppo_cfg"): load_yaml(path) for path in Path(__file__).parent.glob("skrl_*_ppo_cfg.yaml") } return preset(default=configs.pop("box_box"), **configs) # Gym registration "skrl_cfg_entry_point": f"{agents.__name__}:skrl_cfg" ``` The configurations remain, but the 26 preset-specific agent keys, three compatibility maps, and duplicate preset-name lists do not. ### 2. Preset CLI ownership #### Before: parse, rediscover task metadata, and mutate another subsystem's argument ```python def setup_preset_cli(parser, argv=None, *, agent_library=None): ... args, remaining = parser.parse_known_args(args_to_parse) if agent_library and task_name: _auto_select_agent(args, task_name, agent_library, args_to_parse) return args, remaining # Every caller had to opt into the second selector. args, remaining = setup_preset_cli(parser, agent_library="rsl_rl") ``` `_auto_select_agent` scanned raw `presets=` tokens, intersected them with the compatibility maps, selected a different registry key, and rewrote `args.agent`. #7532 later added a sentinel and a second argparse pass just to decide whether that mutation was allowed to override a parser default. #### After: parse preset syntax and return it unchanged ```python def setup_preset_cli(parser, argv=None): ... return parser.parse_known_args(args_to_parse) args, remaining = setup_preset_cli(parser) ``` The preset CLI is again bounded to preset help and parsing. Agent configuration selection happens once, inside config resolution. ### 3. Humanoid AMP and SKRL algorithm identity #### Before: infer both the config and algorithm from CLI/key spelling ```python # Humanoid AMP registered no canonical SKRL key. "skrl_amp_cfg_entry_point": "...:skrl_walk_amp_cfg.yaml" # SKRL defaulted to PPO and reconstructed meaning from registry-key text. parser.add_argument("--algorithm", default="PPO", ...) agent_cfg_entry_point = ( "skrl_cfg_entry_point" if args_cli.algorithm.lower() == "ppo" else f"skrl_{args_cli.algorithm.lower()}_cfg_entry_point" ) algorithm = agent_cfg_entry_point.split("_cfg")[0].split("skrl_")[-1].lower() ``` A plain Humanoid AMP command therefore looked for the missing `skrl_cfg_entry_point`. #7045 compensated with a second CLI rule: if the canonical key was absent and exactly one other key existed, mutate `args.agent` to that key. The same key-parsing pattern also mislabeled showcase keys such as `skrl_box_discrete_cfg_entry_point` as algorithms. #### After: the task owns its default; the resolved config owns its algorithm ```python # Humanoid AMP registration "default_agent": "skrl", "skrl_cfg_entry_point": "...:skrl_walk_amp_cfg.yaml", "skrl_amp_cfg_entry_point": "...:skrl_walk_amp_cfg.yaml", # explicit --algorithm AMP agent_cfg_entry_point = resolve_skrl_agent_cfg_entry_point(args_cli.agent, args_cli.algorithm) env_cfg, agent_cfg = resolve_task_config(args_cli.task, agent_cfg_entry_point) algorithm = resolve_skrl_algorithm(agent_cfg, args_cli.algorithm) # reads agent.class ``` Omitting `--algorithm` now means “use the task's canonical SKRL config,” not “assume PPO.” An explicit `--algorithm` still selects an independent algorithm recipe and is checked against the resolved `agent.class`. Train, play, benchmarks, and LEAPP all use the same rule. ### 4. Downstream consumers | Surface | Before | After | | --- | --- | --- | | CLI help | `_AgentDescriptionBuilder` and `_enumerate_agents` loaded Gym metadata and rendered compatibility pairings. | Preset help describes selectable presets; agent selection is not duplicated in the preset CLI. | | Environment browser | Every generated row carried `agentPresetCompatibility`; JavaScript searched it and injected `--agent` into commands. | The row field and JavaScript rewrite are gone; generated commands pass `presets=` directly. | | Environment catalog | Treated arbitrary agent-key suffixes as algorithms, displaying recipe names such as `FEATURE` or `BOX_DISCRETE`. | Recognizes only explicit algorithm aliases, ignores preset/recipe suffixes, and deduplicates canonical aliases of the same config. | | Ray Cartpole vision jobs | Set both `--agent=rl_games_feature_cfg_entry_point` and `presets=resnet18/theia_tiny`. | Set only the preset. | | Missing-config diagnostics | Split every `*_cfg_entry_point` suffix into guessed library and algorithm labels. | Lists the exact registered configuration keys. | | LEAPP export | The shared parser accepted `agent_library` so the preset CLI could mutate `args.agent`; SKRL then reconstructed the algorithm from that key. | Uses the plain preset parser and derives SKRL identity from the resolved `agent.class`. | | Generated project defaults | Emitted the canonical `<library>_cfg_entry_point` only for PPO, so non-PPO and all multi-agent projects depended on CLI fallback. | Filters selected algorithms per workflow and marks PPO, MAPPO, or the sole selected non-PPO recipe canonical; the documented command resolves directly. | | Regression tests | Preserved compatibility dictionaries and asserted an intermediate rewritten `args.agent` value. | Assert the resolved environment and agent configs, exact canonical registrations/minimal variants, and absence of the rejected maps/helpers. | ### 5. Commands Before, users either had to provide both coupled selectors explicitly or rely on the preset CLI to synthesize the `--agent` half: ```bash # Before: two names for one camera-feature choice uv run isaaclab train --rl_library rsl_rl \ --task Isaac-Cartpole-Camera \ --agent rsl_rl_feature_cfg_entry_point presets=resnet18 # After: one preset is composed into both roots uv run isaaclab train --rl_library rsl_rl \ --task Isaac-Cartpole-Camera presets=resnet18 ``` The same simplification applies to RL Games and the showcase space matrix: ```bash # Before uv run isaaclab train --rl_library skrl \ --task IsaacContrib-Cartpole-Showcase-Direct \ --agent skrl_box_discrete_cfg_entry_point presets=box_discrete # After uv run isaaclab train --rl_library skrl \ --task IsaacContrib-Cartpole-Showcase-Direct presets=box_discrete ``` Humanoid AMP no longer depends on an algorithm flag or the sole-entry fallback: ```bash # Before, without relying on CLI auto-selection uv run isaaclab train --rl_library skrl \ --task IsaacContrib-Humanoid-AMP-Walk-Direct --algorithm AMP # After: the canonical task config is AMP uv run isaaclab train --rl_library skrl \ --task IsaacContrib-Humanoid-AMP-Walk-Direct ``` `--algorithm AMP` remains valid when an explicit algorithm selection is desired. Generated multi-agent projects likewise use MAPPO as their canonical SKRL config, so their documented command needs no fallback: ```bash uv run isaaclab train --rl_library skrl --task <GENERATED-MARL-TASK> ``` ## Exact lineage of the removed mechanism The structure removed or superseded here accumulated across several PRs: | Change | Mechanism introduced | Disposition in this PR | | --- | --- | --- | | #2713 | Made missing-config errors split every agent entry-point key into inferred library and algorithm labels. | Errors now report the exact registered keys instead of inventing semantics for their suffixes. | | #5605 | Added the 24 space-specific showcase SKRL keys and the RL-Games camera feature key while consolidating preset-driven Cartpole tasks. | Keeps those configurations under canonical agent preset roots and removes their preset-specific registry keys. | | #5879 | Made the generated environment catalog infer algorithm labels from arbitrary entry-point suffixes and, for RL-Games vision, from the config path. | Catalog generation recognizes only the known algorithm aliases and ignores preset/recipe suffixes. | | #5904 | Added Ray camera-feature jobs that specified both `--agent=rl_games_feature_cfg_entry_point` and `presets=resnet18/theia_tiny`. | Ray selects each feature pipeline with the preset alone. | | #5930 | Added the separate `rsl_rl_feature_cfg_entry_point` for pretrained camera features. | The canonical RSL-RL root owns its raw and feature-policy variants. | | #6553 and #6564 | Made SKRL train/play and benchmark entry points default `--algorithm` to PPO, select a registry key from that default, and reconstruct algorithm identity from explicit key suffixes. | An omitted algorithm resolves the task's canonical config first; the resolved `agent.class` is authoritative everywhere. | | #6677 | Added three `agent_preset_compatibility` maps, duplicate `_SPACE_PRESETS` / `_RAW_CAMERA_PRESETS` lists, `setup_preset_cli(..., agent_library=...)`, `_AgentDescriptionBuilder`, `_enumerate_agents`, and `agent_library=` plumbing in all eight unified RL train/play entry points. It also added help, docs, and tests around those pairings. | Deletes the maps, duplicate lists, agent-aware preset CLI API/helpers, call-site plumbing, and preservation tests. | | #6779 | Extended `agent_library` into the shared LEAPP export parser and added another SKRL helper that inferred the algorithm from the agent key. | Removes that parser parameter/helper and resolves algorithm identity from the loaded config. | | #7045 | Promoted the compatibility metadata from help text into runtime control with `_auto_select_agent`, raw `presets=` scanning, declared-domain filtering, preset-to-key matching, post-parse `args.agent` mutation, and a sole-noncanonical-agent fallback for Humanoid AMP. It also wired the two SKRL benchmark entry points. | Deletes both selection rules and their benchmark wiring. Presets compose the environment and agent roots directly; AMP is registered canonically. | | #7160 | Copied `agent_preset_compatibility` into the generated environment-browser row schema and used it in JavaScript to inject a preset-specific `--agent` into generated commands. | Removes the compatibility column and browser-side command rewrite. | | #7532 (merged) | Added `_AGENT_UNSET`, a second argparse pass in `_agent_passed_explicitly`, a looser mutation guard, six RSL-RL/RL-Games/SB3 benchmark train/play wirings, and tests for rewritten `args.agent` values and explicit-flag spellings. | Fully reverts its live implementation: there is no agent-key mutation to guard, no backend-specific preset-CLI wiring to propagate, and no preservation test for that removed behavior. | This is therefore more than an alternative fix for two symptoms: it removes the parallel preset-to-agent selection system end to end. ## Intentional compatibility removal No warning-only or no-op compatibility shim is retained for: - `agent_preset_compatibility` - preset-specific agent keys such as `rsl_rl_feature_cfg_entry_point` and the showcase space-specific SKRL keys - `setup_preset_cli(..., agent_library=...)` The separately named `pretrained_checkpoint_preset_compatibility` metadata from #7630 is intentionally retained: it declares which preset-specific checkpoint artifacts exist and never selects an agent entry point. Keeping those aliases would preserve the duplicate ownership this refactor removes. Commands using a preset-specific key should remove `--agent=<preset-specific-key>` and use the canonical library selection plus `presets=<name>`, as shown above. Older SKRL runs may have encoded a configuration-key suffix such as `box_discrete` as the algorithm in a run directory or manifest. The corrected identity is the resolved `agent.class` (`PPO` in that example), so automatic `latest` / `best` discovery cannot safely match those historical runs. Pass their checkpoint path explicitly. ## Type of change - Bug fix - Architecture refactor - Intentional removal of recently introduced compatibility APIs - Documentation update ## Validation The four-case composition regression was also run against an untouched `develop` worktree. All four cases failed there because the environment preset changed while the canonical agent stayed at its default; all four pass on this branch. - Preset composition, CLI, RL entrypoint, generator, and benchmark adapter/API tests: **148 passed** - Pretrained-checkpoint metadata tests: **12 passed** - Environment documentation tests: **35 passed** - LEAPP selector/checkpoint tests: **11 passed, 1 skipped** - Environment browser generation: up to date for **137** training environments - JavaScript syntax, pre-commit hooks for all PR files, changelog validation against current `upstream/develop`, centralized structure audit, and `git diff --check`: passed No GPU simulation or full training job was run; the regression is exercised at configuration composition and entrypoint boundaries before environment construction. The generated environment-browser refresh also incorporates the current physics selectors for the two DrLegs rows. ## Release backport - [x] <!-- backport-active-release --> Backport this pull request to the active release branch after it merges into `develop` ## Screenshots Not applicable. ## Checklist - [x] I have read and understood the contribution guidelines - [x] I have run the pre-commit checks with `uv run --frozen isaaclab -f` - [x] I have made corresponding changes to the documentation - [x] My changes generate no new warnings - [x] I have added tests that prove the fix is effective - [x] I have added changelog fragments for every touched package - [x] My name already exists in `CONTRIBUTORS.md`
# Description Moves `teleop_se3_agent.py`, `record_demos.py` and `teleop_replay_agent.py` into `isaaclab_teleop.entrypoints`, following the `isaaclab_rl.entrypoints` pattern (#6553, #6793), and untangles `record_demos.py` from `isaaclab_mimic`, which is slated for deprecation. - **Entrypoints:** `run_teleop_se3_agent_cli`, `run_record_demos_cli` and `run_teleop_replay_agent_cli` take the command line without the program name. The function bodies are unchanged; the argument parsing that ran at import time becomes `_parse_args(argv)`. Git tracks the modules as renames, so review with rename detection. - **Scripts kept as thin wrappers** at their current paths (same shape as `random_agent.py`), so documented commands and the wheel staging list keep working. - **`isaaclab teleop run|record` call the entrypoints in process,** like `isaaclab train`, instead of launching the scripts. `replay` still runs `scripts/tools/replay_demos.py`, which is not moved. - **Out-of-tree tasks:** each entrypoint calls `load_external_tasks()` before parsing, so tasks registered through the `isaaclab.tasks` entry point work with the scripts and `isaaclab teleop`. - **Mimic untangled from `record_demos.py`:** - Mimic task variants (`*-Mimic-v0`) are registered only when `isaaclab_mimic` is installed. - The instruction display, whose only user was `record_demos.py`, moves from `isaaclab_mimic.ui` into the entrypoints package as a private module. - Without Kit the display has no labels and shows nothing, replacing the `SimpleNamespace` stand-ins from #8828. Notes for review: - The entrypoints import `isaaclab_tasks` without `isaaclab_teleop` declaring it. Declaring it would create a cycle, since `isaaclab_tasks` imports `isaaclab_teleop`; the import only happens when a CLI function runs. - The instruction display moves from isaaclab_mimic with its original Apache-2.0 and BSD-3-Clause notices; .pre-commit-config.yaml licenses it like the mimic files so the header hooks keep them. - The modules keep a module-level `args_cli`, so the moved functions stay unchanged. Passing it explicitly, as the RL backends do, is left for a follow-up. ## Type of change - New feature (non-breaking change which adds functionality) - Breaking change (`isaaclab_mimic.ui.instruction_display` is removed; its only user was `record_demos.py`) ## Checklist Docker and GPU tests run on demand. Push the commits you want tested, then comment `run-ci` on the pull request. - [x] I have read and understood the [contribution guidelines](https://isaac-sim.github.io/IsaacLab/main/source/refs/contributing.html) - [x] I have run the [`pre-commit` checks](https://pre-commit.com/) with `uv run isaaclab --format` - [x] I have made corresponding changes to the documentation - [x] My changes generate no new warnings - [x] I have validated the changed behavior with focused coverage and applied the [test-audit criteria](https://github.com/isaac-sim/IsaacLab/blob/HEAD/skills/developer/test-audit/SKILL.md) to any test changes - [x] I have added a changelog fragment under `source/<pkg>/changelog.d/` for every touched package (do **not** edit `CHANGELOG.rst` or bump package versions — CI handles that) - [x] I have added my name to the `CONTRIBUTORS.md` or my name already exists there --------- Signed-off-by: Rafael Wiltz <[email protected]>
Description
This PR moves the reinforcement-learning training and playback logic out of the
scripts/reinforcement_learning/launcher scripts and into a reusableisaaclab_rl.entrypointssubpackage. The per-library launcher scripts(
rl_games/,rlinf/,rsl_rl/,sb3/,skrl/) were thin wrappers thatcouldn't be imported or reused by downstream applications; the actual backend
logic now lives in the
isaaclab_rlpackage and is exercised through a singledispatcher.
What changed
Added an
isaaclab_rl.entrypointssubpackage that owns the backendimplementations (
entrypoints/backends/train_*.py,play_*.py), the sharedcommon.pyhelpers, and adispatch.pythat selects a backend from--rl_libraryand forwards the remaining arguments.Added a typed programmatic API so downstream code can launch training and
playback without building an
argparse.Namespace:PlaybackRequest/playprovide the same for playback. Backend-specificoptions go through
backend_args, and Hydra / preset selectors throughhydra_args.Reduced the top-level
scripts/reinforcement_learning/train.pyandplay.pyto thin executables that call
run_train_cli/run_play_cli.Removed the deprecated per-library scripts under
scripts/reinforcement_learning/<library>/(train.py,play.py,cli_args.py). Use the unifiedtrain.py/play.pywith--rl_library, orthe programmatic API instead.
Updated all internal callers — benchmarks, demos, Ray runners, AutoMate
contrib launchers, the project template generator, and CI workflows — to use
the unified entrypoints.
Fixed
--deterministicnot configuring PyTorch deterministic operations inthe RL-Games, RSL-RL, SB3, and skrl backends.
Removed the
--use_last_checkpointflag from the RL-Gamesplayentrypoint;use
--checkpoint latestinstead.Fixes # (issue)
Type of change
Breaking: The per-library scripts under
scripts/reinforcement_learning/<library>/and the RL-Games--use_last_checkpointflag have been removed. Migrate to the unifiedtrain.py/play.pywith--rl_library <library>(and--checkpoint latest).Screenshots
N/A — no user-facing visual changes.
Checklist
pre-commitchecks with./isaaclab.sh --formatsource/<pkg>/changelog.d/for every touched package (do not editCHANGELOG.rstor bumpextension.toml— CI handles that)CONTRIBUTORS.mdor my name already exists there