Repository navigation
[MDP2 bug fix] Select the registered RL library of experimental MDP2 tasks by default #9219
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 3 commits
cb73c0e
ef4c10f
bb4cadc
303938e
53362a6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| * Selected the registered default RL library of experimental tasks, such as ``Isaac-Cartpole-MDP2``, when | ||
| ``--rl_library`` is not given. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -660,6 +660,18 @@ def test_dispatch_uses_task_registered_default_backend(monkeypatch) -> None: | |
| assert received == {"module_name": "isaaclab_rl.entrypoints.backends.train_rsl_rl", "argv": ["--task", task_name]} | ||
|
|
||
|
|
||
| def test_dispatch_finds_the_default_backend_of_experimental_tasks() -> None: | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🟡 Warning · Test Quality — Mark the regression kitless This regression needs no Isaac Sim runtime, but its file has no kitless marker, so kitless CI selection misses it. Mark the test pytest.mark.kitless.
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The only CI job that selects tests by the |
||
| """Tasks of the optional experimental task package also select their registered default backend.""" | ||
| pytest.importorskip("isaaclab_tasks_experimental") | ||
| # A fresh process, so that no earlier import has registered the experimental tasks. | ||
| code = ( | ||
| "from isaaclab_rl.entrypoints.dispatch import _resolve_default_library\n" | ||
| "print(_resolve_default_library(['--task', 'Isaac-Cartpole-MDP2'], {'rsl_rl': ''}))" | ||
| ) | ||
| result = subprocess.run([sys.executable, "-c", code], capture_output=True, text=True, check=True) | ||
| assert result.stdout.strip().splitlines()[-1] == "rsl_rl" | ||
|
|
||
|
|
||
| def test_dispatch_fuses_option_like_kit_args(monkeypatch) -> None: | ||
| """Space-separated option-like Kit arguments are fused before backend parsing.""" | ||
| received: dict[str, object] = {} | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -52,10 +52,11 @@ def test_mdp2_environment_resets_and_steps(task_name): | |
| env.close() | ||
|
|
||
|
|
||
| @pytest.mark.parametrize("disabled", [None, "action_rate"]) | ||
| @pytest.mark.parametrize("disabled", [None, "action_rate", "joint_vel"]) | ||
| def test_reach_curriculum_sets_reward_weights_at_first_reset_after_threshold(disabled): | ||
| """The Reach curriculum keeps its reward weights until the first reset after its step threshold, then sets them | ||
| in every world, from a captured step. It leaves out a reward that the task disables.""" | ||
| in every world, from a captured step. It leaves out a reward that the task disables, and every other weight as | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🟡 Warning · Style Consistency — State the weight invariant plainly “And every other weight as it is” obscures the new whole-tensor assertion. Say that non-target reward weights remain unchanged.
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Reworded: the docstring now says the test skips a disabled reward and leaves every other weight unchanged. (303938e) |
||
| it is.""" | ||
| task_name = "Isaac-Reach-Franka-MDP2" | ||
| env_cfg, _ = resolve_task_config(task_name, None, overrides=["physics=newton_mjwarp"]) | ||
| env_cfg.sim.device = "cuda:0" | ||
|
|
@@ -73,10 +74,10 @@ def test_reach_curriculum_sets_reward_weights_at_first_reset_after_threshold(dis | |
| indices = {op.use: op.index for op in unwrapped.mdp.ops[mdp2.Phase.REWARDS]} | ||
| names = [name for name in ("action_rate", "joint_vel") if name != disabled] | ||
| assert f"rewards.{disabled}" not in indices | ||
| columns = [indices[f"rewards.{name}"] for name in names] | ||
| weights = unwrapped.state.reward_weights.torch | ||
| initial = weights[:, columns].clone() | ||
| final = torch.tensor([getattr(env_cfg, f"curriculum_{name}") for name in names], device=unwrapped.device) | ||
| initial, final = weights.clone(), weights.clone() | ||
| for name in names: | ||
| final[:, indices[f"rewards.{name}"]] = getattr(env_cfg, f"curriculum_{name}") | ||
|
|
||
| env.reset(seed=0) | ||
| actions = torch.zeros(env.action_space.shape, device=unwrapped.device) | ||
|
|
@@ -87,8 +88,8 @@ def test_reach_curriculum_sets_reward_weights_at_first_reset_after_threshold(dis | |
| early_reset |= resetting and step <= env_cfg.curriculum_after_steps | ||
| if applied_at is None and resetting and step > env_cfg.curriculum_after_steps: | ||
| applied_at = step | ||
| expected = final.expand_as(initial) if applied_at is not None else initial | ||
| torch.testing.assert_close(weights[:, columns], expected, msg=f"weights after step {step}") | ||
| expected = final if applied_at is not None else initial | ||
| torch.testing.assert_close(weights, expected, msg=f"weights after step {step}") | ||
| assert early_reset and applied_at is not None | ||
| # Steps after the first replay the captured graphs, so the curriculum ran inside one. | ||
| assert applied_at > 1 and unwrapped.num_graphs > 0 | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🟡 Warning · Implementation — Do not hide registration failures
Suppressing every ImportError also hides failures inside an installed experimental package. Its tasks then appear unregistered and dispatch reports a missing backend. Ignore only absence of the top-level package.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This matches the import in all ten train and play backends (for example
train_rsl_rl.py), which guard the optional package with the samecontextlib.suppress(ImportError), so dispatch and the selected backend see the same registered tasks. Changing how the optional package is detected would be a separate change across all eleven sites, so this stays as is.