Repository navigation
Add isaaclab_neural integration for Newton neural robot dynamics - #9200
Conversation
Adds the isaaclab_neural extension, generic scripts under scripts/neural (record.py, train.py, evaluate.py), task presets and recipes for Franka Reach, ANYmal C Flat, and Allegro Hand Reorient, documentation, and CI/wheel-builder wiring backed by newton-physics/newton-neural. Signed-off-by: Mehdi Ataei <[email protected]>
There was a problem hiding this comment.
Isaac Lab Review Bot
Needs attention: Design and architecture (2), Scope and over-engineering (4), API (1), Compatibility and deprecation (4), Implementation (3), Style consistency (5), Test quality (3).
- PR description: Correct the CI extra-installation claim; provide baseline/candidate evidence for Allegro’s claimed MuJoCo-equivalent step cost, including revisions, workload command, hardware, backend, environment count, warmup, and step-time metric.
- Design and architecture: Solver construction hides backend and cached-model dependencies behind SimulationContext; pass resolved resources from the construction owner instead.
- Scope and over-engineering: Minimal implementation: extend NewtonManager/NewtonSolver and task preset owners; keep all three scripts, both package export pairs, shared recipe runtime/configuration modules, both solver adapter/configuration pairs, timing manager, three task-local recipe pairs, and nerd_test_utils.py for their lifecycle, polymorphism, or configuration contracts; delete RecordingEventsCfg and redundant copies, and cache regime scales. Suggested PR breakdown: (1) solver integration and presets, validating timing/reset contracts; (2) recipes and recording/training, validating datasets/checkpoints; (3) evaluation and workflow documentation, validating scoring.
- API: Recording restart inputs omit shapes, units, quaternion ordering, and floating-base velocity frames; document these contracts so callers can construct valid frames.
- Compatibility and deprecation: Breaking changes: navigation’s nested preset alternatives disappear, and ANYmal task/agent fields plus Allegro’s experiment name become preset containers; preserve old access through targeted warnings, migration/removal guidance, and transition coverage.
- Implementation: Evaluation weights metrics containing later episode endings as first-episode metrics, corrupting comparisons; collect per-environment metrics at each environment’s first ending.
- Style consistency: Missing-policy notices and workflow status bypass logging; configure console logging before work and use logger.warning for notices and logger.info for progress.
- Test quality: Recipe construction replays and module-name inventories assert identity or layout rather than distinct behavior; remove them while retaining recording integration and optional-dependency boundary checks.
Significant concerns. Posted 22 inline findings.
Automated review; human maintainers own approval decisions.
| for key, value in extras["log"].items(): | ||
| if key.startswith("Metrics/"): | ||
| name = key.removeprefix("Metrics/") | ||
| metrics[name] = metrics.get(name, 0.0) + float(value) * count |
There was a problem hiding this comment.
🔴 Critical · Implementation — Exclude later episodes from metrics
After an early reset, extras['log'] can average that environment's later ending with another environment's first ending. Weighting it by first endings corrupts the reported metric. Collect metrics per environment at its first ending.
| .. literalinclude:: ../../../source/isaaclab_tasks/isaaclab_tasks/contrib/velocity/config/anymal_c/flat_env_cfg.py | ||
| :language: python | ||
| :start-at: # ``physics=newton_nerd`` steps the robot | ||
| :end-at: self.events.base_com = preset( |
There was a problem hiding this comment.
🟡 Warning · Implementation — Complete both included preset calls
This :end-at: stops the ANYmal excerpt at an opening preset(, and the RSL-RL excerpt has the same problem. Extend both includes through their closing calls.
| * - ``rsl_rl``, ``rl_games``, ``skrl``, ``stable_baselines3`` | ||
| - ``rsl_rl`` is installed by default. Select ``rl-games``, ``skrl``, or ``sb3`` | ||
| for the other frameworks, for example ``uv run --extra skrl isaaclab train ...``. | ||
| * - ``newton_neural`` |
There was a problem hiding this comment.
🟡 Warning · Style Consistency — Synchronize troubleshooting guidance
This page explicitly requires corresponding updates to skills/user/setup-troubleshooting/. Its new optional-dependency guidance has no matching change there; update the skill.
| seconds += task.step_dt * running | ||
| ended = running & dones.bool() | ||
| running &= ~ended | ||
| count = int(ended.sum()) |
There was a problem hiding this comment.
🟡 Warning · Scope Complexity — Defer scoring scalar transfers
int(ended.sum()) synchronizes CUDA on every scoring step, and termination counts add transfers. Accumulate device counters and transfer them when producing the report.
| folder = Path("logs/rsl_rl") / agent_cfg.experiment_name | ||
| run = trained_run(folder, physics_classes(to_dict(trained_cfg.sim)["physics"])) if folder.is_dir() else None | ||
| if run is None: | ||
| print(f"No policy trained with physics={preset} yet, {folder} holds no run on it that saved a policy.") |
There was a problem hiding this comment.
🟡 Warning · Style Consistency — Log missing-policy notices
A missing policy is a user-facing warning, but print bypasses configured logging. Configure console logging before lookup and emit the notice through logger.warning.
|
|
||
| self.max_iterations = 300 | ||
| self.experiment_name = "anymal_c_flat" | ||
| self.experiment_name = preset(default="anymal_c_flat", newton_nerd="anymal_c_flat_nerd") |
There was a problem hiding this comment.
🟡 Warning · Compatibility — Preserve concrete ANYmal agent fields
Constructed experiment_name and clip_actions now expose preset containers instead of their former string and numeric values. Direct consumers break; retain the old values through a documented, warned transition covering both paths.
| actuator_effort_limit=legs.actuator_effort_limit, | ||
| actuator_velocity_limit=legs.actuator_velocity_limit, | ||
| ) | ||
| self.scene.robot.actuators["legs"] = preset(default=legs, newton_nerd=pass_through) |
There was a problem hiding this comment.
🟡 Warning · Compatibility — Preserve direct ANYmal field access
The actuator, clip, and event fields now expose preset containers where constructed configurations formerly exposed actuator settings, None, and event terms. Preserve direct access through a documented, warned transition.
| ) | ||
| self.scene.robot.actuators["legs"] = preset(default=legs, newton_nerd=pass_through) | ||
| # The joint targets [rad] stay within the range that the model was recorded on, whatever sets the actions. | ||
| reach = AnymalCFlatNeRDRecipeCfg().target_reach |
There was a problem hiding this comment.
🟡 Warning · Implementation — Keep clipping tied to recorded reach
Recording accepts a target_reach override, but the task's clipping range comes from a new default recipe. A differently recorded model can receive out-of-range targets; derive both from one resolved setting.
| max_iterations = 5000 | ||
| save_interval = 50 | ||
| experiment_name = "allegro_hand" | ||
| experiment_name = preset(default="allegro_hand", newton_mjwarp_nerd="allegro_hand_mjwarp_nerd") |
There was a problem hiding this comment.
🟡 Warning · Compatibility — Preserve Allegro's experiment string
AllegroHandManagerPPORunnerCfg().experiment_name is now a preset container rather than 'allegro_hand'. Direct path and runner consumers lose the string contract; retain it through a documented, warned transition.
| choice = torch.randint(len(scales), (hand_count, joint_count // finger_joint_count), device=device) | ||
| together = torch.rand(hand_count, 1, device=device) < 0.5 | ||
| choice = torch.where(together, choice[:, :1], choice) | ||
| scale = torch.tensor(scales, device=device)[choice].repeat_interleave(finger_joint_count, dim=1) |
There was a problem hiding this comment.
🟡 Warning · Scope Complexity — Reuse device regime scales
Every CommandHandTargets.next call rebuilds the same scales tensor on device. Construct the sampler's and command's scale tensors once and reuse them during sampling.
[Medium impact] The PR appears safe to merge; no new actionable issue was confirmed. SummaryAdds optional neural robot dynamics through
This review checked source paths and tests; it did not run simulations or tests. Diagram%%{init: {'theme': 'neutral'}}%%
flowchart LR
A[Task recording configuration] --> B[Ordinary environment steps]
B --> C[RecorderManager hooks]
C --> D[Native trajectory dataset]
D --> E[Offline model training]
E --> F[Checkpoint]
F --> G[Newton solver adapter]
G --> H[Policy training or playback]
H --> I[Shared bounded evaluation]
Reviews (2) · Last reviewed commit: "Resolve presets in LEAPP export test con..." · Reviewed by Greptile |
| trained = { | ||
| preset: resolve_task_config(args.task, AGENT_ENTRY_POINT, overrides=[f"physics={preset}"]) | ||
| for preset in presets | ||
| } |
There was a problem hiding this comment.
Custom policy settings are dropped
evaluate.py discards agent overrides when building the configurations used to load policies. A Franka policy trained with agent.actor.hidden_dims=[128,128] is loaded into the default [64,64] actor, so loading fails. Passing the matching override to evaluation does not help: it only reaches the discarded agent configuration on line 157.
Restore each run's saved params/agent.yaml, or pass the requested agent overrides into the configurations actually used by OnPolicyRunner.
|
Could we make the dependencies of Simplified current flow: # Manager loads and caches the learned model.
self._initial_nerd = ...
# Existing Newton construction creates the adapter.
adapter = NeRDSolver(cfg, model, mode, env_template)
# Inside the adapter:
manager = SimulationContext.instance().backend_manager
nerd = manager.pop_initial_nerd(cfg.checkpoint)
solver = SolverNeRD(model, nerd, ...)
check_task(solver) # Also reads the global simulation context.
forget_setup_changes() # Clears backend.model_changes.Could the existing construction path instead pass the loaded model and required values explicitly? For example, with illustrative internal arguments: # Construction owner resolves the dependencies.
nerd = load_nerd(cfg.checkpoint, "cpu")
adapter = NeRDSolver(
cfg, model, mode, env_template,
nerd=nerd,
solver_dt=solver_dt,
)
# Inside the adapter:
solver = SolverNeRD(model, nerd, ...)
check_task(solver, solver_dt=solver_dt)The backend should retain ownership of processing pending model changes. The user-facing cfg can stay unchanged; this is a cleanup of construction and ownership within the existing Newton integration. |
ooctipus
left a comment
There was a problem hiding this comment.
Evaluation configuration and reuse of the existing RSL-RL play pipeline.
| env_cfg, _ = resolve_task_config(args.task, AGENT_ENTRY_POINT, play_mode=True, overrides=overrides) | ||
| trained = { | ||
| preset: resolve_task_config(args.task, AGENT_ENTRY_POINT, overrides=[f"physics={preset}"]) | ||
| for preset in presets | ||
| } |
There was a problem hiding this comment.
Could we follow the existing RSL-RL play pipeline here and preserve the caller's full configuration?
The first resolve_task_config(..., overrides=overrides) resolves the caller's settings but discards its agent configuration. These subsequent calls replace the override list with only physics=<preset>, so agent.* overrides and domain selections such as presets=... never reach the runner. For example, a policy trained with custom actor dimensions cannot be loaded even when evaluation receives the matching override.
Standard play resolves environment and agent together and retains that agent configuration:
env_cfg, agent_cfg = resolve_task_config(
args.task,
AGENT_ENTRY_POINT,
play_mode=True,
overrides=overrides,
)
# After constructing the evaluation environment:
env = RslRlVecEnvWrapper(env, clip_actions=agent_cfg.clip_actions)
runner = create_rsl_rl_runner(env, agent_cfg, inference=True)
runner.load(checkpoint, map_location=env.unwrapped.device)For cross-physics evaluation, please make training physics and evaluation physics explicit: resolve the policy configuration with training physics and the environment configuration with evaluation physics, preserving domain presets and agent overrides in both resolutions and replacing only the physics selector. Use the training resolution's agent_cfg for runner construction and the evaluation resolution's env_cfg for environment construction.
I would simplify this to one explicitly selected checkpoint and training-physics preset per invocation, with comparisons invoking the same evaluation path. That avoids a separate policy-discovery/configuration pipeline. Please also reuse create_rsl_rl_runner(..., inference=True), as standard play and the RSL-RL benchmark do, rather than constructing OnPolicyRunner directly.
A focused regression should evaluate a policy with non-default actor dimensions and a domain preset, including when the evaluation physics differs from the training physics. Automatically restoring saved agent.yaml would be a separate reproducibility improvement; it is not required to match the current play convention.
#9202) # Description Improves 4,096-env `IsaacContrib-NIST-Franka` (20-variant) PPO training throughput by **~31% (`1.31x`)** with exact dynamic physics and zero solver overflows via two targeted changes: 1. **Expose `include_static_kinematic_pairs` on `NewtonCollisionPipelineCfg` and disable it in `NISTEnvCfg`** - Newton's `CollisionPipeline` already supports `include_static_kinematic_pairs: bool = True` to filter static–kinematic and kinematic–kinematic pairs in the broadphase, but `NewtonCollisionPipelineCfg` did not yet expose it. - In `NISTEnvCfg`, `ground` is static while `table`, `nistboard`, and `fixed_asset` (bolts/sockets/gear bases) are kinematic (`kinematic_enabled=True`). Because they rest against each other (`ground ↔ table`, `table ↔ nistboard`, `nistboard ↔ fixed_asset`, `table ↔ fixed_asset`), Newton's 256³ SDF narrowphase was generating **~63% of all scene contacts** (`311.7k` total vs `114.1k` dynamic) that MuJoCo Warp immediately discards because two immovable bodies cannot exert constraint impulses on each other. - Setting `include_static_kinematic_pairs=False` in `NISTEnvCfg` removes only immovable-vs-immovable pairs while keeping **100% of dynamic contacts** untouched — including the `assembly_contact` sensor between the dynamic `HeldAsset` and kinematic `FixedAsset`. The default remains `True` on `NewtonCollisionPipelineCfg`, so no other task changes behavior. 2. **Right-size MJWarp solver capacities in `NISTEnvCfg` (`njmax: 3000 → 1024`, `nconmax: 600 → 256`)** - Across all 20 variants (all 140/140 reset-accumulator cells, including gear meshes, full 8,192-state precollection, and 5 PPO rollout iterations at 4,096 envs), measured runtime peaks were `nefc_peak = 283` (max `311` across runs) and `nacon_per_world_peak = 165`, with `overflow_max = 0`. - `njmax=1024, nconmax=256` matches pyramidal friction cone scaling (`4 × 256 = 1024`) with ~3.3–3.6× headroom on constraint rows and ~1.55× headroom on per-world contacts while significantly reducing MJWarp solver memory bandwidth. ## Benchmark (`IsaacContrib-NIST-Franka`, 4,096 envs, 20 variants, RTX PRO 6000 Blackwell MIG 2g.48gb) | Configuration | Uninstrumented PPO Iter | Rollout Collection (32 steps) | Throughput | Reset Precollect (4,096) | Newton SDF Contacts (mean) | MJWarp Contacts (mean) | Peak `nefc` / `nacon` | Overflows | |---|---:|---:|---:|---:|---:|---:|---:|---:| | Stock `main` (`include_sk=True`, `3000/600`) | 3,876 ms | 3,434 ms | 33.8k steps/s | ~6.9 s | 311,694 | 114,057 | 291 / 151 | 0 | | `include_sk=False` only (`3000/600`) | 3,662 ms (+5.9%) | 3,234 ms | 35.8k steps/s | ~5.4 s | 114,682 | 114,682 | 231 / 165 | 0 | | `include_sk=False` + `1536/300` | 3,172 ms (+22.2%) | 2,749 ms | 41.3k steps/s | ~5.0 s | 115,149 | 115,149 | 311 / 148 | 0 | | **This PR (`include_sk=False` + `1024/256`)** | **2,963 ms (+30.8%)** | **2,537 ms (+35.4%)** | **44.2k steps/s** | **~5.0 s** | **115,487 (2.7× fewer)** | **115,487** | **292 / 143** *(8,192-table 5-iter stress: 283 / 165)* | **0** | ## Type of change - New feature (non-breaking change which adds functionality) - Performance improvement (exact physics; default behavior unchanged outside NIST) ## Validation - Added behavioral GPU test `test_collision_cfg_filters_static_and_kinematic_pairs` in `source/isaaclab_newton/test/physics/test_newton_manager.py` verifying that `include_static_kinematic_pairs=False` removes static–kinematic and kinematic–kinematic pairs while preserving dynamic–kinematic contacts. - Passed all 80 tests in `source/isaaclab_newton/test/physics/test_newton_manager.py` and `source/isaaclab_tasks/test/contrib/test_nist_reset_monitor.py`. - Stress-tested `IsaacContrib-NIST-Franka` at 4,096 envs with full `state_table_size=8192` (140/140 joint cells populated) and 5 PPO iterations: `nefc_peak=283`, `nacon_per_world_peak=165`, `overflow_max=0`. - Passed `ruff check`, `ruff format --check`, and `git diff --check`. ## 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 formatting and lint checks (`ruff check` / `ruff format --check`) - [x] I have made corresponding changes to the documentation - [x] My changes generate no new warnings - [x] I have validated the changed behavior with focused coverage - [x] I have added a changelog fragment under `source/<pkg>/changelog.d/` for every touched package - [x] My name is included in `CONTRIBUTORS.md` (via #9200) Signed-off-by: Mehdi Ataei <[email protected]>
The manager change this test covered was reverted when the recording environments adopted observation configuration objects with no groups, so the test failed on an AttributeError.
The browser was regenerated without the fovi extra, which dropped the IsaacContrib-Cartpole-Camera-Fovi row. Regenerating with the extra installed returns the file to its state on main.
Drop the source scan for files and names of earlier drafts, the mocked playback wiring test that counted configuration resolutions, and the private action-handling call-shape assertions for code this change no longer touches. Episode scoring keeps its behavioral test.
File export through the recorder manager materialized one episode per environment in Python and wrote one shard per step that had resets. The dynamics recorder term now buffers frames for all environments and writes them through the native trajectory writer as one contiguous stream per environment, marking episode starts from resets. The per-episode file handler and the manager property that exposed it are no longer needed. Recording loop at 4096 environments, before and after: Allegro, 40 steps: 19.1 s to 1.2 s. Franka, 200 steps: 4.3 s to 2.1 s. ANYmal C, 200 steps: 7.8 s to 7.2 s.
Recording constructed the model and saved it untrained in the dataset, so changing the architecture meant recording again. The dataset now describes the recorded robot, its contact input and its physical-model contract, and training builds the task's model definition on that description. model.<field> overrides configure the definition in both entrypoints. The settings that select recorded signals are checked against the dataset, and the recorder term binds its own robot instead of being wired by the entrypoint.
The fragments announced classes, a manager and an evaluation script that earlier drafts of this change removed, followed by entries that removed them again. Each package now carries the entries of its net change, including the task configuration fields that became preset alternatives.
The major markers of isaaclab_tasks and isaaclab_neural belonged to entries about earlier drafts of this change, and would have released isaaclab_tasks 32.0.0 and the new package as 1.0.0. The remaining minor markers cover the new presets and the new package. The backend change in isaaclab_newton adds no public API, so it takes the default patch tier.
The package README still credited a removed manager and described an evaluation flow that no longer exists, and the how-to carried a migration section for an API that never shipped along with statements about what the implementation does not do.
The shared Reach and locomotion physics declarations offer the neural preset to every task and leave its checkpoint unset. A required field left unset raised TypeError during validation, which preset enumeration does not treat as a rejected combination, so the environment documentation updater crashed. An empty checkpoint is now a ValueError that says the task declares no model.
The later commits on this branch added four more entries that describe one draft relative to another. The task entry now states where the neural presets are declared and which fields became preset alternatives, and the package README says where task composition lives.
Folding the neural preset into the shared Reach physics dropped the checks that tied it to the joint-position action and excluded holding. The arm model was then accepted with the hold gains, the inverse kinematics actions and the operational space task, none of which it was recorded with.
The recording environments copied timing, actuators, events and robot properties from the unresolved task, so presets=newton_nerd recorded MuJoCo Warp at the model frame with the pass-through actuators, and presets=diffik recorded a gravity-compensated arm. The task is now resolved on its reference solver first; only the numerical solver remains a choice of a recording.
AGENTS.md routes to the contribution guide, which owns shared rules and already carries the neural design guidance. The section duplicated it with rules specific to one feature.
The rule sat in the general refactoring guidance but described one feature, and it no longer matched the code: the solver adapters load their own checkpoints during construction.
|
run-ci |
|
run-ci |
|
run-ci |
Main's isaaclab_neural now holds NeRD, a learned solver inside the Newton backend (isaac-sim#9200). The world-model backend joins it as the package's second part: the package docstring and README describe both, physics exports the solvers and the world-model backend, and the package keeps main's version, dependencies and CI job. The world-model tests follow main's import order.
Description
Adds
isaaclab_neuralto run Newton tasks on neural robot dynamics from newton-neural. Tasks record trajectories through the existing RecorderManager, fit dynamics models offline, and select learned physics through ordinary task presets.Summary of Changes
NeRDSolverCfgfor standalone dynamics andMJWarpNeRDSolverCfgfor free-motion coupling inside MuJoCo Warp. Both use the existingNewtonManager,NewtonBackend, and solver-construction path.sim.dt, withdecimation=1andnum_substeps=1, preserving the environment control period. Free-motion coupling retains its numerical substeps. Native stepping rejects a timestep that differs from the checkpoint frame.NeRDCfg, independentNeRDTrainingCfg, and separate recording environment configurations, with independent registry entries.scripts/neural/record.pyandtrain.pyown dynamics collection and offline fitting, including early task configuration resolution. The neural library has no task registry dependency or preset selection. Policy training and playback use existing RL entrypoints. Bounded policy scoring usesisaaclab play --rl_library rsl_rl --evaluate; there is no neural-specific policy evaluator or second preset-resolution path.newton_nerd), ANYmal C flat (newton_nerd), and Allegro reorientation (newton_mjwarp_nerd).newton-neuralextra pinned to06da4d2a604f3dbb48127a9010c41511cdd37a32, dependency licensing, wheel metadata handling, Docker/CI integration, API reference, how-to documentation, and package changelog fragments. Task configurations remain importable without the optional library.Configuration layout
Task composition and its integration tests live in scripts and
isaaclab_tasks/test/neural; library unit tests enforce import isolation and prohibit task resolution. CI includes the relocated integration tests.Models do not contain recording, training or inference workflow configuration. Recorder terms capture complete transitions before automatic reset; the output handler exports independent episodes with invalid padding. Checkpoints require Isaac Lab physical-model metadata. Standalone learned dynamics use the standard Newton collision lifecycle, including scenes without contact sensors.
Validation
Latest structural changes:
Earlier validated changes:
Checklist