Repository navigation
Migrate Newton contact sensors to solver observables - #8954
Conversation
[Medium impact] The changes affect contact-sensor updates and collision sizing within the Newton physics backend. Resolve the competing Kamino and collision capacity settings before merging. Findings
SummaryAdds shared support for solver-owned contact observables and per-world contact capacity.
Diagram%%{init: {'theme': 'neutral'}}%%
flowchart TD
C[Collision settings] --> R[Resolve total capacity]
R --> M[Set model capacity]
M --> B[Build solver]
B --> P[Allocate contacts]
S[Registered contact sensors] --> O[Create contact observables]
P --> O
O --> T[Step solver with observables]
T --> U[Update contact sensors]
Reviews (1) · Last reviewed commit: "Add shared Newton contact observables an..." · Reviewed by Greptile |
| contact_max = self.cfg.collision_cfg.resolve_rigid_contact_max(self.model.world_count) | ||
| if contact_max is not None: | ||
| # Solver scratch and the collision pipeline must agree on the explicit contact capacity. | ||
| self.model.rigid_contact_max = contact_max | ||
| solver = self.solver = solver_cls.build(solver_cfg, self.model, mode, env_template) |
There was a problem hiding this comment.
Kamino overwrites requested capacity
With KaminoPADMMSolverCfg(use_collision_detector=False, max_contacts_per_world=32) and rigid_contact_max_per_world=128, init_solver sets the requested capacity, but KaminoSolver.build replaces it with 32 contacts per world. Since to_pipeline_args removes the new field, the pipeline also gets the smaller value. Contact-heavy scenes can exhaust that buffer despite the larger requested capacity.
Resolve these settings together, or reject conflicting values, rather than silently ignoring the collision setting.
| elif self.contact_observables is None: | ||
| self.contact_observables = solver_cfg.class_type.create_contact_observables( | ||
| solver_cfg, self.solver, self.contacts | ||
| ) |
There was a problem hiding this comment.
Late sensors miss graph updates
If an adapter supplies observables and a sensor is registered after CUDA graph capture, this branch creates contact_observables but keeps the old graph. Later steps still run the solver without those observables, and the graph contains no update for the new sensor. Its forces can remain unchanged.
Invalidate the graph when a new sensor or its observables are added so the next step records those operations.
Knowledge Base Used: Newton backend
| backend.contacts = object() | ||
| backend.contact_observables = object() |
There was a problem hiding this comment.
Tests bypass observable allocation
This test assigns contact_observables directly, so it never exercises create_contact_observables. Removing both new factory calls would still leave the test passing, even though registered sensors would no longer cause observables to be allocated.
Add cases that register a sensor before init_solver and after contacts exist. Assert that the factory result reaches the solver and sensor.
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
Needs attention: Design and architecture (1), Scope and over-engineering (1), API (1), Compatibility and deprecation (1), Style consistency (1). Other reviewed categories look good.
- PR description: The body matches the six-file diff and discloses the dependency, but its “10 focused cases” claim is not reproducible; add the exact pytest command and dependency revisions.
- Design and architecture: Both capacity fields can coexist until solver initialization, delaying a deterministic configuration error until scene launch; reject the pair in
NewtonCollisionPipelineCfgvalidation. - Scope and over-engineering: Minimal implementation: keep capacity ownership in
NewtonCollisionPipelineCfgand pre-construction application inNewtonBackend; delete the producerlessNewtonSolverobservables hook, backend field, branches, fixture state, and injected test; no source modules were added; remaining flow resolves capacity, updates the model, and builds the solver and pipeline; Replace with one smaller PR: the collision config, backend capacity lines, changelog, and resolver test, validated bytest_newton_manager.py. - API: The existing
rigid_contact_maxfield now also sizes solver scratch, but its documentation describes only pipeline allocation; document the widened contract or restrict the model write to the new field. - Compatibility and deprecation: Breaking changes:
_update_sensorsunconditionally requires Newton 1.9’sobservableskeyword while the base dependency lacks it; retain the legacy call when observables are absent. - Implementation: Implementation looks good.
- Style consistency: The new field omits the sibling fields’ default statement and switches from “world” to “environment”; document the
Nonedefault and use consistent vocabulary. - Test quality: Test quality looks good.
Needs rework. Posted 5 inline findings.
Automated review; human maintainers own approval decisions.
| contact_max = self.cfg.collision_cfg.resolve_rigid_contact_max(self.model.world_count) | ||
| if contact_max is not None: | ||
| # Solver scratch and the collision pipeline must agree on the explicit contact capacity. | ||
| self.model.rigid_contact_max = contact_max |
There was a problem hiding this comment.
🟡 Warning · Api — Document widened rigid_contact_max effect
An explicit rigid_contact_max now also sizes solver scratch, not just the pipeline, while its docstring still documents pipeline resolution only. Document the broadened effect or limit this write to the per-world field.
| self.solver.update_contacts(eval_contacts, self.state_0) | ||
| for sensor in self.contact_sensors.values(): | ||
| sensor.update(self.state_0, eval_contacts) | ||
| sensor.update(self.state_0, eval_contacts, observables=self.contact_observables) |
There was a problem hiding this comment.
🟡 Warning · Compatibility — Guard the sensor observables keyword
solver_cls.step is guarded against the new keyword, but this call always passes observables=, so every contact sensor must accept it even before the Newton 1.9 bump lands. Guard it the same way.
| """ | ||
|
|
||
| rigid_contact_max_per_world: int | None = None | ||
| """Rigid contact capacity per world; the total is this times the world count. |
There was a problem hiding this comment.
🟡 Warning · Style Consistency — Field docstring omits default behavior
Every sibling field in this class closes with a "Defaults to None (...)" sentence; this one does not. Add that line and use the class's "world" vocabulary instead of "environments".
| """Return the total contact capacity this configuration sets, or ``None`` to let Newton choose.""" | ||
| if self.rigid_contact_max_per_world is None: | ||
| return self.rigid_contact_max | ||
| if self.rigid_contact_max is not None: |
There was a problem hiding this comment.
🟡 Warning · Design Architecture — Validate field exclusivity at construction
Setting both capacity fields passes config construction and to_pipeline_args, raising only inside init_solver after launch and scene build. Move the mutual-exclusion check to the config's validation hook.
| cls, cfg: NewtonSolverCfg, solver: SolverBase, contacts: Contacts | ||
| ) -> SolverBase.Observables | None: | ||
| """Allocate solver-owned contact forces for sensors, or use the legacy contact buffer.""" | ||
| return None |
There was a problem hiding this comment.
🟡 Warning · Scope Complexity — Observables hook has no producer
The base returns None and no shipped solver overrides it, so contact_observables stays None and every added backend branch is dead code exercised only by injection. Land this plumbing with its first consumer.
d9b316e to
b50761a
Compare
| if observables is None: | ||
| solver.step(state_in, state_out, control, contacts, dt) | ||
| else: | ||
| solver.step(state_in, state_out, control, contacts, dt, observables=observables) |
There was a problem hiding this comment.
You don't need to branch on oservables is None. You can also pass observables in the step() call too if it is None.
| if solver_cls.single_state: | ||
| solver_cls.step(solver_cfg, solver, state, state, control, contacts, dt) | ||
| state_out = state if solver_cls.single_state else self.state_1 | ||
| if observables is None or i < num_substeps - 1: |
There was a problem hiding this comment.
nitpick: I think you can remove the observables is None part out.
There was a problem hiding this comment.
It is probably better to add comment for others to understand why you skip passing in observables for substeps.
My hunch is that you want to avoid unnecessary compute because we will never read those substep observable outputs. A comment in the code will help others to be sure.
| if self.solver is not None: | ||
| if self.contacts is None: | ||
| self._allocate_contacts() | ||
| elif self.contact_observables is None: |
There was a problem hiding this comment.
I would remove the observable construction from the _allocate_contacts() method, otherwise it would expand the scope of this function as indicated by the function name.
Then the elif in this line can become if to make the code block a bit more streamlined.
| self._launch("before_actuators", self._before_actuators) | ||
| actuators.step(self.state_0, self.control, self.dt) | ||
| self._launch("after_actuators", self._after_actuators) | ||
| observables = self.contact_observables if i == steps - 1 else None |
There was a problem hiding this comment.
I guess I know the reason why you skip observables for intermediate steps, but I would add a comment for other developers :)
| else: | ||
| solver_cls.step(solver_cfg, solver, state, state_out, control, contacts, dt) | ||
| # Intermediate substep forces are never read; collect observables only on the final substep. | ||
| substep_observables = observables if i == num_substeps - 1 else None |
There was a problem hiding this comment.
The naming of substep_observables is exactly the opposite of your purpose. You don't want substep observables, you only want the step observables :)
| ) -> None: | ||
| """Advance one substep of ``dt`` [s].""" | ||
| solver.step(state_in, state_out, control, contacts, dt) | ||
| solver.step(state_in, state_out, control, contacts, dt, observables=observables) |
There was a problem hiding this comment.
Passing observables= unconditionally breaks any SolverBase subclass whose step predates the keyword (here SolverCoupledMJWarpVBD and EndpointVBD raise TypeError on the first step, and so would user solvers). Newton's SolverCoupled keeps the plain step() call when no observables are requested for exactly this reason. Needs fixing before merge.
There was a problem hiding this comment.
but observable=None should be fine...
I'd like to avoid if else to handle having obsrevables or not
e4c9f9f to
c0fadd8
Compare
|
run-ci |
|
run-ci |
# Description Add Newton Steel as a solver in the shared Newton backend and expose `presets=newton_steel` across supported Isaac Lab task families. Steel uses point friction by default, the shared Newton manager, and one owner for each task family preset. This branch is rebased onto upstream `main` at `d4be26397`. The Steel presets include the tuned settings from contributor PR [#12](ooctipus#12). Franka Reach and Drawer select the driven PhysX USD variant. ## Dependencies - [PR #8953](#8953) updates Newton to 1.9 and MuJoCo/MuJoCo Warp to 3.17. Dependency pins, the lockfile, wheel overrides, the actuator compatibility fix, and the MPM rendering reference are there. - [PR #8954](#8954) migrates contact sensors for Steel, MuJoCo, XPBD, VBD, and Kamino to Newton solver observables. - [PR #8957](#8957) aligns explicit contact capacity before solver construction. PRs #8953 and #8954 are merged into `main`. PR #8957 is still open and remains a dependency for explicit contact-capacity alignment. The benchmark table below was collected before the Newton Manager redesign and is retained as historical data, not as a current-revision performance claim. ## Historical benchmark: Steel point friction vs MJWarp All 42 Steel-configured task families were benchmarked sequentially on RTX 5090 GPU 0. The original 16,384-environment pairs used point-friction runtime code at `8b8799c40`. Steel rows affected by the driven Franka USD variant or the default solver tuning were rerun with the final integration settings; their MJWarp rows are unchanged. The SO101 row was rerun after #8954's contact-observable migration, before the Newton Manager redesign merged into `main`. The other rows predate that migration and should be read as a baseline, not current-code measurements. The measurements include the dependency versions in #8953: official Newton `7f0c13af6e4d` and MuJoCo/MuJoCo Warp 3.17. Steel uses `friction_anchor_beta=0.0`. - 41 task pairs completed at **16,384 environments**. Both SO101 solvers ran out of GPU memory there, so SO101 was rerun at its configured default of **4,096 environments**; both completed. - In that earlier run, Steel was faster on **28 of 39** pairs without MJWarp line-search warnings at 16,384 environments. The historical geometric mean Steel/MJWarp ratio was **1.31×** (median **1.12×**). - Two 16,384-environment pairs emitted MJWarp line-search warnings; their numbers are shown but excluded from that summary. SO101 uses 4,096 environments and is also outside the 16,384-environment summary. - After #8954's migration on the earlier base, SO101 measured 172,477 aggregate steps/s with Steel and 135,059 with MJWarp on GPU 0. Earlier Steel reruns ranged from 157,878 to 172,872 aggregate steps/s. GPU process checks detected brief unrelated startup overlap on one earlier rerun; per-step contention was not continuously measured. The shared runtime uses Isaac Sim 6.1, while the repository lock targets 6.2. The SO101 task packs 108 keyboard joints into one Newton articulation per environment. Its default Steel preset keeps two substeps. On the earlier combined code with #8954, Steel took 23.7 ms per full `env.step()` call at 4,096 environments; MJWarp took 30.3 ms in its paired rerun. Each result is one 100-call run. These timings have not been repeated after the Newton Manager redesign on current `main`. ### What the numbers mean We timed **100 full `env.step()` calls** after 20 warmup calls. The table shows the **total environment steps per second across all environments**: environments × 100 ÷ the combined host wall time of those calls. Higher is better. This includes work inside `env.step()`, not just the physics solver. GPU completion is not synchronized at every call. ### Default Steel tuning The tuned solver settings from contributor PR #12 are selected by `presets=newton_steel`. The measurements below were taken before this rebase; the tuning improves some tasks and reduces throughput on others in that earlier run. ### Historical result table (`presets=newton_steel`) | Task | Envs | Steel aggregate env steps/s | MJWarp aggregate env steps/s | Steel / MJWarp | Note | |---|---:|---:|---:|---:|---| | Isaac-Ant | 16,384 | 5,318,029 | 2,626,845 | 2.02× | | | Isaac-Ant-Direct | 16,384 | 6,559,093 | 5,599,628 | 1.17× | | | Isaac-Cartpole | 16,384 | 9,422,295 | 8,633,389 | 1.09× | | | Isaac-Cartpole-Camera | 16,384 | 970,962 | 938,307 | 1.03× | | | Isaac-Cartpole-Camera-Direct | 16,384 | 1,014,796 | 987,499 | 1.03× | | | Isaac-Cartpole-Direct | 16,384 | 10,603,728 | 11,049,601 | 0.96× | | | Isaac-Humanoid | 16,384 | 1,716,377 | 1,381,116 | 1.24× | | | Isaac-Humanoid-Direct | 16,384 | 1,889,483 | 1,567,169 | 1.21× | | | Isaac-Lift-Franka | 16,384 | 761,653 | 723,584 | 1.05× | | | Isaac-Lift-KukaAllegro | 16,384 | 630,889 | 473,922 | 1.33× | | | Isaac-Lift-KukaAllegro-Camera | 16,384 | 269,357 | 232,573 | 1.16× | | | Isaac-Open-Drawer-Franka | 16,384 | 3,724,915 | 793,857 | 4.69× | | | Isaac-Open-Drawer-Franka-Direct | 16,384 | 3,768,857 | 818,514 | 4.60× | | | Isaac-Reach-Franka | 16,384 | 2,836,122 | 2,031,628 | 1.40× | | | Isaac-Reach-Franka-OSC | 16,384 | 1,467,223 | 1,248,146 | 1.18× | | | Isaac-Reach-UR10 | 16,384 | 4,697,814 | 2,458,897 | 1.91× | | | Isaac-Reorient-Cube-Allegro | 16,384 | 474,390 | 321,799 | 1.47× | | | Isaac-Reorient-Cube-Allegro-Direct | 16,384 | 473,186 | 330,940 | 1.43× | MJWarp line search (3) | | Isaac-Reorient-KukaAllegro | 16,384 | 619,824 | 475,442 | 1.30× | | | Isaac-Reorient-KukaAllegro-Camera | 16,384 | 260,914 | 236,028 | 1.11× | | | Isaac-Velocity-Flat-AnymalD | 16,384 | 623,494 | 394,514 | 1.58× | MJWarp line search (1) | | Isaac-Velocity-Flat-Cassie | 16,384 | 980,049 | 872,366 | 1.12× | | | Isaac-Velocity-Flat-G1 | 16,384 | 395,715 | 413,783 | 0.96× | | | Isaac-Velocity-Flat-H1 | 16,384 | 811,177 | 732,821 | 1.11× | | | Isaac-Velocity-Flat-UnitreeGo2 | 16,384 | 861,115 | 929,370 | 0.93× | | | Isaac-Velocity-Rough-AnymalD | 16,384 | 262,903 | 309,238 | 0.85× | | | Isaac-Velocity-Rough-Cassie | 16,384 | 626,981 | 546,664 | 1.15× | | | Isaac-Velocity-Rough-G1 | 16,384 | 219,665 | 225,923 | 0.97× | | | Isaac-Velocity-Rough-H1 | 16,384 | 534,495 | 480,473 | 1.11× | | | Isaac-Velocity-Rough-UnitreeGo2 | 16,384 | 360,563 | 385,435 | 0.94× | | | IsaacContrib-Cartpole-Showcase-Direct | 16,384 | 13,125,361 | 11,187,047 | 1.17× | | | IsaacContrib-Keyboard-SO101 | 4,096 | 172,477 | 135,059 | 1.28× | Both OOM at 16,384; rerun with #8954 contact observables | | IsaacContrib-Open-Drawer-Franka-IK-Abs | 16,384 | 3,278,941 | 637,379 | 5.14× | | | IsaacContrib-Open-Drawer-Franka-IK-Rel | 16,384 | 3,120,403 | 584,387 | 5.34× | | | IsaacContrib-Velocity-Flat-AnymalB | 16,384 | 752,575 | 462,837 | 1.63× | | | IsaacContrib-Velocity-Flat-AnymalC | 16,384 | 757,105 | 442,263 | 1.71× | | | IsaacContrib-Velocity-Flat-UnitreeA1 | 16,384 | 789,132 | 1,041,755 | 0.76× | | | IsaacContrib-Velocity-Flat-UnitreeGo1 | 16,384 | 635,813 | 937,895 | 0.68× | | | IsaacContrib-Velocity-Rough-AnymalB | 16,384 | 431,995 | 439,662 | 0.98× | | | IsaacContrib-Velocity-Rough-AnymalC | 16,384 | 410,209 | 404,162 | 1.01× | | | IsaacContrib-Velocity-Rough-UnitreeA1 | 16,384 | 396,145 | 451,066 | 0.88× | | | IsaacContrib-Velocity-Rough-UnitreeGo1 | 16,384 | 330,732 | 396,851 | 0.83× | | | **Geometric mean (39 comparable pairs)** | 16,384 | — | — | **1.31×** | Excludes pairs with MJWarp line-search warnings; SO101 uses 4,096 envs | ## Type of change - New feature - Bug fix - Documentation update ## Validation Focused checks on the rebased branch: - Newton Steel solver: 5 passed - Newton manager Steel build and step: 1 passed - Steel contact-sensor force: 1 passed - Steel task presets: 17 passed - Benchmark capture: 20 passed - Ruff lint and format checks passed; `git diff --check` passed The historical benchmark table has not been rerun on this revision. PR #8957 is still open, so the full integration and CI remain subject to that dependency. ## Checklist - [x] I have read and understood the contribution guidelines - [ ] I have run pre-commit checks on the changed files - [x] I have made corresponding documentation changes - [ ] My changes generate no new warnings - [x] I have validated the changed behavior with focused coverage and applied the test-audit criteria - [x] I have added changelog fragments for every touched source package - [x] My name already exists in CONTRIBUTORS.md
) ## Description Set an explicit `NewtonCollisionPipelineCfg.rigid_contact_max` on the model before constructing the solver. This keeps solver scratch and the collision pipeline at the same contact capacity. Reject a conflicting `KaminoPADMMSolverCfg.max_contacts_per_world` instead of silently overriding that value. This change is independent of the contact-sensor observable migration in [#8954](#8954). [#8940](#8940) has merged. This PR remains a needed follow-up: its SO101 Steel preset sets an explicit collision capacity, and this change applies that capacity to the model before solver construction. ## Validation - Newton manager tests are rerunning in CI on the rebased head. - Ruff, Python syntax, changelog gate, and diff whitespace checks passed locally after rebase. ## Type of change - Bug fix
Description
Use Newton's
CONTACT_Fsolver 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 aContactsbuffer for observable contact indexing. Late sensor registration invalidates captured step graphs.Newton deprecated
Contacts.forceandsolver.update_contacts()in version 1.7. Isaac Lab no longer uses that path for contact sensors. Featherstone and implicit MPM do not provideCONTACT_Fin 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 adds Steel; #8957 independently aligns explicit contact capacity.
Base
Rebased on
mainatbb4d9915f, which includes #8953 (Newton 1.9 and MuJoCo/MuJoCo Warp 3.17) and #8946 (Newton manager redesign). The solver observable changes use the new instance-based solver interface.Validation
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.90e1f74d9: 4 coupled-solver runtime tests and 56 Newton manager tests passed locally. Activated Docker + Tests CI passed, includingisaaclab_assetsand contrib environments.