Repository navigation
[5D] Bind Newton consumers to shared native resources - #8027
Conversation
|
run-ci |
|
run-ci |
|
run-ci |
|
run-ci |
|
run-ci |
9c5b283 to
73ad8b4
Compare
|
run-ci |
|
| sim = SimulationContext.instance() | ||
| self.backend = sim.get_or_create_backend(self.newton_cfg) | ||
| self._scene_data_provider = sim.get_scene_data_provider() | ||
| self._transform_mapping = self._scene_data_provider.create_mapping(list(self.backend.model.body_label)) |
There was a problem hiding this comment.
Joint paths break camera binding
With PhysX or OVPhysX physics, a render-only Newton body can be labelled with a USD joint path while scene data publishes the rigid-body path. This passes the joint path directly to create_mapping(), which raises KeyError instead of initializing the Newton Warp camera. The previous binding resolved joint labels to their rigid-body targets; that resolution is still needed here.
Knowledge Base Used: Newton backend
| self.backend = sim.get_or_create_backend(self.newton_cfg) | ||
| self._scene_data_provider = sim.get_scene_data_provider() | ||
| self._transform_mapping = self._scene_data_provider.create_mapping(list(self.backend.model.body_label)) |
There was a problem hiding this comment.
Segmentation retains old models
On a Newton hard reset, initialize() binds the replacement model but leaves _seg_mapper attached to the previous one. The mapper keeps that model and its per-shape mappings, so repeated resets retain native resources that should be released. If the shape layout changes, segmentation also uses mappings for the wrong model. Rebuild the mapper when the model is replaced.
Knowledge Base Used:
| self._camera_sensor = next(iter(cameras.values())) | ||
| self._camera_sensor_indices = env_ids | ||
| self._streaming_view_active = self._viewer._streaming_view_active = True |
There was a problem hiding this comment.
Adopted camera may be undersized
When no streaming camera target is configured, Rerun now adopts the first scene camera without checking its view count. If that camera has fewer views than the selected environments, frame composition indexes past its output and the stream fails. The previous selection skipped cameras whose view count differed from the scene count. Viser has the same unchecked adoption.
Knowledge Base Used: Rendering pipelines and visualizer adapters
There was a problem hiding this comment.
Isaac Lab Review Bot
The shared Newton builder/backend ownership model and per-consumer query graphs are coherent, but the refactor introduces two behavioral regressions in renderer registration and foreign-physics transform binding, and omits the newly public NewtonQueries API from the reference documentation.
- Design and architecture: The retained ModelBuilder plus closable NewtonBackend design keeps ownership on SimulationContext and cleanly separates shared native resources from consumer-owned query graphs. However, consumers now bind raw Newton body labels directly to SDP; removing the prior joint-label-to-rigid-body-path resolution breaks foreign-physics models whose Newton labels identify joints rather than published body prims.
- API: The breaking changes to NewtonManager entry points, NewtonBackendCfg/NewtonBuilderCfg, streaming_cam_renderer_cfg, and create_mapping are documented. Two API integration issues remain: Kit now constructs its streaming renderer without honoring the documented cameras-enabled precondition, and the newly exported NewtonQueries class is missing from the Newton API reference.
- Implementation: Builder acquisition, backend lifecycle, hard-reset rebinding, shared BVH refits, and consumer-owned query graphs were traced. Fix the unconditional renderer acquisition in BaseVisualizer for Kit when cameras are disabled, and restore body-path resolution before strict SDP mapping so foreign-physics consumers do not raise KeyError during initialization.
Minor fixes needed. Posted 3 actionable findings inline.
Automated review; human maintainers own approval decisions.
| self._reset_requested: bool = False | ||
| # Declare the camera renderer before cloning gathers consumer requirements. | ||
| owns_camera = cfg.streaming_sensor_prim_path is None and cfg.streaming_cam_target_prim_path is not None | ||
| if cfg.streaming_view and owns_camera: |
There was a problem hiding this comment.
🟡 Warning · Api — Kit streaming registration drops cameras-enabled guard
KitVisualizer previously registered its streaming renderer only when /isaaclab/cameras_enabled was set. The base-class version drops that condition, so with streaming_view=True and a target prim but no --enable_cameras, IsaacRtxRendererCfg is now constructed (enabling Replicator and RTX global settings) and its errors propagate, contradicting KitVisualizerCfg's documented silent skip. Re-apply the cameras-enabled check before acquiring the renderer.
| sim = SimulationContext.instance() | ||
| self.backend = sim.get_or_create_backend(self.newton_cfg) | ||
| self._scene_data_provider = sim.get_scene_data_provider() | ||
| self._transform_mapping = self._scene_data_provider.create_mapping(list(self.backend.model.body_label)) |
There was a problem hiding this comment.
🟡 Warning · Design Architecture — Raw body labels bypass joint-path resolution
Consumers now pass model.body_label straight to create_mapping, but NewtonManager._resolve_scene_data_body_paths — which mapped Newton joint labels to their target rigid-body prim path — was deleted with its test. Under foreign physics the SDP publishes body prim paths, so a joint-labelled render body no longer resolves and the new strict create_mapping raises KeyError during initialization. Resolve joint labels before binding.
| NewtonManager | ||
| NewtonCfg | ||
| NewtonBackendCfg | ||
| NewtonBuilderCfg |
There was a problem hiding this comment.
🔵 Suggestion · Api — NewtonQueries missing from physics API docs
NewtonQueries is added to isaaclab_newton.physics.__all__ and the __init__.pyi stub as the public home for query and capture functions, but this page only gained NewtonBuilderCfg and create_newton_builder. Add it to the autosummary and an autoclass block so the replacement for the removed manager query gateway is discoverable.
|
run-ci |
…resources (#8099) ## Summary Backports #8027 (`b05a35a0eedda86662f82e663993c2b7046bf94f`) to `release/3.0.0`. Newton cameras, raycasters, and visualizers acquire shared native resources through the simulation registry and consume transforms and geometry through SDP. The original API migration notes and changelog fragments are included unchanged. This is an exact, conflict-free cherry-pick. The prerequisite #8021 is already present on the release branch. No additional refactoring or fixes are included. ## Validation - Exact-patch backport validation passed. - Formatting, lint, and changelog checks passed. - 14 focused registry/lifecycle tests passed. - A broader local test invocation encountered Rerun/package-import collection errors. Further local testing was stopped at the user's request; full package, GPU, rendering, and documentation validation is delegated to CI.
# 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
Summary
Newton cameras, raycasters, and viewers acquire their shared native model and state from the simulation registry. They request transforms and deformable geometry through SDP instead of using the physics manager as a rendering gateway.
ModelBuilder: mutable construction data retained for hard resets. Consumer initialization acquiresNewtonBackend: the finalized model and native buffers, including with PhysX/OVPhysX physics.NewtonBuilderCfgdeclares Python-owned construction data;NewtonBackendCfgdeclares a runtime resource withclose(). Both use the selected physics cfg and the same registry. Configs have no teardown methods.NewtonQueriesfunctions live besideNewtonManager, take an explicit backend, and own no state. Cameras and raycasters own their query graphs. The shared backend usesTimestampedBufferto refit BVHs once per publication change. Raycasters configure the existing builder before finalization, regardless of which consumer acquired it first.streaming_cam_renderer_cfg=OVRTXRendererCfg()(or another renderer cfg), not a nickname. Visualizers register that dependency before cloning. Defaults remain Kit → Isaac RTX and other viewers → Newton Warp; explicit construction errors propagate without renderer substitution.This PR retains the supported single Newton representation for the selected physics configuration. It does not add independently configured consumer models.
NewtonManager.set_builder()is removed; direct-builder callers use the first line above beforesim.reset().NewtonManager.get_state()andupdate_visualization_state()are removed; render consumers acquire the backend and call SDP directly.sync_transforms_to_fabric()and itssync_transforms_to_usd()alias are also removed: rendering-ownedFabricBackend.update_transforms(provider)already requests poses through SDP.The registry calls
resource.close()forBackendCfgresources and drops its reference to plain construction data. A missing backendclose()is an error. SDP validates unique named source/destination paths when binding a layout; subsets and repeatedNonedestination slots remain supported.Built on merged #8021. Relative to the develop base: 380 fewer production lines and 230 fewer test lines.
Matched startup and runtime benchmark
Compared the develop parent immediately before this PR (
2d6ebcce0, #8095) with this PR's merged commit (b05a35a0). Both revisions were measured in fresh processes using the same tasks, dependencies, and GPU 0 (RTX 5090).4096 environments, seed 42, no interactive visualizer, warm caches, 50 excluded warm-up steps and 300 measured steps. FPS is aggregate environment transitions/s over the GPU-completed random-action loop, including action sampling, not video frames/s or training throughput. Newton means MJWarp. Camera tasks use one RGB camera per environment: Cartpole 96×96, Kuka 64×64. No foreign GPU 0 compute process was observed during the measured runs.
Startup is wall time from script entry through the GPU-completed initial reset, including imports and environment creation, excluding the first step. These are warm-cache startup measurements.
Positive bars mean higher throughput after this PR.
xychart-beta horizontal title "Environment FPS change after #8027" x-axis ["Cartpole: Newton → none", "Humanoid: Newton → none", "Kuka Allegro: Newton → none", "Rough Anymal-D: Newton → none", "Cartpole Camera: Newton → Newton", "Kuka Camera: Newton → Newton", "Cartpole: Isaac PhysX → none", "Kuka Allegro: Isaac PhysX → none", "Kuka Camera: Newton → Isaac RTX"] y-axis "Change vs parent (%)" -10 --> 10 bar [0.4, -4.9, -1.5, 9.1, 1.7, 1.4, -3.3, 5.3, 0.4]One measured warm sample per revision and workload. These observations do not establish a performance gain or regression; differences, including the larger startup changes, need repeated measurements before attribution to this PR. Measured 2026-09-28 UTC on a Threadripper PRO 7965WX. Newton 1.6.0, MuJoCo Warp 3.12.0, Warp 1.17.0, Torch 2.12.0+cu130, Isaac Sim 6.1.0-rc.26, NVIDIA driver 580.173.02.
Validation