Repository navigation
Add generic Newton coupled-solver with Proxy + ADMM variants - #5834
Conversation
There was a problem hiding this comment.
Code Review: Add generic Newton coupled-solver manager with Proxy + ADMM variants
Thank you for this comprehensive addition to the Newton physics coupling framework! The design is well-structured and the implementation is clean. Below are my observations and suggestions.
✅ Strengths
-
Excellent extensibility - The
_SOLVER_CLASS_BY_CFG_TYPEregistry pattern inNewtonCoupledSolverManagermakes it trivial to add new solver combinations without modifying the manager. -
Clean dispatch pattern - Using config subclass type (
CoupledProxySolverCfgvsCoupledAdmmSolverCfg) to select the coupling algorithm is elegant and type-safe. -
Good separation of concerns - Body selector resolution, model partitioning, and proxy selection are cleanly separated into well-named static methods.
-
Comprehensive unit tests - The 358-line test file with fake objects is excellent for testing partitioning logic without launching Isaac Sim.
-
Helpful error messages - The partition validation errors include specific body IDs and labels, making debugging much easier.
-
Refactoring win - Extracting
_filter_solver_kwargsintoNewtonManagerremoves duplication across all solver managers.
🔴 Issues to Address
1. Breaking Rename Needs Migration Guide
The rename from deformable to object in lift_franka_soft is a breaking change that affects:
- Scene entity:
scene.deformable→scene.object - Command:
deformable_pose→object_pose - All MDP functions:
deformable_*→object_*
The changelog mentions this, but consider adding a migration note in the documentation or a deprecation warning for downstream users who have trained models referencing the old keys.
2. proxy_mode Should Be Validated
File: coupled_manager.py line ~161
proxies.append(
SolverCoupledProxy.Proxy(
...
mode=solver_cfg.proxy_mode, # No validation
...
)
)A typo like "laggeed" would fail deep in Newton code. Add validation:
if solver_cfg.proxy_mode not in {"lagged", "staggered"}:
raise ValueError(f"Invalid proxy_mode={solver_cfg.proxy_mode!r}; expected 'lagged' or 'staggered'.")🟡 Suggestions
1. Add ADMM-Specific Tests
The unit tests thoroughly cover proxy coupling, but there are no tests for:
_build_admm_coupled_solverparameter forwardingContactPairconstruction whenenable_contacts=True/False- The
contact_distance/detection_marginNone handling
2. Defensive Error for Missing scene_cfg
File: coupled_manager.py line ~87
outer_cfg = PhysicsManager._cfg
scene_cfg = outer_cfg.scene_cfg if isinstance(outer_cfg, CoupledNewtonCfg) else NoneIf someone uses SceneEntityCfg selectors without CoupledNewtonCfg, they get a confusing error later. Consider failing fast:
if any(isinstance(s, SceneEntityCfg) for s in solver_cfg.src_bodies + solver_cfg.dst_bodies):
if scene_cfg is None:
raise ValueError(
"SceneEntityCfg selectors require physics.scene_cfg to be set "
"(use CoupledNewtonCfg and set scene_cfg in __post_init__)."
)3. Consider Bounds for Numerical Parameters
Parameters like rho, gamma, proxy_mass_scale are passed through without validation. While Newton may handle invalid values, early validation with helpful error messages improves UX:
if solver_cfg.proxy_mass_scale <= 0:
raise ValueError(f"proxy_mass_scale must be positive, got {solver_cfg.proxy_mass_scale}")📝 Minor Observations
-
Documentation is solid - The
using-vbd-solver.rstadditions explain proxy coupling well with good examples. -
Coupling mode validation - Good that
coupled_mjwarp_vbd_manager.pyandcoupled_featherstone_vbd_manager.pynow raise for unknown coupling modes. -
Static shape routing - The decision to route
body == -1shapes to destination for ground collision is correct. A brief inline comment explaining this would help future maintainers.
Verdict
This is a well-designed and well-implemented feature. The architecture is sound and the code quality is high. Addressing the proxy_mode validation and adding a migration note for the breaking rename would make this PR ready to merge.
Overall: 👍 Approve with minor suggestions
Greptile SummaryThis PR adds Newton coupled-solver support for rigid/deformable setups. The main changes are:
Confidence Score: 5/5This looks safe to merge.
Important Files Changed
Reviews (3): Last reviewed commit: "Feat: Remove NewtonModelCfg from where i..." | Re-trigger Greptile |
|
|
||
| import torch | ||
| import warp as wp | ||
|
|
There was a problem hiding this comment.
Cross-module import of private helpers
observations.py imports _com_w and _points_w from rewards.py. Both are prefixed with _, meaning they are private to that module. Importing private symbols across module boundaries makes refactoring fragile and breaks the encapsulation contract that underscore-prefixed names imply. These shared utilities should be extracted into a small internal helpers module (e.g. _deformable_utils.py) so both rewards.py and observations.py can import from a common, intentionally public location.
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.
This thread is outdated: the private cross-module helper import was removed from the current #5834 head. The coupling follow-up in mmichelis#6 does not reintroduce it.
15310c6 to
fb72837
Compare
fb72837 to
48bc7d1
Compare
| ) | ||
|
|
||
| @classmethod | ||
| def _build_proxy_coupled_solver( |
There was a problem hiding this comment.
again , the colyd looks like a lot of data piping, if we just ensure the type is given correctly at Cfg, leys construct just by proxy_cfg.class_type(proxy_cfg) or NewtonConfig(**config)
There was a problem hiding this comment.
Addressed in mmichelis#6, stacked on #5. #5 now forwards the proxy mapping config directly into Newton; #6 keeps that direct path but checks every authored field against the pinned Newton dataclass, and applies the same completeness check to ADMM so a renamed field fails loudly instead of silently falling back to a default.
AntoineRichard
left a comment
There was a problem hiding this comment.
High-level comment. Should we promote VBD and the coupler to isaaclab rather than contrib?
|
I reviewed the current head with a particular focus on
The focused tests pass, but they replace both real coupled-solver implementations with recorder classes. A minimal headless proxy construct/reset/step test (and ideally an ADMM equivalent) would cover model-view construction, contact preparation, reset behavior, and the actual pinned Newton constructor contract; those paths can currently regress while all new tests remain green. I also ran |
| # (matches newton/examples/softbody/example_softbody_franka.py) | ||
| newton_mjwarp_vbd: NewtonCfg = NewtonCfg( | ||
| solver_cfg=CoupledMJWarpVBDSolverCfg( | ||
| rigid_solver_cfg=MJWarpSolverCfg( | ||
| njmax=40, | ||
| nconmax=20, | ||
| ls_iterations=20, | ||
| cone="pyramidal", | ||
| impratio=1, | ||
| integrator="implicitfast", | ||
| ccd_iterations=100, | ||
| ), | ||
| soft_solver_cfg=VBDSolverCfg( | ||
| iterations=10, | ||
| integrate_with_external_rigid_solver=True, | ||
| particle_enable_self_contact=False, | ||
| particle_collision_detection_interval=-1, | ||
| ), | ||
| coupling_mode="two_way", | ||
| model_cfg=NewtonModelCfg( | ||
| soft_contact_ke=1e4, | ||
| soft_contact_kd=1e-5, | ||
| soft_contact_mu=5.0, | ||
| ), | ||
| ), | ||
| default_shape_cfg=NewtonShapeCfg(ke=4e4, kd=1e-5, mu=5.0), | ||
| num_substeps=10, | ||
| ) | ||
|
|
||
| newton_mjwarp_vbd_proxy: NewtonCfg = NewtonCfg( | ||
| solver_cfg=CouplerProxyCfg( | ||
| entries=[ | ||
| CouplerEntryCfg( | ||
| name="rigid", | ||
| solver_cfg=MJWarpSolverCfg( | ||
| cone="elliptic", | ||
| ls_iterations=20, | ||
| integrator="implicitfast", | ||
| ), | ||
| bodies=[SceneEntityCfg("robot")], | ||
| ), | ||
| CouplerEntryCfg( | ||
| name="soft", | ||
| solver_cfg=VBDSolverCfg(iterations=10), | ||
| all_particles=True, | ||
| include_static_shapes=True, | ||
| ), | ||
| ], | ||
| proxies=[ | ||
| CouplerProxyMappingCfg( | ||
| source="rigid", | ||
| destination="soft", | ||
| bodies=[ | ||
| SceneEntityCfg( | ||
| "robot", | ||
| body_names=["panda_hand", "panda_(left|right)finger"], | ||
| ) | ||
| ], | ||
| collide_interval=5, | ||
| ) | ||
| ], | ||
| iterations=1, | ||
| model_cfg=NewtonModelCfg( | ||
| soft_contact_ke=1e4, | ||
| soft_contact_kd=1e-5, | ||
| soft_contact_mu=5.0, | ||
| ), | ||
| ), | ||
| default_shape_cfg=NewtonShapeCfg(ke=4e4, kd=1e-5, mu=5.0), | ||
| num_substeps=10, | ||
| use_cuda_graph=True, | ||
| ) | ||
|
|
||
| physx: PhysxCfg = PhysxCfg() | ||
|
|
||
| default = newton_mjwarp_vbd | ||
| default = newton_mjwarp_vbd_proxy |
There was a problem hiding this comment.
LEt's make sure the difference between the two is well documented.
There was a problem hiding this comment.
(with pros & cons)
There was a problem hiding this comment.
Addressed in mmichelis#6. The VBD guide now has a decision table comparing alternating MJWarp+VBD and proxy coupling across interaction model, advantages, trade-offs/limits, and when to choose each.
|
|
||
| class NewtonCoupler(NewtonVBDManager): |
There was a problem hiding this comment.
Why does it inherit from VBDManager?
There was a problem hiding this comment.
this is a suboptimal part of the current design: the inheritance intentionally reuses VBD’s deformable lifecycle, but it conflates generic coupling with VBD-specific behavior even though solver selection remains entry-driven. A cleaner follow-up would have NewtonCouplerManager inherit directly from NewtonManager and introduce an extensible per-solver CouplerEntrySupport API, allowing current and future solvers to declare their builder, contact, and runtime requirements without changing the coupler
Validate ownership, references, nested solver lifecycles, and config forwarding before mutating manager state. Cover the pinned Newton Proxy and ADMM contracts with real CPU runtime tests.
Express supported modes as Literal types and reject invalid values before constructing solvers or mutating shared manager state.
Document alternating and proxy coupling tradeoffs, correct task IDs and release notes, and make the Franka proxy preset self-contained with full body-label regexes.
Delegate native configuration checks to Newton and retain only adapter lifecycle constraints. Preserve proxy collision factories while selecting outer contacts from constructed proxy state.
Require full Newton body-label regexes for coupler selectors and migrate the Franka soft preset. Keep scene entity resolution within the manager layer.
Restore the prior Newton and schema versions and remove the MuJoCo overrides added for the newer pin. Remove the obsolete pin changelog fragments.
9ce193f to
a92de97
Compare
# Description ## Summary * **New `isaaclab_contrib.coupling` submodule.** It exposes `NewtonCoupler` and a typed `Coupler*Cfg` API for Newton's experimental coupled solvers: * `CouplerProxyCfg` → `SolverCoupledProxy`: lagged-impulse virtual-proxy coupling. This works well when only a small set of rigid bodies, such as a gripper, needs to interact with a deformable while the rest of the articulation remains entirely in the rigid solver. * `CouplerAdmmCfg` → `SolverCoupledADMM`: linearized ADMM coupling with tunable `rho`, `gamma`, and `baumgarte` penalties plus cross-solver joint stiffness and damping. * **N-way named solver entries.** `CouplerEntryCfg` partitions the model into named entries, each with its own typed `solver_cfg`. Each entry constructs its nested solver through that config's `class_type`, so combinations such as MJWarp + VBD, Featherstone + VBD, XPBD + Kamino, and implicit MPM work without coupler-specific solver registries. * **Implicit MPM entries.** Entries forward `substeps` and `in_place` to Newton, reuse the MPM builder-registration and kinematic-collider finalization hooks, request FK before stepping, and prepare coupled contacts before CUDA graph capture. * **Explicit external-contact routing.** Proxy source entries configured to consume Newton contacts receive the shared collision pipeline, including MJWarp with `use_mujoco_contacts=False`. Proxy destinations continue to use their entry-local collision pipeline. * **Flexible ownership selectors.** Body selectors accept raw Newton body-label regex strings alongside `SceneEntityCfg`. Bodies, particles, joints, and shapes may be assigned to at most one entry; model elements may intentionally remain unassigned. When using `SceneEntityCfg`, assign `CouplerCfg.scene_cfg` from the environment config, typically in `__post_init__`. * **`Isaac-Lift-Soft-Franka-v0` defaults to proxy-coupled MJWarp + VBD** through the `newton_mjwarp_vbd_proxy` preset. * **`NewtonShapeCfg` gains `ke`, `kd`, and `mu` contact-material fields**, forwarded to Newton's `ModelBuilder.default_shape_cfg` for shapes without an explicit per-asset material. * **Reusable Newton solver construction.** Newton solver managers expose a common nested-solver construction hook used by the coupler instead of duplicating config-to-constructor plumbing. * **Documentation and tests.** The coupling API page, VBD guide, focused pure-Python tests, and existing changelog fragment cover the final `NewtonCoupler` / `Coupler*Cfg` API. Builds on Newton Coupling in [gdaviet/coupled-solver-framework](https://github.com/gdaviet/newton/tree/gdaviet/coupled-solver-framework). ## How to use Partition the model into named entries, then select a coupling algorithm with its typed coupler config: ```python from isaaclab_contrib.coupling import ( CouplerAdmmCfg, CouplerEntryCfg, CouplerProxyCfg, CouplerProxyMappingCfg, ) # Proxy coupling: rigid MJWarp entry + soft VBD entry, with the gripper exposed as proxies. solver_cfg = CouplerProxyCfg( entries=[ CouplerEntryCfg( name="rigid", solver_cfg=MJWarpSolverCfg(...), bodies=["/World/envs/env_.*/Robot"], ), CouplerEntryCfg( name="soft", solver_cfg=VBDSolverCfg(iterations=10), all_particles=True, include_static_shapes=True, ), ], proxies=[ CouplerProxyMappingCfg( source="rigid", destination="soft", bodies=[ "/World/envs/env_.*/Robot/panda_hand", "/World/envs/env_.*/Robot/panda_(left|right)finger", ], collide_interval=5, ) ], iterations=1, ) # ADMM coupling: the same entries with symmetric contact interfaces instead of proxies. solver_cfg = CouplerAdmmCfg( entries=[...], iterations=10, rho=1.0, gamma=0.0, baumgarte=0.0, joint_stiffness=1.0e4, joint_angular_stiffness=1.0e4, ) # Selectors may also use SceneEntityCfg, for example: # SceneEntityCfg("robot", body_names=["panda_hand"]). # Attach the scene in the environment config so those selectors can resolve. solver_cfg.scene_cfg = self.scene ``` An implicit MPM entry uses the same entry API: ```python CouplerEntryCfg( name="media", solver_cfg=MPMSolverCfg(grid_type="fixed"), all_particles=True, substeps=4, in_place=True, ) ``` ## Type of change - New feature (non-breaking change which adds functionality) - Documentation update ## Test plan - [x] `./isaaclab.sh -f` (pre-commit) - [x] `./isaaclab.sh -p -m pytest source/isaaclab_contrib/test/coupling/test_coupler.py -q` — 24/24 passed - [x] `./isaaclab.sh -d` — full documentation build passed - [x] Changelog fragment validation passed - [x] `Isaac-Lift-Soft-Franka-v0` with the `newton_mjwarp_vbd_proxy` preset runs stably ## 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 updated the changelog and the corresponding version in the extension's `config/extension.toml` file - [x] I have added my name to `CONTRIBUTORS.md`, or my name already exists there --------- Co-authored-by: Maximilian Krause <[email protected]>
Description
Summary
isaaclab_contrib.couplingsubmodule. It exposesNewtonCouplerand a typedCoupler*CfgAPI for Newton's experimental coupled solvers:CouplerProxyCfg→SolverCoupledProxy: lagged-impulse virtual-proxy coupling. This works well when only a small set of rigid bodies, such as a gripper, needs to interact with a deformable while the rest of the articulation remains entirely in the rigid solver.CouplerAdmmCfg→SolverCoupledADMM: linearized ADMM coupling with tunablerho,gamma, andbaumgartepenalties plus cross-solver joint stiffness and damping.CouplerEntryCfgpartitions the model into named entries, each with its own typedsolver_cfg. Each entry constructs its nested solver through that config'sclass_type, so combinations such as MJWarp + VBD, Featherstone + VBD, XPBD + Kamino, and implicit MPM work without coupler-specific solver registries.substepsandin_placeto Newton, reuse the MPM builder-registration and kinematic-collider finalization hooks, request FK before stepping, and prepare coupled contacts before CUDA graph capture.use_mujoco_contacts=False. Proxy destinations continue to use their entry-local collision pipeline.SceneEntityCfg. Bodies, particles, joints, and shapes may be assigned to at most one entry; model elements may intentionally remain unassigned. When usingSceneEntityCfg, assignCouplerCfg.scene_cfgfrom the environment config, typically in__post_init__.Isaac-Lift-Soft-Franka-v0defaults to proxy-coupled MJWarp + VBD through thenewton_mjwarp_vbd_proxypreset.NewtonShapeCfggainske,kd, andmucontact-material fields, forwarded to Newton'sModelBuilder.default_shape_cfgfor shapes without an explicit per-asset material.NewtonCoupler/Coupler*CfgAPI.Builds on Newton Coupling in gdaviet/coupled-solver-framework.
How to use
Partition the model into named entries, then select a coupling algorithm with its typed coupler config:
An implicit MPM entry uses the same entry API:
Type of change
Test plan
./isaaclab.sh -f(pre-commit)./isaaclab.sh -p -m pytest source/isaaclab_contrib/test/coupling/test_coupler.py -q— 24/24 passed./isaaclab.sh -d— full documentation build passedIsaac-Lift-Soft-Franka-v0with thenewton_mjwarp_vbd_proxypreset runs stablyChecklist
pre-commitchecks with./isaaclab.sh --formatconfig/extension.tomlfileCONTRIBUTORS.md, or my name already exists there