Repository navigation
[Newton] Redesign Newton Manager [2c-iii/N] - #8884
Conversation
aedaef9 to
8a209df
Compare
… and velocity writers
# Description Part 2c-ii of the Newton manager redesign ([overview](#8218 (comment))). Follows [2c/N] #8735 (merged). The test overhaul is [2c-iii/N] #8884. ## Reset and FK flags are mask-only `NewtonBackend.invalidate_fk(env_mask, articulation_ids, *, articulation_mask, consume_mask)` and `invalidate_body_state(env_mask, *, consume_mask)` select worlds and articulations with boolean masks only. The flag kernels run one thread per world and take no index selectors, so their launch shape is fixed and any write made through a `_mask` writer can be recorded into a CUDA graph. Resets still call the `_index` writers until mask-based environment resets land. The FK flag kernel is specialized per view with `wp.static` on its articulation count and on whether an articulation mask is given, so it handles no optional arrays at run time. The id-indexed kernels and their dtype dispatch are removed. - **Breaking:** `NewtonManager.invalidate_fk` and `invalidate_body_state` (and the backend methods) no longer take `env_ids`. Pass a boolean `env_mask`, and `articulation_mask` to select view-local articulations. ## Index writes convert ids at the asset boundary Asset `*_index` writes (articulation root and joint state, rigid object root state, rigid object collection body state, cable segments) flag their ids into a per-asset scratch mask with one small kernel and pass that mask on. The backend clears each entry as it reads it (`consume_mask=True`), so the mask starts empty for the next write without a memset. Writes over all environments pass the asset's all-true mask. Collections also flag `body_ids` into a scratch object mask, zeroed after the call when a subset of objects was written. The assets share one `mask_from_ids` helper. ## Asset state writes - Rigid object collection writes use separate index and mask kernels. The mask kernels take only masks and full data, so the index path can later be removed without touching them. - Asset writers flag the backend once per write. The data classes' `_reset_pose` / `_reset_velocity` invalidate only derived caches. - Obtaining write destinations no longer refreshes derived state. ## Deprecated joint-state index writer `Articulation.write_joint_state_to_sim_index` (Newton, PhysX, OVPhysX) emits a `DeprecationWarning`. Use `write_joint_state_to_sim_mask`, or `write_joint_position_to_sim_index` and `write_joint_velocity_to_sim_index`. The lift, locomotion, Franka pour, Rizon coffee and UR10 particle-push resets move to the position and velocity writers. ## Performance RTX PRO 6000 Blackwell, Warp 1.17.0, `main` at `c498443e0`. Environment throughput from `isaaclab benchmark runtime --task <task> --num_envs 4096 --num_steps 1000 --warmup_steps 100 --visualizer none physics=newton_mjwarp`, two alternating sequential rounds after a warm-up run (steps/s): | Task | `main` | this PR | change | |---|---|---|---| | Cartpole (reset-heavy) | 2.67M | 2.63M | −1.4% | | Flat ANYmal-D | 254.3k | 254.7k | +0.2% | Per-call cost of articulation writes, 4096 envs, CUDA, three alternating rounds (host-bound; µs): | Write | `main` | this PR | |---|---|---| | `write_joint_state_to_sim_index` | 61.6 | 57.9 | | `write_joint_position_to_sim_index` | 59.1 | 55.0 | | `write_root_link_pose_to_sim_index` | 71.3 | 78.8 | | `write_root_link_pose_to_sim_mask` | 52.5 | 52.8 | | `write_joint_state_to_sim_mask` | 42.6 | 33.6 | The ids→mask launch adds about 5.5 µs to each `_index` write; root pose index writes are about 7.5 µs slower than on `main`, and reset-heavy Cartpole, which makes four `_index` writes per reset, is 1.4% slower. Mask-based environment resets (a later stage) move resets onto the `_mask` writers. ## Testing Targeted tests pass, run file by file: Newton manager abstraction, two backends, visualization state, articulation and rigid object contracts (all backends), articulation, rigid object and collections, cable, joint coordinates, Newton actuators, MDP events, lift environment config and Warp event capture safety. ## 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 added changelog fragments
8a209df to
d8ebe52
Compare
|
run-ci |
[Medium impact] Reset behavior changes across Newton assets and their task callers. The PR appears safe to merge, with a non-blocking gap in the merged precedence test. Findings
SummaryThe PR splits Newton tests by owner and updates the cache-warming job.
Reviews (1) · Last reviewed commit: "Consolidate the Newton manager and solve..." · Reviewed by Greptile |
| joint.GetPrim().CreateAttribute("physxJoint:armature", Sdf.ValueTypeNames.Float, True).Set(0.21) | ||
| joint.GetPrim().CreateAttribute("newton:friction", Sdf.ValueTypeNames.Double, True).Set(0.31) |
There was a problem hiding this comment.
Newton-versus-PhysX check is missing
The merged test no longer checks that Newton values beat PhysX values. newton:friction competes only with MuJoCo, while physxJoint:armature competes only with MuJoCo. Reversing the Newton and PhysX readers would therefore still pass.
Keep a joint with both newton:armature and physxJoint:armature, using different values, and assert that the Newton value wins. This preserves the distinct check removed with the old precedence test.
There was a problem hiding this comment.
Fixed, a second joint now checks Newton over PhysX armature.
|
run-co |
|
run-ci |
|
run-ci |
There was a problem hiding this comment.
Isaac Lab Review Bot
Needs attention: Implementation (1), Style consistency (2). Other reviewed categories look good.
- PR description: The test-only scope matches the diff; substantiate the 43.7→32.3 s claim with revisions, exact command, hardware/backend, environment count, cache warmup, and measured per-file metric.
- Design and architecture: Architecture looks good.
- Scope and over-engineering: No over-engineering issues.
- API: API changes look good.
- Compatibility and deprecation: No breaking changes identified.
- Implementation: The relocated stateful-actuator test still requests unused
monkeypatch, implying nonexistent setup; remove the fixture parameter. - Style consistency: Relocated wording and compressed assertions obscure intent; name
test_newton_manager.pyin the cache comment and express the two state reads separately. - Test quality: Test quality looks good.
Minor fixes needed. Posted 3 inline findings.
Automated review; human maintainers own approval decisions.
| test_environment_determinism.py, | ||
| test_contrib_environments_kitless.py, | ||
| test_newton_manager_abstraction.py | ||
| test_newton_manager.py |
There was a problem hiding this comment.
🟡 Warning · Style Consistency — Warm-cache comment names ambiguous file
After the rename, the adjacent comment's "Newton solver-matrix file" reads as test_newton_solvers.py, which is not listed and builds no solver. Name test_newton_manager.py explicitly so the Kamino rationale stays checkable.
| with wp.ScopedCapture(device="cpu"): | ||
| assert scene_data.state is manager.backend.state_0 | ||
| assert fks == resets == [] | ||
| assert scene_data.state is scene_data.state is manager.backend.state_0 |
There was a problem hiding this comment.
🟡 Warning · Style Consistency — Chained identity hides deliberate second read
scene_data.state is scene_data.state is ... reads as a tautology; the second property read that proves FK resolves only once is invisible, and a cleanup would silently drop it. Use two separate reads, as the deleted…
| assert counter.numpy()[0] == step + 1 | ||
|
|
||
|
|
||
| def test_stateful_actuators_replay_like_eager_steps_across_decimation_changes(monkeypatch): |
There was a problem hiding this comment.
🟡 Warning · Implementation — Unused monkeypatch fixture parameter
The relocated test no longer patches has_kit or _has_offscreen_render, so monkeypatch is requested but never used, implying setup that does not exist. Drop the parameter.
# Description Part 2d of the Newton manager redesign ([overview](#8218 (comment))). Follows [2c-iii/N] #8884 (merged) and folds in [2e/N] #8737. Builds on @maxkra15's captured-runtime work and its regression coverage. Newton's step folds the decimation loop even when some actuators cannot be captured, and the step, BVH refits, sensor queries and derived asset data work inside a CUDA graph recorded by a caller, such as a whole environment step. Capture follows the Warp, Newton and MuJoCo Warp examples: Warp owns the capture (`wp.ScopedCapture` / `wp.capture_launch`), Torch actuators that are not graphable stay eager, and Warp's blocking stream orders work with Torch's default stream. ## Changes - **Step around the Newton actuators.** Each physics step runs `_before_actuators()` (solver `pre_step`, collision, pre-actuator callbacks), the Newton actuators, then `_after_actuators()` (post-actuator callbacks, solver substeps); `_finish_step()` runs post-step callbacks and sensors once. With capture-safe actuators the whole decimation loop replays from one graph, as before. Actuators that cannot be captured (Torch networks) now run eagerly between captured `_before_actuators` and `_after_actuators` graphs instead of disabling the folded loop, so `handles_decimation()` holds whenever Newton actuators run in the step. Registering a callback or reallocating contacts captures again. - **Record into an enclosing capture.** `NewtonBackend.step`, `refit_bvh`, the Newton Warp renderer and the ray caster record their work into a caller's capture instead of starting or replaying their own graph. Recorded BVH refits run on every replay, because replays cannot consult host timestamps. Solver status checks run only outside capture. - **Live derived data.** `NewtonBackend.live` is true during a step and while a graph is recorded. Derived asset properties (link velocities, COM poses, heading, projected gravity, body-frame velocities, state concatenations) recompute on read in that interval, so step callbacks see the current substep and replays refresh them. Outside it the timestamp caches apply as before. This replaces the `capture_unsafe` guards that raised during capture. - **Model changes before state reads.** Queued model-property edits reach the solver at the next `forward()`, scene-data state read or step, through `NewtonBackend.notify_model_changes`. Fixed-root pose writes queue their edit instead of notifying the solver on every write. - **View rows map to worlds.** `invalidate_fk` maps articulation-view rows to worlds through `model.articulation_world`, so views over a subset or reordering of worlds reset the right worlds, and global articulations get FK without resetting the global world. ## Performance RTX PRO 6000 Blackwell, Warp 1.17.0, `main` at `e44437edc`. `isaaclab benchmark runtime --task <task> --num_envs 4096 --num_steps 1000 --warmup_steps 100 --visualizer none physics=newton_mjwarp`, two alternating sequential rounds after a warm-up run (steps/s): | Task | `main` | this PR | change | |---|---|---|---| | Cartpole | 2.65M | 2.61M | −1.5% | | Flat ANYmal-D | 254.1k | 260.8k | +2.6% | | Flat Go2 (Newton actuators in the step) | 769.0k | 768.3k | 0% | This PR enables, rather than delivers, the larger gain: capturing the whole environment step, recorded by the caller, in a later stage. ## Testing Targeted tests pass, run file by file: Newton manager, solvers, VBD, MJWarp tendon control, MPM reset masks, coupler and custom coupling, visualization state, articulation and rigid object contracts, articulation, rigid object, cable, joint coordinates, Newton actuators, BAM actuator, MPM object, contact sensor, frame transformer, ray caster, IMU, cloner and the visualizer adapter. New coverage includes the decimation order with capture-safe and eager actuators, an outer capture of two backends side by side, FK over reordered view rows with a global articulation, and a derived heading refreshed inside a replayed step. ## 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 added changelog fragments
Description
Part 2c-iii of the Newton manager redesign (overview).
Follows [2c-ii/N] #8870 (merged). Test-only.
Tests
The 1.5k-line
test_newton_manager_abstraction.pymixed solver configs, builder preparation, the manager lifecycleand the step. It is split by owner, and duplicated or restating tests are removed:
physics/test_newton_solvers.pyphysics/test_newton_manager.pyNewtonCfg, the manager lifecycle, and the backend: step order, capture, collision decimation, model changes, contacts, reset masks, independent backends, BVH refitnotification,
collision_cfgrejection, MPM projection and history, VBD BVH rebuild.sensor attributes, four graph-capture cases that covered two paths), and a second schema-precedence test now merged
into the real replication-path test.
test_two_backends.pyfolds into the manager file; two asset tests move toassets/test_articulation.py.Per-file
pytesttime on a warm Warp cache: 43.7 s → 32.3 s, 119 → 88 tests (plus 5 cases moved), 1.7k → 1.3k lines.The manager file also covers 2c-ii's mask-only reset flags: environment and articulation masks, a consumed mask
cleared as it is read, a caller mask left unchanged, and selections accumulating in one backend only.
Testing
test_newton_manager.py,test_newton_solvers.py,test_vbd_core.pyandassets/test_articulation.pypass, run fileby file. New unit tests fail under one-line mutations of the code they guard.
Checklist
pre-commitchecks with./isaaclab.sh --format