Skip to content

fix(rsl_rl): default obs_groups for new runners - #6440

Closed
saime428 wants to merge 3 commits into
isaac-sim:developfrom
saime428:fix/rsl-rl-play-obs-groups
Closed

saime428 wants to merge 3 commits into
isaac-sim:developfrom
saime428:fix/rsl-rl-play-obs-groups

Conversation

@saime428

@saime428 saime428 commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Summary:

  • Populate a default obs_groups mapping for OnPolicyRunner configs when running with rsl-rl >= 4.0.0.
  • Preserve any explicitly configured obs_groups values.
  • Add regression coverage for missing and existing obs_groups in the rsl-rl deprecation helper.

Why:

  • rsl-rl 4.x expects obs_groups in runner configs. Existing play.py already routes configs through handle_deprecated_rsl_rl_cfg() before calling OnPolicyRunner, so filling the missing default there keeps play/eval paths compatible without changing each script separately.

Validation:

  • python -m compileall source\isaaclab_rl\isaaclab_rl\rsl_rl\utils.py
  • python -m compileall source\isaaclab_rl\test\test_rsl_rl_cfg_deprecation.py
  • python -m ruff check source\isaaclab_rl\isaaclab_rl\rsl_rl\utils.py source\isaaclab_rl\test\test_rsl_rl_cfg_deprecation.py
  • lightweight handle_deprecated_rsl_rl_cfg() dummy-runner check for default and preserved obs_groups
  • python -m pytest source\isaaclab_rl\test\test_rsl_rl_cfg_deprecation.py -q (collection is blocked in this local environment by missing Isaac Sim / Warp packages)

Notes for reviewers:

@github-actions github-actions Bot added bug Something isn't working isaac-lab Related to Isaac Lab team labels Jul 9, 2026
@greptile-apps

greptile-apps Bot commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR fixes compatibility with rsl-rl >= 4.0.0 by automatically populating a default obs_groups mapping on OnPolicyRunner configs when the field is left at its MISSING sentinel. The logic is placed inside handle_deprecated_rsl_rl_cfg, which is already called on every play/eval path, so existing scripts get the fix without modification.

  • _set_default_obs_groups is added to utils.py and called at the top of the >= 4.0.0 branch; it only mutates configs whose class_name is \"OnPolicyRunner\" and whose obs_groups is still MISSING, preserving any explicitly set value.
  • Two parametrized tests in TestObsGroups verify the default-fill and the no-overwrite behavior across versions 4.x and 5.x.

Confidence Score: 4/5

Safe to merge — the change is a small, well-guarded default-fill that only mutates configs missing obs_groups, and explicitly preserves any value the user already set.

The production logic in utils.py is straightforward and correctly gated by three independent guards (class_name, hasattr, and _is_missing). The only gaps are in the test file: there is no assertion that the rsl-rl < 4.0.0 path leaves obs_groups untouched, and there is a minor PEP 8 formatting issue. Neither affects correctness of the shipped code.

The test file test_rsl_rl_cfg_deprecation.py would benefit from a small additional boundary test for the < 4.0.0 path; utils.py itself needs no further attention.

Important Files Changed

Filename Overview
source/isaaclab_rl/isaaclab_rl/rsl_rl/utils.py Adds _set_default_obs_groups helper and calls it at the start of the rsl-rl >= 4.0.0 branch; logic is guarded correctly by class_name, hasattr, and _is_missing checks.
source/isaaclab_rl/test/test_rsl_rl_cfg_deprecation.py Adds TestObsGroups with two parametrized tests covering default-fill and preserve cases; missing a blank line before the following section separator, and no negative test confirming obs_groups is not set for rsl-rl < 4.0.0.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A["handle_deprecated_rsl_rl_cfg(agent_cfg, version)"] --> B{version < 4.0.0?}
    B -- Yes --> C[Validate policy present\nClear new model cfgs]
    B -- No --> D["_set_default_obs_groups(agent_cfg)"]
    D --> E{class_name == 'OnPolicyRunner'\nAND hasattr obs_groups\nAND obs_groups is MISSING?}
    E -- Yes --> F["Set obs_groups = {'actor': ['policy'], 'critic': ['policy']}"]
    E -- No --> G[Leave obs_groups unchanged]
    F --> H{policy present?}
    G --> H
    H -- Yes --> I[Infer actor/critic/student/teacher from deprecated policy]
    H -- No --> J{version < 5.0.0?}
    I --> J
    J -- Yes --> K[Validate old stochastic cfg]
    J -- No --> L[Migrate to distribution_cfg]
Loading
%%{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"}}}%%
flowchart TD
    A["handle_deprecated_rsl_rl_cfg(agent_cfg, version)"] --> B{version < 4.0.0?}
    B -- Yes --> C[Validate policy present\nClear new model cfgs]
    B -- No --> D["_set_default_obs_groups(agent_cfg)"]
    D --> E{class_name == 'OnPolicyRunner'\nAND hasattr obs_groups\nAND obs_groups is MISSING?}
    E -- Yes --> F["Set obs_groups = {'actor': ['policy'], 'critic': ['policy']}"]
    E -- No --> G[Leave obs_groups unchanged]
    F --> H{policy present?}
    G --> H
    H -- Yes --> I[Infer actor/critic/student/teacher from deprecated policy]
    H -- No --> J{version < 5.0.0?}
    I --> J
    J -- Yes --> K[Validate old stochastic cfg]
    J -- No --> L[Migrate to distribution_cfg]
Loading

Reviews (1): Last reviewed commit: "fix(rsl_rl): default obs_groups for new ..." | Re-trigger Greptile

@saime428

Copy link
Copy Markdown
Contributor Author

Hi, checking in on this fix for #5363. The PR remains conflict-free, though the branch is now behind main. I can update it before review if you prefer, or make any requested changes.

@saime428

saime428 commented Aug 2, 2026

Copy link
Copy Markdown
Contributor Author

Following up on this PR. The branch is currently behind main but remains mergeable. I can update it if preferred; otherwise I will avoid an unnecessary rebase. Please let me know if any changes are needed.

@saime428
saime428 changed the base branch from main to develop August 6, 2026 13:08
@saime428
saime428 requested a review from a team August 6, 2026 13:08
@saime428
saime428 force-pushed the fix/rsl-rl-play-obs-groups branch from eb49991 to 1249c55 Compare August 6, 2026 13:17
@saime428

saime428 commented Aug 6, 2026

Copy link
Copy Markdown
Contributor Author

Retargeted this PR from main to develop and rebased onto current develop. The fix and test commits are unchanged; I also added the changelog fragment that develop requires (source/isaaclab_rl/changelog.d/fix-rsl-rl-play-obs-groups.rst, patch tier) — that mechanism does not exist on main, so the PR was missing it.

I originally opened this against main, which is likely why it never went anywhere: in a month the only check that ever ran was labeler. docs/source/refs/contributing.rst (L53 on develop) still says "Submit a pull request to the main branch", which contradicts the PR template's "Target develop for all contributions" — that is what I followed. I've opened #6940 to fix that one line so the next contributor doesn't hit it.

The fix still applies on develop: both insertion points are unchanged there and obs_groups is still never defaulted, so #5363 still reproduces.

Verified locally against develop (source/isaaclab_rl/test/test_rsl_rl_cfg_deprecation.py):

  • with the fix — 42 passed
  • reverting only the utils.py hunk while keeping the tests — 2 failed, 40 passed, both being TestObsGroups::test_defaults_missing_obs_groups_for_on_policy_runner[4.0.0/5.0.0]

So the new tests do fail without the fix rather than passing vacuously. Happy to make any changes you'd like.

@saime428

saime428 commented Aug 18, 2026 •

Copy link
Copy Markdown
Contributor Author

@ooctipus @kellyguo11 could one of you take a look? This has had no maintainer review since it was opened on 2026-07-09.

Current state, re-checked today: retargeted to develop and rebased on 2026-08-06, still MERGEABLE, labeler green, and the develop-required changelog fragment is in (source/isaaclab_rl/changelog.d/fix-rsl-rl-play-obs-groups.rst).

It fixes #5363: with rsl-rl >= 4.0.0, OnPolicyRunner configs left obs_groups at its MISSING sentinel fail at runtime. The default is filled in by a new _set_default_obs_groups helper called from handle_deprecated_rsl_rl_cfg, so configs that already set obs_groups are untouched and nothing changes below rsl-rl 4.0. Happy to move it elsewhere if that placement is wrong.

kellyguo11 pushed a commit that referenced this pull request Sep 7, 2026
…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]>
isaaclab-bot Bot pushed a commit that referenced this pull request Sep 7, 2026
…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)
@saime428

saime428 commented Sep 8, 2026

Copy link
Copy Markdown
Contributor Author

Closing this to keep the queue clear rather than leave it sitting open.

The branch stays up and can be reopened if the fix is still wanted. It would need a rebase onto current develop first.

@saime428 saime428 closed this Sep 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working isaac-lab Related to Isaac Lab team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug Report] play.py hangs in OnPolicyRunner init with rsl-rl 4.0.0+ due to missing obs_groups

1 participant