Repository navigation
[Newton] Redesign Newton Manager [2d-ii/N] - #8946
Conversation
014c789 to
9efdaab
Compare
[High impact] The change reaches Newton's shared solver interface and the workflows built on it. Fix the teapot demo's custom solver override before merging. Findings
SummaryChanges
Diagram%%{init: {'theme': 'neutral'}}%%
flowchart LR
C[Solver configuration] --> D[NewtonSolver instance]
B[NewtonBackend.solver_ops] --> D
D --> N[Native Newton solver]
B2[NewtonBackend.solver] --> N
D --> E[Child solver drivers for couplers]
E --> EN[Child native solvers]
Reviews (1) · Last reviewed commit: "Build NewtonSolver as a driver of one so..." · Reviewed by Greptile |
There was a problem hiding this comment.
Isaac Lab Review Bot
Needs attention: Scope and over-engineering (1), Compatibility and deprecation (1), Implementation (1). Other reviewed categories look good.
- PR description: Title and body match the 29-file solver-driver migration, identify the breaking extension change, and list targeted validation; no measurable performance claim or material new hot-path cost needs benchmark evidence.
- Design and architecture: Architecture looks good.
- Scope and over-engineering: Minimal implementation: keep NewtonSolver, NewtonBackend, solver subclasses, and couplers as owners; no source modules were added. Keep fixed_tendon_control class-level and bind it directly in Articulation, deleting the avoidable callback and binder. Remaining flow is configuration to driver to native solver. Scope is cohesive; no split recommended.
- API: API changes look good.
- Compatibility and deprecation: Breaking changes: NewtonSolver and CouplerSolver extension hooks gained incompatible instance signatures without deprecation shims, warnings, transition coverage, or removal guidance; preserve old calls through the required deprecation window.
- Implementation: Subclass drivers inherit self.cfg as NewtonSolverCfg, so solver-specific field accesses fail static checking; annotate cfg with each subclass’s concrete configuration type.
- Style consistency: Style consistency looks good.
- Test quality: Test quality looks good.
Significant concerns. Posted 3 inline findings.
Automated review; human maintainers own approval decisions.
|
[P2] Update the solver-extension guide for the instance API The developer guide still says the Isaac Lab solver is never instantiated and every hook is a classmethod (lines 48–52). Its extension contract also gives the old Suggested patch for --- a/docs/source/developer-tools/extending_newton_solvers.rst
+++ b/docs/source/developer-tools/extending_newton_solvers.rst
@@ -45,11 +45,11 @@
:class:`~isaaclab_newton.physics.NewtonBackend` holds everything bound to one finalized model and initializes, steps
and queries it (``init_solver``, ``step``, ``forward``, ``invalidate_fk``, ...), so backends with different solvers can
be built and stepped side by side. The :class:`~isaaclab_newton.physics.NewtonManager` runs one backend through the
-Isaac Lab lifecycle. The backend's solver
-(:attr:`NewtonBackend.solver <isaaclab_newton.physics.NewtonBackend>`) is Newton's solver, built with
-``solver_cfg.class_type.build(solver_cfg, model, mode)``. The Isaac Lab solver is never instantiated and holds no state:
-each method is a class method that takes the configuration and Newton's solver. A coupled solver builds each entry's
-Newton solver through the entry's own Isaac Lab solver.
+Isaac Lab lifecycle. The backend's driver (``NewtonBackend.solver_ops``) is built with
+``instantiate(solver_cfg, model, mode, env_template)`` and stores the configuration as ``cfg`` and Newton's solver as
+``native``. The backend's solver
+(:attr:`NewtonBackend.solver <isaaclab_newton.physics.NewtonBackend>`) is that native Newton solver. A coupled solver
+keeps one driver per entry, built from the entry's own configuration.
.. list-table::
:header-rows: 1
@@ -187,10 +187,11 @@
iterations: int = 16
-``MySolver.build(cfg, model, mode, env_template)`` returns Newton's solver. Every method is a class method:
-methods called before the model exists take the configuration, and the rest also take Newton's solver, e.g.
-``MySolver.reset(cfg, solver, state, world_mask)``. State a solver needs between steps belongs on Newton's
-solver. Override only what differs:
+``MySolver(cfg, model, mode, env_template)`` constructs the driver and calls
+``build(self, model, mode, env_template)`` to create Newton's solver. Override solver-bound hooks as instance
+methods, e.g. ``reset(self, state, world_mask)``, and access configuration through ``self.cfg`` and Newton's solver
+through ``self.native``. State needed between steps can live on the driver. Builder-time hooks and
+``fixed_tendon_control`` remain classmethods and take the configuration. Override only what differs:
.. list-table::
:header-rows: 1 |
|
@AntoineRichard Updated the solver extension guide for the instance API in f79f16e. |
|
run-ci |
## Description Use Newton's `CONTACT_F` solver observables for Isaac Lab contact sensors with MuJoCo, XPBD, VBD, Kamino, and Steel. The backend allocates the solver output when a contact sensor is registered, requests it on the final solver substep of the environment step, and passes it to the sensor. Native collision detectors receive a `Contacts` buffer for observable contact indexing. Late sensor registration invalidates captured step graphs. Newton deprecated `Contacts.force` and `solver.update_contacts()` in version 1.7. Isaac Lab no longer uses that path for contact sensors. Featherstone and implicit MPM do not provide `CONTACT_F` in the pinned Newton version, so contact-sensor registration reports that limitation directly. The changelog fragment records this until Newton adds support. This PR contains no Steel solver or task presets and no contact-capacity change. [#8940](#8940) adds Steel; [#8957](#8957) independently aligns explicit contact capacity. ## Base Rebased on `main` at `bb4d9915f`, which includes [#8953](#8953) (Newton 1.9 and MuJoCo/MuJoCo Warp 3.17) and [#8946](#8946) (Newton manager redesign). The solver observable changes use the new instance-based solver interface. ## Validation - On `bb4d9915f`: the Newton manager, Newton solver, and contact-sensor test files passed with 119 passed and 3 existing skips. Resting-contact cases cover both MuJoCo collision paths, XPBD, VBD, and Kamino with both collision paths. - Pre-commit hooks, changelog gate, and diff whitespace checks passed. - Follow-up `90e1f74d9`: 4 coupled-solver runtime tests and 56 Newton manager tests passed locally. [Activated Docker + Tests CI](https://github.com/isaac-sim/IsaacLab/actions/runs/42301974155) passed, including `isaaclab_assets` and contrib environments.
# Description Part 3 of the Newton manager redesign ([overview](#8218 (comment))). Follows [2d-ii/N] #8946 (merged). The environment's control now runs inside the Newton step. When every action term and every asset that writes to the simulation can be recorded, the Newton step handles them: each physics step of the captured decimation loop applies the actions and writes the assets before the Newton actuators, as the environment's own loop does. One `env.step` then makes one physics call instead of `decimation` calls. ## Changes - **`handle_actions`.** `PhysicsManager.handle_actions(actions, scene)` returns `False` by default. `NewtonManager.handle_actions` registers `ActionManager.apply_action` and `scene.write_data_to_sim` as pre-actuator callbacks and sets `NewtonBackend.handles_actions`. The backend then stages the body forces after the pre-actuator callbacks, so wrenches written by the assets hold for that physics step's substeps, and a reordered or ball-jointed articulation republishes its state at the start of its write. Post-step callbacks still run once per step. Hard resets register them again on the new backend. When something cannot be recorded, nothing is handled and the environment keeps its loop. `ManagerBasedEnv` also keeps its loop when `render_interval` is not a multiple of the decimation, a recorder term records after every physics step (`RecorderManager.records_physics_steps`), or a sensor that refreshes on update (contact history or eager sensor updates) has a period that is not a whole number of environment steps. - **Capture flags.** - `ActionTerm.is_graphable` (default `False`) marks terms whose `apply_actions` launches only Warp work on fixed buffers: joint position, velocity and effort, joint-to-limits (with EMA) and binary joint actions. These terms now write their processed actions in place, so a held `processed_actions` reference sees later commands. A subclass that overrides `process_actions` or `apply_actions` must set it again. `ActionManager.is_graphable` is whether all terms set it. - `AssetBase.is_graphable` (default `False`) is `True` for Newton rigid objects and collections, and for Newton articulations whose actuators run no Torch model and that have no fixed-tendon control. `ActuatorCollection.is_graphable` and `InteractiveScene.is_graphable` report the same. - **Wrench work in a captured step.** `WrenchComposer.pending` replaces `active` in the Newton asset writers. While a graph records, a composer that was ever written always merges, composes into the body frame and clears its buffers, so replays apply wrenches written after the capture. The `on_first_use` constructor argument captures the step again at the first write. ## Performance RTX PRO 6000 Blackwell, Warp 1.17.0. `isaaclab benchmark runtime --task <task> --num_envs 4096 --num_steps 1000 --warmup_steps 100 --visualizer none physics=newton_mjwarp`, two alternating sequential rounds after a warm-up run (steps/s): | Task | `main` | [2d/N] | this PR | vs [2d/N] | |---|---|---|---|---| | Cartpole | 2.632M | 2.634M | 2.808M | +6.6% | | Flat ANYmal-D | 254.0k | 261.1k | 261.9k | +0.3% | | Reach-Franka | 1.049M | 1.051M | 1.078M | +2.6% | ## Testing - New: a backend that handles actions matches the environment loop with a state-dependent action over a captured decimation loop, including after a hard reset. Dropping the re-staging of body forces turns it red. - New: recorded wrench work applies wrenches written after the capture, and recordable joint action terms process into the same buffer. - Handled and env-loop Cartpole and Reach-Franka rollouts on MJWarp match exactly. Flat ANYmal-D (Newton actuators, external wrench applied mid-rollout) matches the unfolded environment loop exactly. - Targeted tests pass, run file by file: Newton manager, solvers, VBD, MJWarp tendon control, MPM reset masks, coupler, visualization state, articulation and rigid object contracts, articulation, rigid object, cable, joint coordinates, Newton actuators, BAM actuator, MPM object, sensors, cloner, visualizer adapter, wrench composer, actions, experimental capture safety and Warp action parity, interactive scene. - Kit-only tests did not run locally. ## 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 `./isaaclab.sh --format` - [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 or that my feature works - [x] I have added changelog fragments --------- Co-authored-by: Antoine RICHARD <[email protected]>
Description
Part 2d-ii of the Newton manager redesign (overview).
Follows [2d/N] #8736 (merged).
NewtonSolverwas a class that was never instantiated: every call passed the solver configuration and Newton's solverback in, e.g.
cfg.class_type.pre_step(cfg, solver, state). It is now a driver built once from its configuration andmodel, so the backend calls
backend.solver_ops.pre_step(state).Changes
NewtonSolver(cfg, model, mode, env_template)storescfgand builds Newton's solver intonativethrough theoverridable
build(model, mode, env_template). Per-solver methods (init_state,pre_step,step,post_step,reset,eval_fk,check_step, contact and capture queries) are instance methods, and each driver narrowscfgto its configuration type.
solver_classes,prepare_builder,applied_deterministic_mode,shares_materials,coupling_error,fixed_tendon_control): they need no built solver.NewtonBackend.solver_opsholds the driver;NewtonBackend.solverstays Newton's solver.CouplerSolverkeeps one driver per entry andCoupledMJWarpVBDSolverkeeps its rigid and soft drivers, instead of re-deriving them from configurations and
solver.solver(name).follow the new API.
Breaking
Custom solvers override
build(self, model, mode, env_template)and instance methods such aspre_step(self, state),reading
self.cfgandself.native. Code that calledcfg.class_type.<method>(cfg, solver, ...)callsbackend.solver_ops.<method>(...).Validation
Targeted tests, one file at a time:
test_newton_manager.py(50),test_newton_solvers.py(36),test_vbd_core.py(8),
test_mpm_reset_mask_contract.py(4),test_mjwarp_tendon_control.py(10),test_coupler.py(66),custom_coupling/test_manager.py(9),test_articulation.py(42),test_rigid_object.py(22), asset contract tests(296 + 146), all passing.
Type of change
Checklist
pre-commitchecks with./isaaclab.sh --formatchangelog.d/