Repository navigation
Harden Newton coupled-solver integration - #6
Conversation
| @@ -324,6 +571,37 @@ def _build_admm_coupled_solver( | |||
| coupling = SolverCoupledADMM.Config(**values) | |||
| return SolverCoupledADMM(model=model, entries=entries, coupling=coupling) | |||
|
|
|||
| @staticmethod | |||
| def _checked_config_values(target_type: type, config, *, handled_fields: set[str] | None = None) -> dict: | |||
There was a problem hiding this comment.
We can use the solver filter args function here, why not use that as opposed to another custom function here? If we want to fail loudly, then we should also fail loudly there for the solver args, might as well unify both.
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.
306d490 to
c526332
Compare
| raise ValueError(f"CouplerCfg {field} {name!r} is not one of the configured entries {sorted(entry_names)}.") | ||
|
|
||
| @classmethod | ||
| def _validate_resolved_entries( |
There was a problem hiding this comment.
A lot of validation code, I guess it's useful to have, but part of me also questions if we should take this job from Newton, or if the coupler from newton side should just check this after we give all the bodies from our side
mmichelis
left a comment
There was a problem hiding this comment.
Several validation blocks here duplicate checks already performed by Newton. I left focused inline comments on the exact overlaps so Newton can remain the single source of truth for its solver invariants.
| names = [entry.name for entry in solver_cfg.entries] | ||
| if any(not isinstance(name, str) or not name for name in names): | ||
| raise ValueError("CouplerCfg entry names must be non-empty strings.") | ||
| duplicate_names = sorted(name for name, count in Counter(names).items() if count > 1) |
There was a problem hiding this comment.
Newton already rejects duplicate entry names in SolverCoupled._validate_entry_names(). Can we remove this duplicate check and rely on the native constructor?
| if len(solver_cfg.entries) > 2: | ||
| raise ValueError("CouplerProxyCfg supports at most two solver entries.") | ||
| for proxy in solver_cfg.proxies: | ||
| cls._validate_entry_reference(name_set, proxy.source, "proxy source") | ||
| cls._validate_entry_reference(name_set, proxy.destination, "proxy destination") | ||
| if proxy.source == proxy.destination: | ||
| raise ValueError( | ||
| f"CouplerProxyMappingCfg source and destination must differ, got {proxy.source!r}." | ||
| ) | ||
| if proxy.collision_pipeline is not None and not callable(proxy.collision_pipeline): | ||
| raise TypeError("CouplerProxyMappingCfg.collision_pipeline must be callable or None.") | ||
| if proxy.collision_pipeline is None and proxy.collide_interval is not None: | ||
| raise ValueError( | ||
| "CouplerProxyMappingCfg.collide_interval requires a proxy-local collision_pipeline." | ||
| ) |
There was a problem hiding this comment.
This block duplicates Newton's proxy validation: SolverCoupledProxy.__init__() enforces the two-entry limit, _validate_config() checks source/destination references and distinctness, and _build_proxy_collision_configs() checks factory callability and collide_interval. Can we rely on those native checks instead?
| if solver_cfg.contact_pairs is not None: | ||
| for source, destination in solver_cfg.contact_pairs: | ||
| cls._validate_entry_reference(name_set, source, "ADMM contact-pair source") | ||
| cls._validate_entry_reference(name_set, destination, "ADMM contact-pair destination") | ||
| if source == destination: | ||
| raise ValueError(f"ADMM contact-pair entries must differ, got {source!r}.") | ||
| if solver_cfg.joint_proximal_destination_entries is not None: | ||
| for name in solver_cfg.joint_proximal_destination_entries: | ||
| cls._validate_entry_reference(name_set, name, "ADMM joint-proximal destination") |
There was a problem hiding this comment.
Newton already validates ADMM contact-pair references and distinctness in SolverCoupledADMM._setup_admm_contact_specs(), and proximal destination names in _init_admm_joint_proxy_visibility(). It also catches duplicate symmetric contact pairs, which this partial duplicate does not. Can we keep Newton as the single source of truth here?
| owners = { | ||
| "bodies": cls._build_ownership_map(model.body_count, entries, "bodies"), | ||
| "particles": cls._build_ownership_map(model.particle_count, entries, "particles"), | ||
| "joints": cls._build_ownership_map(model.joint_count, entries, "joints"), | ||
| "shapes": cls._build_ownership_map(model.shape_count, entries, "shapes"), | ||
| } | ||
| cls._validate_partial_joint_ownership(model, owners["bodies"]) | ||
|
|
||
| unassigned = {name: sum(owner is None for owner in values) for name, values in owners.items()} | ||
| logger.info( | ||
| "[COUPLER] Unassigned model elements: %d bodies, %d particles, %d joints, and %d shapes. " | ||
| "Unassigned elements remain outside nested solver views.", | ||
| unassigned["bodies"], | ||
| unassigned["particles"], | ||
| unassigned["joints"], | ||
| unassigned["shapes"], | ||
| ) | ||
|
|
||
| if isinstance(solver_cfg, CouplerProxyCfg): | ||
| cls._validate_no_cross_entry_proxy_joints(model, {entry.config.name: entry for entry in entries}) | ||
|
|
||
| @staticmethod | ||
| def _build_ownership_map(count: int, entries: list[_ResolvedEntry], field: str) -> list[str | None]: | ||
| """Build one ownership map while validating ranges and overlap.""" | ||
| owners: list[str | None] = [None] * int(count) | ||
| for entry in entries: | ||
| for raw_index in getattr(entry, field): | ||
| index = int(raw_index) | ||
| if not 0 <= index < count: | ||
| raise ValueError( | ||
| f"CouplerEntryCfg {entry.config.name!r} {field} index {index} is out of range [0, {count})." | ||
| ) | ||
| if owners[index] is not None: | ||
| raise ValueError( | ||
| f"CouplerCfg {field} index {index} is owned by both {owners[index]!r} " | ||
| f"and {entry.config.name!r}." | ||
| ) | ||
| owners[index] = entry.config.name | ||
| return owners |
There was a problem hiding this comment.
SolverCoupled already builds ownership maps for bodies, particles, joints, and shapes, and _build_owner_map() rejects out-of-range and multiply owned indices. Could this retain only the minimal body-owner data needed by the adapter-specific partial-joint check and leave range/overlap validation to Newton?
Delegate native configuration checks to Newton and retain only adapter lifecycle constraints. Preserve proxy collision factories while selecting outer contacts from constructed proxy state.
Simplify coupled solver validation
## Description The Documentation Links job on isaac-sim#9070 fails because the G1 motion preview was renamed from `g1_cr7.mp4` to `g1_jump_and_turn.mp4` on the documentation asset host. [Hugging Face PR #6](https://huggingface.co/datasets/nvidia/isaaclab-docs-assets/discussions/6) confirms a 100% identical file rename. Update the G1 motion-tracking guide and Command Builder to use the renamed asset, preserving both video previews. The old reference is already on `main`, introduced in isaac-sim#9098. [Failing link-check job](https://github.com/isaac-sim/IsaacLab/actions/runs/45206719337/job/137804323431) ## Type of change - Documentation update ## Validation - Renamed video URL: HTTP 200; old URL: HTTP 404. - Lychee v0.24.2 on the updated motion-tracking guide: four links OK, zero errors. - `ISAACLAB_CHANGELOG_BASE_REF=upstream/main uv run --no-sync isaaclab --format`: passed all hooks. - `node --check docs/source/_static/css/environment-browser.js` and `git diff --check`: passed. - Clean Sphinx build attempted locally; blocked during API autosummary imports by missing simulation dependencies in the minimal macOS environment. Full documentation build remains for CI. ## Checklist - [x] I have read and understood the contribution guidelines - [x] I have run the pre-commit checks with `isaaclab --format` - [x] I have made corresponding changes to the documentation - [x] I have validated the changed behavior with focused coverage - No source package changes or test changes; no changelog fragment required.
Description
Depends on #5. This is a review-hardening follow-up for isaac-sim#5834 and targets the same
mym/coupledsolverfeature branch.The change keeps the coupler API shape introduced by the parent PR while making unsupported configurations fail at construction, pinning the Isaac Lab/Newton config contract, removing fragile scene wiring from the shipped task, and adding real coupled-solver runtime coverage.
Review issues addressed
Nested solver lifecycle and execution policy
CouplerCfginstances and nestedmodel_cfgvalues instead of silently discarding outer-manager behavior.project_outside_colliders=True, requires MPM entries to stepin_place, and classifies MPM as internally handling contacts.coupling_modevalidation to construction and types the supported values withLiteral.Ownership, references, and selectors
SceneEntityCfgfailures actionable, rejects selector fields whose asset-local semantics cannot be mapped safely, honorspreserve_order, and documents ancestor-label regex behavior.scene_cfgalias wiring with self-contained full Newton body-label regexes.Proxy contacts, materials, and config forwarding
NewtonShapeCfgdefaults; per-shape overrides remain a separate concern from coupled-solver configuration.None, preserves outer contacts whencollision_pipeline=Noneis explicit, and reuses one checked wrapper for repeated mappings in the same direction.Runtime and documentation
ModelViewinstances, prepare contacts, reset, collide, step, and reset again.NewtonCouplerManagerinheritsNewtonVBDManagerintentionally to reuse deformable builder hooks, coloring/finalization, rendering sync, and contact initialization.Isaac-Lift-Soft-Franka-v0references, the false deformable-to-object migration note, the private-symbol changelog wording, theNewtonShapeCfgdescription, and the broken cross-package Sphinx reference.Stacked changelog note
This PR targets an unmerged feature branch. Three in-flight feature fragments are therefore changed in the final branch diff: one change is inherited from #5, and two correct review findings in the parent feature's release notes. The child PR's immutable-fragment check reports those existing paths, but the finalized feature diff passes the actual upstream gate:
New per-package fragments for this follow-up are also included. The intended integration is to merge or squash this draft into
mym/coupledsolver, after which isaac-sim#5834 contains the final release-note surface.Type of change
Validation
./isaaclab.sh -f69 passed: fullsource/isaaclab_contrib/test/couplingsuite plus construction-time coupling-mode testsc7ae7c7648cd0717df39e5c94b95d5a02c997320./isaaclab.sh -d: full documentation build succeededtools/changelog/cli.py check develop: passedisaacsimpackage; CI retains that coverage.Checklist
./isaaclab.sh --format.CONTRIBUTORS.md.