Repository navigation
[Odin] Fix preset-based agent selection for rsl_rl, rl_games and sb3 - #7532
kellyguo11 merged 4 commits into
Conversation
Preset-based --agent auto-selection was unreachable for every entrypoint that registers --agent with a non-None default. The selection guard could not distinguish a default-supplied value from a user-typed one, so presets=resnet18 and presets=theia_tiny on Isaac-Cartpole-Camera kept the raw-camera entry point and RSL-RL failed to construct its runner. Detect an explicit --agent by re-parsing into a sentinel-seeded namespace instead, which keeps an explicitly typed value winning over auto-selection. The rsl_rl, rl_games and sb3 benchmark train and play entrypoints also never passed agent_library to setup_preset_cli, so auto-selection was not attempted there at all. Only the skrl entrypoints wired it.
Greptile SummaryThe PR repairs preset-based agent selection when
Confidence Score: 5/5The PR appears safe to merge, with no actionable correctness, security, or compatibility issue identified. The new selection path preserves explicit user choices and existing defaults while selecting a different agent only when task registration provides an unambiguous compatible entry point. Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[Parse benchmark or train arguments] --> B{Was --agent explicitly supplied?}
B -->|Yes| C[Preserve explicit agent]
B -->|No| D[Enumerate task agent entry points]
D --> E{Exactly one preset-compatible agent?}
E -->|Yes| F[Select compatible agent]
E -->|No| G[Preserve parser default]
C --> H[Resolve task and agent configuration]
F --> H
G --> H
Reviews (1): Last reviewed commit: "Fix preset-based agent selection for rsl..." | Re-trigger Greptile |
There was a problem hiding this comment.
Isaac Lab Review Bot
Reviewed the preset-agent selection fix across the shared CLI helper and all six rsl_rl, rl_games, and sb3 benchmark train/play entrypoints. The patch distinguishes an explicit --agent from an argparse default, enables backend-aware selection in the benchmark paths, and preserves canonical defaults when no unambiguous preset-compatible agent exists.
- Design and architecture: Returning str | None from _auto_select_agent centralizes namespace mutation in setup_preset_cli and cleanly preserves caller defaults when selection is absent or ambiguous. The sentinel namespace probe is consistent with argparse behavior and retains explicit-user-choice precedence. Re-parsing does execute parser actions twice, but the affected entrypoints use ordinary argument actions; custom side-effecting actions remain a non-blocking future compatibility consideration.
- API: setup_preset_cli remains signature-compatible, and its agent_library behavior is now documented. The changed _auto_select_agent helper is private, its local callers were updated, and both affected source packages include changelog fragments. Explicit --agent values continue to override automatic selection.
- Implementation: The producer-to-consumer path was traced from benchmark request argv generation through setup_preset_cli to resolve_task_config. Preset compatibility selects the feature entrypoints for rsl_rl and rl_games, ambiguous or absent matches retain existing defaults, and the default-absent rule still supports tasks with a single noncanonical agent entrypoint. Tests cover feature-preset selection, explicit override precedence, and default preservation across the wired backends. The added hasattr guard means parsers without an agent destination no longer receive one implicitly, but the changed benchmark consumers all define --agent.
No blocking issues. No inline issue met the actionable-evidence threshold; the assessment above records the review feedback.
Automated review; human maintainers own approval decisions.
Keep _auto_select_agent mutating args in place instead of returning the selected entry point: the return-value refactor was a tidy-up riding along, not something the fix needs. Replace the library x preset cross product in the unit test with a single selection case, and cover the three --agent spellings argparse accepts (separate, =VALUE, abbreviated) instead. The abbreviated form is what rules out scanning argv for a literal token; the benchmark test keeps the full resnet18/theia_tiny x rsl_rl/rl_games matrix that mirrors the failing rows.
The three benchmark_play_* wirings were unproven: reverting them broke no test, since every regression test drove the training path. Playback resolves the same agent config through the same resolve_task_config call and builds the same runner, so it mis-selects the raw-camera entry point identically and would load a feature-trained checkpoint into the wrong policy architecture. The sweep never surfaced it only because a row that dies at train_rc=1 never reaches playback. Add the playback selection test so the wiring is justified by a test that fails without it, rather than kept for symmetry.
|
run-ci |
hujc7
left a comment
There was a problem hiding this comment.
[P2] Agent review: both bot assessments are pinned to 61a2957 and predate the last two commits. The review-bot's approval specifically praises the _auto_select_agent return-value shape that d29e344d7f2 reverted, so it no longer describes the code. Worth re-running them before merge.
|
|
||
| task_name = getattr(args, "task", None) or argv_helper.task_name | ||
| if agent_library and getattr(args, "agent", None) is None and task_name: | ||
| if agent_library and task_name and hasattr(args, "agent") and not _agent_passed_explicitly(parser, args_to_parse): |
There was a problem hiding this comment.
[P2] Agent review: agent_preset_compatibility drives selection here but nothing validates an explicit --agent against it, so an incompatible one is honoured silently and still reaches the opaque runner-construction error this PR removes for the auto-selected path.
Raising as a follow-up rather than a change here, since "Narrow the preset agent-selection fix to its minimum" deliberately kept this out of scope.
|
Backported to |
…7532) # Description Preset-based `--agent` auto-selection is dead code for `rsl_rl`, `rl_games` and `sb3`. Two defects sit **in series** on the same code path: 1. **The selection guard cannot see past the CLI default.** `_auto_select_agent` in `source/isaaclab_tasks/isaaclab_tasks/utils/preset_cli.py` was only reached when `args.agent is None`. `add_common_train_args` registers `--agent` with `default=agent_default`, and every backend except `skrl` passes a non-`None` `agent_default` (`rsl_rl_cfg_entry_point`, `rl_games_cfg_entry_point`, `sb3_cfg_entry_point`). The parsed value is therefore never `None`, so the branch never runs. 2. **The benchmark entrypoints never asked for it.** `benchmark_train_{rsl_rl,rl_games,sb3}.py` and `benchmark_play_{rsl_rl,rl_games,sb3}.py` called `setup_preset_cli(parser, argv)` without `agent_library`, so auto-selection was not attempted at all (and the registered-agent help listing was missing too). Only the `skrl` benchmark entrypoints wired it. ## Provenance and symptom Benchmark sweep dispatch `20260901-153531` (image built from `release/3.0.0` at `f88dbc59c82`, `rsl_rl`) produced **60 failed rows**: `resnet18` (30) and `theia_tiny` (30), failing 100% across all three renderers and all physics backends. Every one died before the first training step: ``` ValueError: Observation 'critic' in observation set 'critic' not found in the observations from the environment. Available observations from the environment: ['policy'] ``` Call chain: `OnPolicyRunner.__init__` → `ppo.py construct_algorithm` → `rsl_rl/utils/utils.py:233 resolve_obs_groups`. ## Why this is an agent-entrypoint bug, not a missing observation group `Isaac-Cartpole-Camera` already declares the correct pairing: ```python "agent_preset_compatibility": { "rsl_rl_cfg_entry_point": _RAW_CAMERA_PRESETS, "rsl_rl_feature_cfg_entry_point": ("resnet18", "theia_tiny"), ... } ``` and `CartpoleCameraFeaturePPORunnerCfg` sets `obs_groups` with `critic: ["policy"]`. The feature entry point exists, is registered, is correct — it was simply unreachable, so `resnet18`/`theia_tiny` ran against the raw-camera `CartpoleCameraPPORunnerCfg`, whose `obs_groups` asks for a `critic` group the env does not expose. Nothing needs to be added to the environment. ## Why both defects are in one PR Neither half fixes the observed failure alone; this was measured, not assumed. Reverting either half of the change and running the regression test: | state | result | | --- | --- | | defect 2 fixed only (`agent_library` wired, guard unchanged) | 4 failed — `--agent` still parses to the non-`None` default, so the guard rejects | | defect 1 fixed only (guard fixed, `agent_library` not wired) | 4 failed — `if agent_library and ...` is `False`, auto-selection never attempted | | both fixed | passes | They are two links in one chain, so splitting them yields a PR that fixes nothing observable and a PR that cannot be tested end-to-end. ## Scope: train **and** play, benchmark **and** non-benchmark To pre-empt the obvious question — this is not a play-only or a train-only fix. | path | affected by | fixed by | proven by | | --- | --- | --- | --- | | `benchmark_train_{rsl_rl,rl_games,sb3}` | defects 1 + 2 | `preset_cli.py` + `agent_library=` wiring | `test_training_request_selects_preset_compatible_agent` — **this is the observed 60-row failure** | | `benchmark_play_{rsl_rl,rl_games,sb3}` | defects 1 + 2 | `preset_cli.py` + `agent_library=` wiring | `test_play_request_selects_preset_compatible_agent` | | `isaaclab_rl` `train_*`/`play_*` (non-benchmark) | defect 1 only — they already pass `agent_library` | `preset_cli.py` alone; **no file in this PR touches them** | `test_setup_preset_cli_auto_selects_agent_over_non_none_default` | Each half of the benchmark wiring was reverted independently and re-tested: * revert the three **train** wirings → the 4 training selection cases fail. Load-bearing for the reported failure. * revert the three **play** wirings → the 2 playback selection cases fail. There is **no train/play asymmetry** that would justify wiring only one of them: both register `--agent` with the same non-`None` default via the same helper, both call `setup_preset_cli`, and both feed `args.agent` into the same `resolve_task_config(...)` and then into the same `OnPolicyRunner(...)` construction. The reason the sweep only surfaced the training failure is ordering, not asymmetry — a row that dies at `train_rc=1` never reaches playback. Measured on the playback path before the wiring was added: ``` $ BenchmarkPlayRequest(backend="rsl_rl", task="Isaac-Cartpole-Camera", presets=("resnet18",)) args.agent : rsl_rl_cfg_entry_point # raw-camera config, wrong # with the wiring: args.agent : rsl_rl_feature_cfg_entry_point # correct ``` Playback would therefore have loaded a feature-trained checkpoint into the raw-camera policy architecture. ## Fix chosen Detect an explicitly typed `--agent` by re-parsing the same argv into a namespace pre-seeded with a sentinel: argparse only applies a default for a destination the namespace does not already carry, so the sentinel survives unless the user actually typed the flag. Auto-selection runs only when it does survive; an explicit `--agent` still wins. The six benchmark entrypoints now pass `agent_library`. The probe uses the same parser on the same argv as the real parse, so its verdict *is* argparse's verdict. Verified across every spelling — `--agent V`, `--agent=V`, the abbreviation `--age V`, repeated flags, and `--agent` after a `--` separator (correctly not explicit: argparse does not set it in the real parse either). A literal argv scan for `--agent` would get the abbreviation wrong and silently override a user's explicit choice, which is why the probe is preferred; the repo's existing `ExplicitAction` idiom would work too but requires touching all ten `--agent` registration sites across three packages, and a missed site fails the same silent way. ### Rejected: make `--agent` default to `None` everywhere This is the obvious fix and it is not safe. `skrl` can default to `None` because `train_skrl.py` reconstructs the entry point from `--algorithm` when it is `None`. The other three pass `args_cli.agent` straight into `resolve_task_config(...)`, which has no such fallback — `hydra.py:619` sets `agent_cfg = load_cfg_from_registry(...) if agent_entry else None`, and the entrypoints then dereference `agent_cfg.max_iterations`. A `None` default would break every plain `--task=X` run that relies on the canonical entry point, i.e. the overwhelmingly common case. Fixing that would mean adding a fallback to each of the six benchmark entrypoints plus the four train/play entrypoints: a much wider blast radius than the bug. ### Blast radius Behavior changes only where auto-selection actually fires, and only when the user did **not** type `--agent`: * **Rule 1 (preset-based)** fires only for tasks that opted in with `agent_preset_compatibility` — today `Isaac-Cartpole-Camera` and the two cartpole-showcase tasks. That is the declared contract finally being honored. Anyone who wants the previous (broken) pairing can still pass `--agent rsl_rl_cfg_entry_point` explicitly; covered by a test. * **Rule 2 (default-absent)** fires only when `<library>_cfg_entry_point` is *not* registered and exactly one other entry point is. That path previously resolved an unregistered entry point and crashed, so this is strictly a repair. * Everything else — no preset pairing declared, or the canonical default is registered — keeps the exact default it had; covered by a test for all three libraries. * `skrl` is unaffected: it already passed `agent_default=None`, and the explicit/implicit distinction collapses to the old `is None` check for it. `rl_games` and `sb3` share the defect and are fixed by the same change. **`sb3` has no task declaring `agent_preset_compatibility`, so there is no positive selection test for it** — its wiring is covered by the shared code path and by a default-preservation test only. ## Type of change - Bug fix (non-breaking change which fixes an issue) ## Screenshots Not applicable. ## Validation Regression tests were confirmed to fail on `develop` without the fix and pass with it. **Before the fix** (production changes reverted to `develop`, tests in place): ``` $ uv run --frozen --extra test python -m pytest source/isaaclab_tasks/test/core/test_preset_cli.py \ source/isaaclab/test/benchmark/test_api.py -q -p no:warnings \ -k "preset_compatible_agent or keeps_backend_default_agent or auto_selects_agent_over_non_none or keeps_explicit_agent" FAILED test_preset_cli.py::test_setup_preset_cli_auto_selects_agent_over_non_none_default FAILED test_api.py::test_training_request_selects_preset_compatible_agent[resnet18-rsl_rl] FAILED test_api.py::test_training_request_selects_preset_compatible_agent[resnet18-rl_games] FAILED test_api.py::test_training_request_selects_preset_compatible_agent[theia_tiny-rsl_rl] FAILED test_api.py::test_training_request_selects_preset_compatible_agent[theia_tiny-rl_games] 5 failed, 6 passed, 53 deselected E AssertionError: assert 'rl_games_cfg_entry_point' == 'rl_games_feature_cfg_entry_point' ``` **After the fix:** ``` $ uv run --frozen --extra test python -m pytest source/isaaclab_tasks/test/core/test_preset_cli.py \ source/isaaclab_tasks/test/core/test_hydra.py source/isaaclab/test/benchmark \ source/isaaclab_rl/test/test_entrypoints_common.py -q -p no:warnings 492 passed, 1 skipped in 30.89s $ uv run --frozen --extra test --extra skrl --extra sb3 --extra rl-games --extra rsl-rl \ python -m pytest source/isaaclab_rl/test/test_typed_preset_cli_train_play.py -q -p no:warnings 8 passed in 33.27s ``` (The last suite fails on a bare `--extra test` environment on `develop` too — `ModuleNotFoundError: No module named 'skrl'` etc. — so it was rerun with the RL extras.) ``` $ uv run --frozen python tools/changelog/cli.py check develop ✓ All modified packages have valid changelog fragments. $ uv run --frozen isaaclab -f all hooks passed ``` Tests added: * `source/isaaclab_tasks/test/core/test_preset_cli.py` — auto-selection over a non-`None` default; explicit `--agent` wins over the preset, parametrized over the three spellings argparse accepts. The two pre-existing auto-selection tests only covered `skrl` with `agent_default=None`, which is exactly why this bug went unnoticed. * `source/isaaclab/test/benchmark/test_api.py` — drives the real benchmark entrypoints via `BenchmarkTrainingRequest`/`BenchmarkPlayRequest` and `_parse_args`, asserting the feature entry point is selected for `resnet18`/`theia_tiny` × `rsl_rl`/`rl_games` on the train path (mirroring the failing rows), the same on the play path, and that the canonical default survives otherwise (`rsl_rl`, `rl_games`, `sb3`). Both assert the *selected agent config*, not merely absence of an exception. Not run: a real training job on the failing rows (requires GPU sim). The failure is a construction-time config selection, fully reproduced at CLI level. ## Related PRs — checked, no overlap * **#7491** (Select pretrained checkpoints from resolved task configs) touches `isaaclab_rl/entrypoints/common.py`, the four `play_*` entrypoints, the four `benchmark_play_*` entrypoints, `cartpole/__init__.py` and `test_preset_cli.py` — adjacent, but changes neither `agent_default` nor the selection guard. Textual conflicts are possible in `test_preset_cli.py` and the `benchmark_play_*` files (one-line `setup_preset_cli(...)` call); no semantic conflict. * **#6440** (`fix(rsl_rl): default obs_groups for new runners`) adds an `obs_groups` default in `isaaclab_rl/rsl_rl/utils.py`. It would mask this symptom for runners that omit `obs_groups`, but `CartpoleCameraPPORunnerCfg` sets `obs_groups` explicitly, so it does not fix these 60 rows — and it would not make the correct feature config get selected either. Complementary, not duplicate. * `gh pr list --search "agent preset"` returned nothing touching this code. ## Release backport - [x] <!-- backport-active-release --> Backport this pull request to the active release branch after it merges into `develop` --------- Co-authored-by: hujc <[email protected]> (cherry picked from commit 7c6b4d7)
# Description Complete preset-aware pretrained checkpoint support for feature-extractor policies on `Isaac-Cartpole-Camera`. - Advertise every feature-agent preset supported by the preferred RSL-RL workflow in the checkpoint publication matrix. The currently registered feature presets are `resnet18` and `theia_tiny`. - Flatten arbitrary multi-dimensional frozen image-encoder outputs after the environment batch dimension. This is a no-op for ResNet18's already-flat output and converts Theia-Tiny's token output from `(num_envs, 36, 192)` to the flat observation required by the MLP policy. - Validate checkpoint metadata registry-wide: workflows must be registered, presets must be unique, and every advertised preset must be a real domain preset. - Derive the Cartpole coverage assertion from `agent_preset_compatibility`, so adding a future feature preset without checkpoint publication metadata fails CI. - Regenerate the environment browser so supported pretrained feature presets are visible. The mechanism is not tied to the two QA commands: #7594 provides generic preset-aware naming/lookup/publication, while this PR covers arbitrary feature encoder shapes and future feature-preset registry additions. Other raw camera/rendering/domain presets remain explicit opt-ins because each advertised entry requires a compatible trained artifact. This builds on the agent preset selection fixed by #7532 and the checkpoint naming/lookup fixed by #7594. Both are merged. Addresses NVBug 6675381. ## Type of change - Bug fix (non-breaking change which fixes an issue) - Documentation update ## Release backport - [x] <!-- backport-active-release --> Backport this pull request to the active release branch after it merges into `develop` ## Screenshots Not applicable. ## Validation - Regression test failed on merged `develop`: encoder output remained `torch.Size([4, 6, 8])` instead of `(4, 48)`. - `.venv/bin/python -m pytest scripts/tools/test/test_train_and_publish_checkpoints.py source/isaaclab/test/envs/test_stacked_image_mdp.py source/isaaclab_rl/test/test_pretrained_checkpoint.py -q` — 44 passed. - `UV_FROZEN=1 uv run isaaclab -f` — passed. - `uv run python tools/changelog/cli.py check develop` — passed. - `uv run --isolated --extra test -- make -C docs current-docs` — generated the updated browser and completed all pages, but exited 2 because the local isolated environment reports 44 pre-existing import/reference warnings as errors (including unavailable `ovstage` and `isaaclab_ppisp` modules). The PR docs CI is the authoritative warning-free build. - ResNet18 and Theia-Tiny RSL-RL policies trained for 1,638,400 steps each with local Isaac Sim 6.1 and reached mean episode lengths of 222.25 and 177.00, respectively (benchmark threshold: 150). - Both checkpoints loaded and reached policy playback; Theia-Tiny used the corrected flattened observation size of 6,912. - Both default Newton MJWarp/Newton renderer artifacts are present on the internal Nucleus server under the exact preset-aware filenames: - `rsl_rl/Isaac-Cartpole-Camera_resnet18_newtonmjwarp_newton_rsl_rl.pt` — 6,985,267 bytes, SHA-256 `13cbec819675809d6904c57d68a20d7c7d92d283999502509e8fd8da006099f8` - `rsl_rl/Isaac-Cartpole-Camera_theia_tiny_newtonmjwarp_newton_rsl_rl.pt` — 43,450,675 bytes, SHA-256 `9f75a2069bdec9bd06f888b9264da3ad664d3707fa038cf09929045ce5b526c0` ## Artifact coverage The uploaded pair covers the default Newton MJWarp/Newton renderer selection. The generic core publication matrix also schedules both feature presets for these additional supported backend/renderer pairs, whose artifacts still need to be trained and published for full cross-backend coverage: - PhysX / RTX - PhysX / Newton renderer - Newton MJWarp / RTX ## 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 `uv run 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 my fix is effective - [x] I have added a changelog fragment under `source/<pkg>/changelog.d/` for every touched package - [x] My name already exists in `CONTRIBUTORS.md`
# Description Complete preset-aware pretrained checkpoint support for feature-extractor policies on `Isaac-Cartpole-Camera`. - Advertise every feature-agent preset supported by the preferred RSL-RL workflow in the checkpoint publication matrix. The currently registered feature presets are `resnet18` and `theia_tiny`. - Flatten arbitrary multi-dimensional frozen image-encoder outputs after the environment batch dimension. This is a no-op for ResNet18's already-flat output and converts Theia-Tiny's token output from `(num_envs, 36, 192)` to the flat observation required by the MLP policy. - Validate checkpoint metadata registry-wide: workflows must be registered, presets must be unique, and every advertised preset must be a real domain preset. - Derive the Cartpole coverage assertion from `agent_preset_compatibility`, so adding a future feature preset without checkpoint publication metadata fails CI. - Regenerate the environment browser so supported pretrained feature presets are visible. The mechanism is not tied to the two QA commands: #7594 provides generic preset-aware naming/lookup/publication, while this PR covers arbitrary feature encoder shapes and future feature-preset registry additions. Other raw camera/rendering/domain presets remain explicit opt-ins because each advertised entry requires a compatible trained artifact. This builds on the agent preset selection fixed by #7532 and the checkpoint naming/lookup fixed by #7594. Both are merged. Addresses NVBug 6675381. ## Type of change - Bug fix (non-breaking change which fixes an issue) - Documentation update ## Release backport - [x] <!-- backport-active-release --> Backport this pull request to the active release branch after it merges into `develop` ## Screenshots Not applicable. ## Validation - Regression test failed on merged `develop`: encoder output remained `torch.Size([4, 6, 8])` instead of `(4, 48)`. - `.venv/bin/python -m pytest scripts/tools/test/test_train_and_publish_checkpoints.py source/isaaclab/test/envs/test_stacked_image_mdp.py source/isaaclab_rl/test/test_pretrained_checkpoint.py -q` — 44 passed. - `UV_FROZEN=1 uv run isaaclab -f` — passed. - `uv run python tools/changelog/cli.py check develop` — passed. - `uv run --isolated --extra test -- make -C docs current-docs` — generated the updated browser and completed all pages, but exited 2 because the local isolated environment reports 44 pre-existing import/reference warnings as errors (including unavailable `ovstage` and `isaaclab_ppisp` modules). The PR docs CI is the authoritative warning-free build. - ResNet18 and Theia-Tiny RSL-RL policies trained for 1,638,400 steps each with local Isaac Sim 6.1 and reached mean episode lengths of 222.25 and 177.00, respectively (benchmark threshold: 150). - Both checkpoints loaded and reached policy playback; Theia-Tiny used the corrected flattened observation size of 6,912. - Both default Newton MJWarp/Newton renderer artifacts are present on the internal Nucleus server under the exact preset-aware filenames: - `rsl_rl/Isaac-Cartpole-Camera_resnet18_newtonmjwarp_newton_rsl_rl.pt` — 6,985,267 bytes, SHA-256 `13cbec819675809d6904c57d68a20d7c7d92d283999502509e8fd8da006099f8` - `rsl_rl/Isaac-Cartpole-Camera_theia_tiny_newtonmjwarp_newton_rsl_rl.pt` — 43,450,675 bytes, SHA-256 `9f75a2069bdec9bd06f888b9264da3ad664d3707fa038cf09929045ce5b526c0` ## Artifact coverage The uploaded pair covers the default Newton MJWarp/Newton renderer selection. The generic core publication matrix also schedules both feature presets for these additional supported backend/renderer pairs, whose artifacts still need to be trained and published for full cross-backend coverage: - PhysX / RTX - PhysX / Newton renderer - Newton MJWarp / RTX ## 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 `uv run 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 my fix is effective - [x] I have added a changelog fragment under `source/<pkg>/changelog.d/` for every touched package - [x] My name already exists in `CONTRIBUTORS.md` (cherry picked from commit cdaefc5)
#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
Preset-based
--agentauto-selection is dead code forrsl_rl,rl_gamesandsb3. Two defects sit in series on the same code path:_auto_select_agentinsource/isaaclab_tasks/isaaclab_tasks/utils/preset_cli.pywas only reached whenargs.agent is None.add_common_train_argsregisters--agentwithdefault=agent_default, and every backend exceptskrlpasses a non-Noneagent_default(rsl_rl_cfg_entry_point,rl_games_cfg_entry_point,sb3_cfg_entry_point). The parsed value is therefore neverNone, so the branch never runs.benchmark_train_{rsl_rl,rl_games,sb3}.pyandbenchmark_play_{rsl_rl,rl_games,sb3}.pycalledsetup_preset_cli(parser, argv)withoutagent_library, so auto-selection was not attempted at all (and the registered-agent help listing was missing too). Only theskrlbenchmark entrypoints wired it.Provenance and symptom
Benchmark sweep dispatch
20260901-153531(image built fromrelease/3.0.0atf88dbc59c82,rsl_rl) produced 60 failed rows:resnet18(30) andtheia_tiny(30), failing 100% across all three renderers and all physics backends. Every one died before the first training step:Call chain:
OnPolicyRunner.__init__→ppo.py construct_algorithm→rsl_rl/utils/utils.py:233 resolve_obs_groups.Why this is an agent-entrypoint bug, not a missing observation group
Isaac-Cartpole-Cameraalready declares the correct pairing:and
CartpoleCameraFeaturePPORunnerCfgsetsobs_groupswithcritic: ["policy"]. The feature entry point exists, is registered, is correct — it was simply unreachable, soresnet18/theia_tinyran against the raw-cameraCartpoleCameraPPORunnerCfg, whoseobs_groupsasks for acriticgroup the env does not expose. Nothing needs to be added to the environment.Why both defects are in one PR
Neither half fixes the observed failure alone; this was measured, not assumed. Reverting either half of the change and running the regression test:
agent_librarywired, guard unchanged)--agentstill parses to the non-Nonedefault, so the guard rejectsagent_librarynot wired)if agent_library and ...isFalse, auto-selection never attemptedThey are two links in one chain, so splitting them yields a PR that fixes nothing observable and a PR that cannot be tested end-to-end.
Scope: train and play, benchmark and non-benchmark
To pre-empt the obvious question — this is not a play-only or a train-only fix.
benchmark_train_{rsl_rl,rl_games,sb3}preset_cli.py+agent_library=wiringtest_training_request_selects_preset_compatible_agent— this is the observed 60-row failurebenchmark_play_{rsl_rl,rl_games,sb3}preset_cli.py+agent_library=wiringtest_play_request_selects_preset_compatible_agentisaaclab_rltrain_*/play_*(non-benchmark)agent_librarypreset_cli.pyalone; no file in this PR touches themtest_setup_preset_cli_auto_selects_agent_over_non_none_defaultEach half of the benchmark wiring was reverted independently and re-tested:
There is no train/play asymmetry that would justify wiring only one of them: both register
--agentwith the same non-Nonedefault via the same helper, both callsetup_preset_cli, and both feedargs.agentinto the sameresolve_task_config(...)and then into the sameOnPolicyRunner(...)construction. The reason the sweep only surfaced the training failure is ordering, not asymmetry — a row that dies attrain_rc=1never reaches playback. Measured on the playback path before the wiring was added:Playback would therefore have loaded a feature-trained checkpoint into the raw-camera policy architecture.
Fix chosen
Detect an explicitly typed
--agentby re-parsing the same argv into a namespace pre-seeded with a sentinel: argparse only applies a default for a destination the namespace does not already carry, so the sentinel survives unless the user actually typed the flag. Auto-selection runs only when it does survive; an explicit--agentstill wins. The six benchmark entrypoints now passagent_library.The probe uses the same parser on the same argv as the real parse, so its verdict is argparse's verdict. Verified across every spelling —
--agent V,--agent=V, the abbreviation--age V, repeated flags, and--agentafter a--separator (correctly not explicit: argparse does not set it in the real parse either). A literal argv scan for--agentwould get the abbreviation wrong and silently override a user's explicit choice, which is why the probe is preferred; the repo's existingExplicitActionidiom would work too but requires touching all ten--agentregistration sites across three packages, and a missed site fails the same silent way.Rejected: make
--agentdefault toNoneeverywhereThis is the obvious fix and it is not safe.
skrlcan default toNonebecausetrain_skrl.pyreconstructs the entry point from--algorithmwhen it isNone. The other three passargs_cli.agentstraight intoresolve_task_config(...), which has no such fallback —hydra.py:619setsagent_cfg = load_cfg_from_registry(...) if agent_entry else None, and the entrypoints then dereferenceagent_cfg.max_iterations. ANonedefault would break every plain--task=Xrun that relies on the canonical entry point, i.e. the overwhelmingly common case. Fixing that would mean adding a fallback to each of the six benchmark entrypoints plus the four train/play entrypoints: a much wider blast radius than the bug.Blast radius
Behavior changes only where auto-selection actually fires, and only when the user did not type
--agent:agent_preset_compatibility— todayIsaac-Cartpole-Cameraand the two cartpole-showcase tasks. That is the declared contract finally being honored. Anyone who wants the previous (broken) pairing can still pass--agent rsl_rl_cfg_entry_pointexplicitly; covered by a test.<library>_cfg_entry_pointis not registered and exactly one other entry point is. That path previously resolved an unregistered entry point and crashed, so this is strictly a repair.skrlis unaffected: it already passedagent_default=None, and the explicit/implicit distinction collapses to the oldis Nonecheck for it.rl_gamesandsb3share the defect and are fixed by the same change.sb3has no task declaringagent_preset_compatibility, so there is no positive selection test for it — its wiring is covered by the shared code path and by a default-preservation test only.Type of change
Screenshots
Not applicable.
Validation
Regression tests were confirmed to fail on
developwithout the fix and pass with it.Before the fix (production changes reverted to
develop, tests in place):After the fix:
(The last suite fails on a bare
--extra testenvironment ondeveloptoo —ModuleNotFoundError: No module named 'skrl'etc. — so it was rerun with the RL extras.)Tests added:
source/isaaclab_tasks/test/core/test_preset_cli.py— auto-selection over a non-Nonedefault; explicit--agentwins over the preset, parametrized over the three spellings argparse accepts. The two pre-existing auto-selection tests only coveredskrlwithagent_default=None, which is exactly why this bug went unnoticed.source/isaaclab/test/benchmark/test_api.py— drives the real benchmark entrypoints viaBenchmarkTrainingRequest/BenchmarkPlayRequestand_parse_args, asserting the feature entry point is selected forresnet18/theia_tiny×rsl_rl/rl_gameson the train path (mirroring the failing rows), the same on the play path, and that the canonical default survives otherwise (rsl_rl,rl_games,sb3).Both assert the selected agent config, not merely absence of an exception.
Not run: a real training job on the failing rows (requires GPU sim). The failure is a construction-time config selection, fully reproduced at CLI level.
Related PRs — checked, no overlap
isaaclab_rl/entrypoints/common.py, the fourplay_*entrypoints, the fourbenchmark_play_*entrypoints,cartpole/__init__.pyandtest_preset_cli.py— adjacent, but changes neitheragent_defaultnor the selection guard. Textual conflicts are possible intest_preset_cli.pyand thebenchmark_play_*files (one-linesetup_preset_cli(...)call); no semantic conflict.fix(rsl_rl): default obs_groups for new runners) adds anobs_groupsdefault inisaaclab_rl/rsl_rl/utils.py. It would mask this symptom for runners that omitobs_groups, butCartpoleCameraPPORunnerCfgsetsobs_groupsexplicitly, so it does not fix these 60 rows — and it would not make the correct feature config get selected either. Complementary, not duplicate.gh pr list --search "agent preset"returned nothing touching this code.Release backport
develop