[Backport release/3.0.0] Add TorchRL environment wrapper for isaaclab_rl (#7502) - #7920
Conversation
Adds `isaaclab_rl.torchrl.IsaacLabTorchRLWrapper`, a `torchrl.envs.EnvBase` implementation over Isaac Lab's batched environments, together with a `torchrl` extra, API docs, and tests. Validated on an A100-40GB (Isaac Sim 6.0, torchrl 0.13.3, 64 envs per task): | Check | Result | | --- | --- | | `test_torchrl_wrapper_specs.py` (kit-free) | passed | | `test_torchrl_wrapper.py` (first 5 registered tasks) | 2 passed | | Same checks over Ant, Ant-Direct, Cartpole, Cartpole-Direct, Cartpole-Camera, Cartpole-Camera-Direct, Humanoid-Direct, Velocity-Flat-AnymalD, Reorient-Cube-Shadow-OpenAI-FF-Direct | 9/9 OK, no NaNs, terminal observation reported on every done row | | Cartpole, 200 steps, vs `torchrl.envs.libs.isaac_lab.IsaacLabWrapper` | 12.5k env-steps/s with terminal observations on done rows; upstream 9.6k (`native_autoreset=True`) / 10.4k (`False`) with NaN next-observations on done rows | - [x] <!-- backport-active-release --> Backport this pull request to the active release branch after it merges into `develop` --------- Co-authored-by: Mustafa Haiderbhai <mhaiderbhai@nvidia.com>
|
run-ci |
|
| add_common_train_args( | ||
| parser, | ||
| agent_default="torchrl_cfg_entry_point", | ||
| agent_help="Name of the RL agent configuration entry point.", | ||
| include_distributed=False, | ||
| ) | ||
| parser.add_argument("--run_name", type=str, default=None, help="Run name suffix to the log directory.") |
There was a problem hiding this comment.
Checkpoint resume is unsupported
The unified TrainingRequest now accepts backend="torchrl" and forwards its documented checkpoint field as --checkpoint, but this parser does not register that option. The unknown argument is therefore forwarded to Hydra, while train_ppo always creates a fresh actor, critic, optimizer, and collector. A TorchRL resume request cannot restore the requested checkpoint and may fail during configuration processing instead of resuming training. Please implement checkpoint restoration, including the intended iteration and optimizer state, or explicitly reject checkpoint-bearing TorchRL requests before Hydra processes them.
Knowledge Base Used: Reinforcement learning integrations
| ["Isaac-Cartpole-Direct", "rl_games,rsl_rl,skrl,sb3,torchrl", "isaacsim_physx,newton_kamino,newton_mjwarp,ovphysx", "", "", "tasks/classic/cartpole.jpg", true], | ||
| ["Isaac-Cartpole", "rl_games,rsl_rl,skrl,sb3,torchrl", "isaacsim_physx,newton_kamino,newton_mjwarp,ovphysx", "", "", "tasks/classic/cartpole.jpg", true], |
There was a problem hiding this comment.
These generated rows advertise TorchRL support, and the browser exposes it in the selector and generates the correct command. However, the RL capability-symbol table has no torchrl entry, so Cartpole task cards omit the TorchRL capability badge. This is a non-blocking visual inconsistency that makes the new integration less discoverable; add TorchRL to capabilitySymbolSets.
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
There was a problem hiding this comment.
Isaac Lab Review Bot
The TorchRL wrapper, PPO runner, unified train/play integration, Cartpole configuration, terminal-observation conversion, documentation, and tests are coherently connected. One dependency-resolution issue remains: adding the optional TorchRL extra upgrades the workspace-wide TensorDict version for base installations.
- Design and architecture: TorchRL-specific spec conversion, auto-reset handling, and terminal-observation substitution remain isolated in the new backend, while the shared MARL adapter exposes concatenated final observations without mutating per-agent extras. However, the optional integration currently changes a shared base dependency through the lockfile, expanding its compatibility impact beyond TorchRL users.
- API: The additive public surfaces are consistent: the backend literal and dispatch registrations, lazy package exports, Cartpole agent entry points, optional extra, API documentation, and changelog fragments align. The remaining concern is dependency compatibility rather than the exposed TorchRL API.
- Implementation: The wrapper and training/playback paths align with Isaac Lab’s in-step reset semantics, including enabling and consuming terminal observations. Regression coverage exercises timeout handling, environment specs, MARL final-observation conversion, and unbatched action bounds. Before merge, constrain the TorchRL dependency graph to preserve the release branch’s TensorDict version or explicitly validate the existing base stack against TensorDict 0.14.2.
Minor fixes needed. Posted 1 actionable finding inline.
Automated review; human maintainers own approval decisions.
| [[package]] | ||
| name = "tensordict" | ||
| version = "0.13.0" | ||
| version = "0.14.2" |
There was a problem hiding this comment.
🟡 Warning · Design Architecture — Optional extra upgrades shared tensordict version
Resolving torchrl>=0.13 pulls torchrl 0.14.0, and the lock moves tensordict from 0.13.0 to 0.14.2 for the entire workspace. tensordict is used on base install paths (the RSL-RL wrapper returns TensorDict observations and its tests import it unconditionally), so users who never select --extra torchrl get the upgrade on a release branch. Bound the extra (for example >=0.13,<0.14) or confirm the base stack against tensordict 0.14.
Description
Backports #7502 to
release/3.0.0.This adds
isaaclab_rl.torchrl.IsaacLabTorchRLWrapper, TorchRL PPO training and playback entrypoints, thetorchrldependency extra, Cartpole agent configuration, API and workflow documentation, and the original regression coverage and changelog fragments. It also preserves the terminal-observation fix for converted multi-agent environments.The merged source commit
5c91e9b1e3c79933b3e62c494fb596ab7b7031ddwas applied onto release commitbe270ed88bbc0ea46201ce5cdd4cd0a502971cbc. The only conflict was inuv.lock; it was resolved using the package versions from the release manifests while retaining the new TorchRL dependency graph.uv lock --checkpasses.Type of change
Release backport
This pull request targets
release/3.0.0directly; no further backport is requested.Validation
uv lock --check: passed.uv run isaaclab -f: all formatting, lint, metadata, and repository hooks passed. The changelog hook was run separately againstrelease/3.0.0because its default base isdevelop.uv run --isolated --extra dev -- make -C docs current-docs. The release branch places Sphinx in thedevextra rather than thetestextra.git diff --check: passed.Screenshots
Not applicable.
Checklist
CONTRIBUTORS.md