Skip to content

Brings Newton assets integration tests - #4818

Merged
kellyguo11 merged 23 commits into
isaac-sim:developfrom
AntoineRichard:antoiner/feat/newton_asset_tests
Mar 6, 2026
Merged

kellyguo11 merged 23 commits into
isaac-sim:developfrom
AntoineRichard:antoiner/feat/newton_asset_tests

Conversation

@AntoineRichard

@AntoineRichard AntoineRichard commented Mar 4, 2026 •

Copy link
Copy Markdown
Collaborator

Description

Brings tests to Newton

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)

Checklist

  • I have read and understood the contribution guidelines
  • I have run the pre-commit checks with ./isaaclab.sh --format
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • I have updated the changelog and the corresponding version in the extension's config/extension.toml file
  • I have added my name to the CONTRIBUTORS.md or my name already exists there

@AntoineRichard
AntoineRichard marked this pull request as draft March 4, 2026 17:06
@github-actions github-actions Bot added the isaac-lab Related to Isaac Lab team label Mar 4, 2026
@AntoineRichard AntoineRichard changed the title WIP Brings Newton assets integration tests. Mar 4, 2026
@AntoineRichard AntoineRichard changed the title Brings Newton assets integration tests. Brings Newton assets integration tests Mar 4, 2026
@greptile-apps

greptile-apps Bot commented Mar 4, 2026 •

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR introduces Newton physics backend integration tests for Articulation and RigidObject (2404 and 1286 lines respectively) and fixes several source-level bugs uncovered while writing those tests. The changes span three extension packages: isaaclab_newton (new tests + source fixes), isaaclab (Newton articulation mock for interface tests), and isaaclab_physx (minor body-index robustness fix).

Key source fixes bundled with the tests:

  • NewtonManager.instantiate_builder_from_stage now correctly detects per-env Xform subtrees and loads each as a separate Newton world, setting _num_envs in both the flat and env-Xform code paths (previous omission in the flat path was flagged in review).
  • Articulation and RigidObject now register a PHYSICS_READY callback to rebind simulation data after resets, and the handle is properly deregistered in _clear_callbacks() (addressing the previous memory-leak concern).
  • Bare except: in ArticulationData._create_simulation_bindings replaced with except Exception:.
  • transform.is_contiguous() → transform.is_contiguous (property, not callable) in RigidObjectData — calling it as a method would have returned a truthy bound-method object, effectively disabling the contiguity optimisation path silently.
  • Kernel signatures refactored from body_com_pose_b: wp.transformf to body_com_pos_b: wp.vec3f, correctly reflecting that the COM offset is a pure translation.
  • _newton_sim_context in test_rigid_object.py uses copy.deepcopy to avoid mutating the module-level NEWTON_SIM_CFG singleton across tests (previous mutation issue was flagged in review).

Remaining items worth attention:

  • A dead HEADLESS = True variable in test_articulation.py (never referenced; AppLauncher hardcodes the value).
  • test_spatial_tendons (currently skipped) uses the sim fixture without a matching articulation_type parametrize decorator — removing the skip will immediately cause a FixtureLookupError.
  • test_rigid_body_with_static_friction (currently skipped) parametrizes device as "cuda" instead of the consistent "cuda:0" used everywhere else.

Confidence Score: 3/5

  • Safe to merge after addressing the test_spatial_tendons latent fixture failure and the unused HEADLESS variable; source-level fixes are sound.
  • The PR brings a substantial body of integration tests and resolves all issues previously raised in review (deregistration, _num_envs, bare except, SIM_CFGs coverage, isaacsim_ci markers, NEWTON_SIM_CFG mutation). Two remaining issues are low-risk: the HEADLESS dead variable is cosmetic, and the test_spatial_tendons latent fixture bug is masked by @pytest.mark.skip. The source-level fixes (contiguity property, kernel dtype refactor, multi-env builder) are well-scoped. Score is 3 rather than 4 because the latent fixture failure in test_spatial_tendons means un-skipping that test without further changes will produce a confusing test-collection error rather than a proper skip.
  • source/isaaclab_newton/test/assets/test_articulation.py — HEADLESS dead variable (line 19) and test_spatial_tendons missing articulation_type parametrize (line 2283).

Important Files Changed

Filename Overview
source/isaaclab_newton/test/assets/test_articulation.py New 2404-line Newton articulation integration test file; previously flagged fixture issues (missing articulation_type parametrize, missing SIM_CFGs entries, missing @pytest.mark.isaacsim_ci) are all resolved, but a dead HEADLESS variable and a latent fixture-resolution bug in the skipped test_spatial_tendons remain.
source/isaaclab_newton/test/assets/test_rigid_object.py New 1286-line Newton rigid object test file; the previously reported NEWTON_SIM_CFG mutation issue is fixed by using copy.deepcopy in _newton_sim_context; one skipped test uses "cuda" instead of the consistent "cuda:0" device specifier used everywhere else.
source/isaaclab_newton/isaaclab_newton/assets/articulation/articulation.py Adds _physics_ready_handle registration and deregistration (addressing the previous callback leak concern), switches wp.copy to .assign, and refactors mask resolution into a shared _resolve_mask helper.
source/isaaclab_newton/isaaclab_newton/assets/articulation/articulation_data.py Bare except: replaced with except Exception: as requested; adds optional _sim_bind_body_parent_f binding with a guarded try/except for graceful degradation when the attribute is absent.
source/isaaclab_newton/isaaclab_newton/physics/newton_manager.py Adds multi-env USD loading via instantiate_builder_from_stage; fixes _num_envs assignment in both the flat and env-Xform code paths; wraps notify_model_changed and _simulate in wp.ScopedDevice for CPU correctness; removes the unconditional CUDA assertion to support CPU mode.
source/isaaclab_newton/isaaclab_newton/assets/kernels.py Refactors kernel signatures to accept body_com_pos_b (wp.vec3f) instead of body_com_pose_b (wp.transformf), correctly reflecting that the COM offset is a pure translation with no rotation component.
source/isaaclab_newton/isaaclab_newton/assets/rigid_object/rigid_object_data.py Fixes transform.is_contiguous() → transform.is_contiguous (property access, not a callable); adds lazy initialization guards for body-frame velocity buffers; switches body_mass/body_inertia to use simulation bindings directly instead of cloned tensors.

Sequence Diagram

sequenceDiagram
    participant Test as Integration Test
    participant SimCtx as build_simulation_context
    participant NM as NewtonManager
    participant Art as Articulation / RigidObject
    participant ArtData as ArticulationData / RigidObjectData

    Test->>SimCtx: enter context (NewtonCfg)
    SimCtx->>NM: instantiate_builder_from_stage()
    NM->>NM: scan /World for Env_N Xforms
    alt env Xforms found
        NM->>NM: build prototype from Env_0
        NM->>NM: begin_world() / add_builder(proto) / end_world() per env
        NM-->>NM: _num_envs = len(env_paths)
    else flat load
        NM->>NM: add_usd(stage)
        NM-->>NM: _num_envs = 1
    end
    NM->>NM: build model + state

    Test->>Art: Articulation(cfg)
    Art->>ArtData: ArticulationData(root_view, device)
    Art->>NM: register_callback(PHYSICS_READY, _create_simulation_bindings)
    Note over Art: _physics_ready_handle stored

    Test->>SimCtx: sim.reset()
    SimCtx->>NM: PhysicsEvent.PHYSICS_READY fired
    NM->>ArtData: _create_simulation_bindings()

    loop simulation steps
        Test->>Art: write_data_to_sim()
        Art->>ArtData: .assign() to sim bindings
        Test->>SimCtx: sim.step()
        Test->>Art: update(dt)
    end

    Test->>SimCtx: exit context (teardown)
    SimCtx->>Art: _clear_callbacks()
    Art->>NM: _physics_ready_handle.deregister()
Loading

Last reviewed commit: 530457e

@greptile-apps

greptile-apps Bot commented Mar 4, 2026

Copy link
Copy Markdown
Contributor
Additional Comments (3)

source/isaaclab_newton/test/assets/test_rigid_object.py
Wrong RigidObject import source

RigidObject is imported from isaaclab_physx.assets, but this test file lives under isaaclab_newton. All other Newton tests import assets from isaaclab_newton.assets. This looks like a copy-paste oversight from the PhysX test suite that will cause the tests to exercise the PhysX backend rather than the Newton backend.

from isaaclab_newton.assets import RigidObject

source/isaaclab_newton/isaaclab_newton/physics/newton_manager.py
_num_envs only set in the multi-env branch

cls._num_envs = len(env_paths) is only assigned when env Xforms are detected. When no env Xforms are found (flat loading branch), _num_envs is never updated. If any downstream code reads _num_envs after a flat-load (e.g. in test_articulation.py generate_articulation creates the Env_* prims before calling sim.reset(), so the env branch will be taken — but standalone uses of a flat stage won't be), it will read a stale or undefined value.

Consider setting cls._num_envs = 1 (or the appropriate default) in the flat-loading branch as well.


source/isaaclab_newton/isaaclab_newton/physics/newton_manager.py
Trailing whitespace on blank line

A blank line with 4 spaces of trailing whitespace was inserted before the docstring. This will fail pre-commit formatting checks and is flagged as a checklist item in the PR.

    def step(cls) -> None:
        """Step the physics simulation."""

@AntoineRichard

Copy link
Copy Markdown
Collaborator Author

@greptile

@AntoineRichard
AntoineRichard marked this pull request as ready for review March 5, 2026 17:37
@kellyguo11

Copy link
Copy Markdown
Contributor

could use a formatter run :)

@AntoineRichard
AntoineRichard force-pushed the antoiner/feat/newton_asset_tests branch from 3b72c89 to a47c91b Compare March 6, 2026 11:03
@AntoineRichard

Copy link
Copy Markdown
Collaborator Author

@greptile

@AntoineRichard

Copy link
Copy Markdown
Collaborator Author

@greptile

@kellyguo11
kellyguo11 merged commit 5d602bb into isaac-sim:develop Mar 6, 2026
6 of 11 checks passed
kellyguo11 added a commit that referenced this pull request Mar 6, 2026
# Description

Adds rigid object collections for Newton. Builds ontop of
#4818

## Type of change

- New feature (non-breaking change which adds functionality)

## 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 the `CONTRIBUTORS.md` or my name already
exists there

---------

Signed-off-by: Kelly Guo <[email protected]>
Co-authored-by: Kelly Guo <[email protected]>
@hujc7 hujc7 mentioned this pull request Mar 7, 2026
4 of 5 tasks
ooctipus added a commit that referenced this pull request Oct 8, 2026
# Description

Update Newton to commit `5ea82eef6f7911388025a8df6ccdb172e2fed286` and
MuJoCo/MuJoCo Warp to 3.14. Adapt checkpoint loading, actuator
selection, cable indexing, deformable registration, and visualization to
the changed interfaces. Workspace requirements and wheel metadata use
the same Newton revision.

## Runtime changes and their upstream causes

- **Actuator checkpoints — [Newton
#4347](newton-physics/newton#4347 Newton
removed TorchScript/dict loading. Export existing TorchScript MLP/LSTM
checkpoints to dynamic-batch `.pt2` during USD authoring, preserving
metadata and device placement. Users keep their existing paths and
actuator configurations.
- **Actuator parameters — [Newton
#4430](newton-physics/newton#4430 Selection
caches now belong to each view. Initialize the DOF mapping cache in
Isaac Lab's lightweight PhysX/OVPhysX view and borrow the updated
mapping methods. Remove its duplicate world-mask implementation.
- **Cable indexing — [Newton
#4124](newton-physics/newton#4124 Standalone
cables now include the free root joint. Its child is the root segment,
so the link array already contains every segment. Remove the separate
root binding and `link_count + 1`; use one child-body ID array for
writes. Masked writes and CUDA capture remain covered.
- **Deformable registration — [Newton
#4363](newton-physics/newton#4363 Mesh
builders now record their own surface/volume ranges. Remove Isaac Lab's
duplicate calls to the deleted private recording methods and read the
new records directly.
- **Live plots — [Newton
#4186](newton-physics/newton#4186 Read
histories from `PlotLogger`, their new owner. The old viewer-level
lookups left GL plots empty.
- **Contact visualization — [Newton
#4340](newton-physics/newton#4340 Replace
the removed `sensing_obj_transforms` alias with `sensing_transforms`.
- **Rendering references — [Newton
#4177](newton-physics/newton#4177 Refresh
four ANYmal images for authored mesh normals and USD sharp shading.
Pixel and SSIM tolerances are unchanged. Disabling the upstream
normal-loading change made both affected Newton cases pass against the
old references, confirming the cause.

All seven upstream changes are included in the pinned revision.

## Why the reset code can be removed

The rebind callback was introduced in [Isaac Lab
#4818](#4818), when hard
resets restarted simulation without first dispatching `STOP`. [Isaac Lab
#8027](#8027) subsequently
added `STOP` before model recreation. Assets are now invalidated and
their existing `PHYSICS_READY` initialization constructs new views,
data, and actuators. Rebinding the discarded data is redundant.

The extra callbacks run before asset initialization and access the
previous data's weak view reference. Newton #4430 removed global caches
that accidentally retained those views, exposing `ReferenceError` in
rigid objects and collections. Articulations avoided that error only
because the shared view registry retained their old views; a
joint-wrench sensor initialized first could then select a view of the
old model.

Remove these extra callbacks across rigid objects, collections,
articulations, cables, deformables, and MPM. Clear Newton's old registry
entries and per-model actuator/step hooks before rebuilding. Each data
instance binds once during construction. Remove the rebind-only proxy
branches, timestamp invalidation, actuator-executor rebinding, and
cleanup overrides. Keep articulation's model-init/post-step cleanup and
its separate joint/body ordering setup, which still have callers.

This preserves the existing hard-reset lifetime: reacquire `asset.data`
and its arrays after `sim.reset(soft=False)`. Soft resets retain the
current model and data. The direct `ArticulationData` test now retains
its `ArticulationView` explicitly, matching production ownership instead
of relying on Newton's former global cache.

Existing asset tests now exercise two real hard resets, state writes,
physics steps, fresh data containers, and stable callback counts.
Replace the synthetic array-swap/rebind test and its helper with this
lifecycle check; remove the actuator test whose only caller was the
deleted private rebind method. Extend the existing nested-root sensor
test to initialize the sensor first. This follow-up removes 200
production lines and 449 lines overall, without adding production files,
classes, or helpers.

PhysX and OVPhysX retain their existing reset lifecycle. Inline five
one-use proxy-initialization helpers into buffer creation, and remove
the unused OVPhysX articulation-data invalidation method and its
test-only assertions. Keep PhysX articulation's helper because ordering
changes call it again. This cleanup removes 64 production lines and 14
test lines (76 net lines including two changelog fragments), with no new
helpers or public API changes.

## Validation

Additional PhysX/OVPhysX validation for `6d4202844`: 565 shared
rigid-object, collection, and articulation contract tests passed on CPU
and GPU0, with four existing expected failures. Each file ran in its own
process. The retained OVPhysX ordering-cache test also passed. An AST
comparison confirmed that inlining preserved every initialization
statement and its order; formatting, lint, and changelog checks passed.

Validated `f677d2532` on GPU0. The collection, articulation, deformable,
MPM, and sensor-order regressions failed on `9f5d1c3bd` for the expected
stale-view or accumulating-callback errors and passed with the fix.

148 focused tests passed. Each test file ran in its own process:

```bash
export CUDA_VISIBLE_DEVICES=0 DISPLAY=
export OMNI_KIT_ACCEPT_EULA=YES ACCEPT_EULA=Y
export WARP_CACHE_PATH=/tmp/pr6aii-warp-cache
for test_file in \
  source/isaaclab_newton/test/assets/test_rigid_object.py \
  source/isaaclab_newton/test/assets/test_articulation.py \
  source/isaaclab_newton/test/assets/test_mpm_object.py \
  source/isaaclab_newton/test/assets/test_deformable_object.py \
  source/isaaclab/test/actuators/test_actuator_collection.py \
  source/isaaclab_newton/test/assets/test_newton_actuators_newton.py \
  source/isaaclab_newton/test/sensors/test_joint_wrench_sensor.py; do
  uv run --no-sync python -m pytest "$test_file" -q
done
uv run --no-sync python -m pytest \
  source/isaaclab_newton/test/physics/test_newton_manager_abstraction.py \
  -k 'hard_reset_then_step_runs or graph_capture_preserves_first_step_and_recapture or reset_lands' -q
ISAACLAB_CHANGELOG_BASE_REF=abe7db4f3 uv run --no-sync isaaclab -f
```

The environment included the `test`, `isaacsim`, and
`tetrahedralization` extras. Local disk pressure required moving
compilation temporary files to shared memory; incompatible global Warp
cache entries required using the branch's dedicated cache. No production
workaround, test tolerance, or timeout was added for either environment
issue.

Earlier checks on the same dependency revision covered checkpoint
numerical agreement and variable batches, viewer teardown and markers,
cable masked writes/capture, camera/raycast hard resets, deformable
cloning, wheel metadata, and all four updated image references.

The exact Newton VCS pin still requires Git for installation. [PyPI does
not accept direct-URL
dependencies](https://setuptools.pypa.io/en/stable/userguide/dependency_management.html#direct-url-dependencies),
so a published Newton version containing the required changes is needed
before publishing that dependency metadata to PyPI.

Related viewer work: #8303.

## Type of change

- Bug fix

## Release backport

- [ ] <!-- backport-active-release --> Backport this pull request to the
active release branch after it merges into `develop`

## Checklist

- [x] Read the contribution guidelines
- [x] Ran `uv run isaaclab -f`
- [x] Validated changed behavior with focused tests
- [x] Added changelog fragments for each changed package
- [x] Contributor already listed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

isaac-lab Related to Isaac Lab team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants