Repository navigation
Fix stale rigid asset caches after state writes - #6741
Closed
AntoineRichard wants to merge 48 commits into
Closed
AntoineRichard wants to merge 48 commits into
AntoineRichard wants to merge 48 commits into
Conversation
Translate between public and backend order on the OVPhysX read and write paths: fused user-and-backend writes with persistent target staging separated from transient applied-torque scratch, forward kinematics aware body state refresh, and a fused ordered joint acceleration kernel. Part 6 of the articulation reordering series.
The ordering core rework single-homed the joint and body ordering maps on ArticulationData and removed the mirrored `_has_*` flags and `_*_user_to_backend` maps, the `_cache_ordering_maps` machinery, the `ArticulationNameMap` identity/name fields, and the dtype-suffixed write-kernel overloads. Repoint the OVPhysX articulation and data classes to the new contracts: - Read ordering presence via `data.joint_ordering` / `data.body_ordering` is-not-None checks; conditional sites dereference the map directly, while always-launch sites use the new `_*_user_to_backend_map()` helpers so publish, wrench, and telemetry gathers keep a valid map. - Configure backend staging through `_ordering_configure_backend_staging` and, now that `_install_ordering_flags` is gone, recover the previous per-axis ordering from the persistent backend staging buffers so a cleared ordering still releases its buffers on rebind. - Replace the dtype-suffixed overload launches with the `write_*_user_to_backend_*` launch wrappers, passing the dtype the old suffix implied and dropping the explicit launch dim. Adapt the OVPhysX asset tests to assert through the single-homed ordering maps, since a non-None map now always denotes a real permutation.
Define the remaining hujc7 and ooctipus review work, including live target coverage, property helper consolidation, changelog fixes, stack verification, and GitHub thread closure.
Preserve dedicated pinned buffers for scalar properties and the existing lazy write staging cache for combined friction properties.
Add the shared interface test suite that exercises ordering allocation, write parity, partial writes, and property reordering uniformly across the PhysX, OVPhysX, and Newton backends through their mock views. Lands after all three backend parts because present-but-unwired backends error rather than skip. Part 7 of the articulation reordering series.
The ordering core now keeps a single source of truth for public ordering. Identity orderings resolve to None rather than an identity map, so a non-None map always denotes a real permutation. The mirror flags (_has_joint_ordering / _has_body_ordering on both the asset and data), the _cache_ordering_maps / _ordering_maps_cached guard, and the data _install_ordering_flags helper were all deleted; backends now stage through _ordering_configure_backend_staging(). Adapt the mocked cross-backend interface tests to match: - Re-stage installed orderings via _ordering_configure_backend_staging instead of the removed _cache_ordering_maps guard dance. - Delete the reinvocation-guard test; with one home there is no mirror state left to protect. - Assert ordering presence as (ordering is not None) against the single source instead of the removed mirror flags, keeping one dedicated assert that the asset property delegates to data. - Drop the now-redundant not-is_identity assert halves, since a non-None map already guarantees a permutation.
Keep the backend import-semantics regression with the shared interface utility tests introduced in P5.
Reinterpret structured Warp destinations as float32 before copying mock binding data, matching the real OVPhysX binding contract. Cover transform and spatial-vector destinations while preserving existing flat paths.
Reject Warp destinations whose scalar element type is not float32 before creating a reinterpret view. This preserves structured float reads without silently copying float bit patterns into integer buffers.
Use the shared ordering constants in the gravity-compensation test added on develop. The backend-local constants were removed when P7 consolidated articulation ordering fixtures.
Route event terms through the asset's public index mapping, fix consumers that mixed public-order indices with backend-order view arrays, apply the factory inertia offsets through the asset API, and document the feature: the sim-to-sim transfer guide, the API reference entries, and the changelog fragments for the touched task packages. Part 8 of the articulation reordering series.
A 10-seed paired benchmark measured the feature at 1.06-1.55% lower native training FPS than develop, attributed to write_data_to_sim launching the joint-target gather unconditionally with an identity map. This reverses the unification from 470b4b7ee94 on the strength of that measurement: both actuator branches now branch once in Python and take develop's exact direct-assign path when no joint ordering is configured, and the external-wrench path selects the reorder-free shared kernel when body ordering is identity instead of threading a flag through the ordered kernel every step. Also fuse the post-step publish hook from four reorder launches into two: one kernel gathers joint position and velocity together, one gathers body pose and velocity together.
Resolution errors told users to configure env.scene.robot, which is wrong for direct-workflow tasks. Point at the ArticulationCfg fields instead, which are layout independent.
Drop the two map micro-tests that duplicate the gather-branch coverage of the permutation tests in the same file and the name-map construction coverage in the core ordering suite. The four remaining map tests are the only coverage of the public map_body_ids_to_backend and map_joint_ids_to_backend application paths and stay.
Replace the 108-case partial-write cartesian with a deterministic 12-row all-pairs covering array, verified to cover every parameter pair and seeded on all backend, ordering, and selector triples so each backend still drives both writer kinds under both orderings. Drop the identity value from the shadow-allocation axes, covered by the per-backend identity-matches-none tests, and remove the internal buffer-shape assertions whose behavioral observables are covered by the shared-backend-read and allocation tests. 233 collected cases become 131 with no loss of distinct-branch coverage.
Application coverage of map_body_ids_to_backend and map_joint_ids_to_backend now lives beside the name-map construction tests in the core ordering suite.
In the ordered Lab-actuator branch of write_data_to_sim, the fused target reorder passed the effort buffer as both the effort output (index 0) and the unused joint-act output (index 3). Because write_joint_act is off, index 3 is never written, but the alias creates a false output dependency on the effort buffer under CUDA graph capture. Point index 3 at the dedicated _sim_bind_joint_act buffer, matching the newton-actuator branch.
sync_torque_telemetry mixed the user-space loop index j with the backend-space backend_j. Rename the user-space index to user_j so each index only subscripts arrays of its own order: user-order targets, gains, limits, and outputs at [i, user_j]; backend-order live state and sim-bound effort buffers at [i, backend_j]. The kernel signature is unchanged, so call sites are unaffected.
Document that register_post_step_callback's hook fires exactly once per step() call, reflecting state after all decimation iterations and their solver substeps complete -- not once per substep or per decimation iteration.
The remaining public-order presence re-derivations in write_data_to_sim tested the raw ordering map (self.data.joint_ordering is None). Replace them with the has_joint_ordering property so presence checks read uniformly across the ordering paths. Genuine map-object uses and articulation-level ordering reads are left untouched. No behavior change.
Use the shared ANYmal joint-order fixture after P7 removed the backend-local constant. This keeps the P8 reversed-order regression cases runnable after restacking.
Model the non-Kamino solver path in the ordering event test after develop added solver-specific material handling.
Record stable PhysX ordering reads once and replay their Warp commands. Avoid nested recording during Newton CUDA graph capture, and discard cached commands when articulations reset or ordering buffers are rebound.
Cache stable PhysX and Newton articulation read kernels so repeated property refreshes avoid Python and Warp launch setup. Preserve eager execution for dynamic scalar inputs and invalidate commands only when their captured buffers can change.
Warp returns no recorded command for zero-sized launch dimensions. Treat that result as a completed no-op so fixed and zero-DOF articulations can initialize with read caching enabled.
Cover Warp recording calls that return no launch command in both Newton and PhysX. The regression tests ensure zero-sized read launches remain no-ops without polluting the command cache.
Clarify that the articulation read caching and task environment updates require no user migration. This keeps each Changed entry compliant with the changelog fragment policy.
Invalidate every pose- and velocity-derived cache after same-timestamp state writes across all rigid asset families and backends.
Mirror the production view's float32 reinterpretation in the OVPhysX mock so structured Warp buffers pass through bindings. Construct collection data with the mock view and expose it to writers.
Invalidate cached poses, velocities, and composite states after center-of-mass offset writes across rigid asset backends.
7 tasks done
Collaborator
Author
Collaborator
Author
|
Superseded by #6784, which preserves this PR's commits and ancestry in the aggregate integration branch. |
kellyguo11
added a commit
that referenced
this pull request
Aug 1, 2026
# Description This aggregate PR preserves the ancestry of the articulation reordering and selector stack so it can be reviewed and merged as one coherent change. Merge order preserved in this branch: - #6507 — articulation ordering element-kind refactor - #6479 — P9 cached articulation reads across Newton, PhysX, and OVPhysX, including OVPhysX computed dynamics - #6741 — rigid asset cache invalidation - #6652 — P10 signed `int32`/`int64` selector support inside Warp work kernels - #6740 — P11 per-asset cached `ProxyArray` finder selectors and explicit legacy return modes The P10 commits remain ancestors of P11. The source PRs should stay open and unchanged until this aggregate PR merges; they can then be closed as superseded. Related overlap: #6674. This branch includes the OVPhysX Jacobian, mass-matrix, and gravity-compensation side folded into P9. Key outcomes: - Articulation work kernels accept signed 32-bit and signed 64-bit item selectors without Torch conversion allocations. - Raw kernel APIs use dtype-aware factories while retaining compatibility aliases for deprecated kernels. - Stable articulation reads are cached for Newton, PhysX, and OVPhysX. - OVPhysX exposes computed dynamics through the backend-agnostic articulation data API. - Asset finders provide opt-in cached, immutable `ProxyArray` selectors with zero-copy Torch and Warp views and per-asset LRU ownership. - Implicit legacy finder returns are deprecated; `as_proxy=False` retains them explicitly during migration. - Rigid asset state/property writes invalidate same-timestamp derived caches correctly. - Changelog entries are consolidated to one fragment per touched package. ## Asset performance before and after this PR The table compares the PR merge-base (`a050ceade7`) with the pushed PR head (`00c8c25cb1`) on an RTX 5090 using CUDA, 4,096 instances, 100 warmup calls, and 1,000 measured calls per operation. It contains only timed asset method/property calls; application and benchmark startup are excluded. Values are the equal-weight mean of the per-operation mean latencies for operations present on both revisions. The pre-PR `torch_tensor` mode and post-PR `torch_tensor_int32` mode both generate CUDA `torch.int32` selectors. Lower is better. | Backend | Asset | Matched methods / data properties | API methods, before → after | Data properties, before → after | |---|---|---:|---:|---:| | PhysX | Articulation | 24 / 65 | 129.12 → 90.82 µs (-29.7%) | 6.94 → 5.22 µs (-24.8%) | | PhysX | Rigid object | 13 / 40 | 82.48 → 54.65 µs (-33.7%) | 16.36 → 7.86 µs (-51.9%) | | PhysX | Rigid-object collection | 13 / 69 | 218.32 → 131.36 µs (-39.8%) | 64.13 → 27.86 µs (-56.6%) | | Newton | Articulation | 24 / 64 | 108.64 → 62.01 µs (-42.9%) | 6.48 → 4.70 µs (-27.4%) | | Newton | Rigid object | 8 / 40 | 66.34 → 43.16 µs (-34.9%) | 15.21 → 10.28 µs (-32.5%) | | Newton | Rigid-object collection | 8 / 78 | 83.08 → 50.47 µs (-39.3%) | 37.99 → 12.12 µs (-68.1%) | | OVPhysX | Articulation | 24 / — | 237.21 → 209.79 µs (-11.6%) | Baseline failed preflight¹ | | OVPhysX | Rigid object | 8 / 40 | 144.43 → 142.74 µs (-1.2%) | 18.57 → 15.36 µs (-17.3%) | | OVPhysX | Rigid-object collection | 8 / 78 | 185.65 → 191.17 µs (+3.0%) | 46.75 → 41.31 µs (-11.6%) | API-method latency improved in 8 of 9 backend/asset pairs. Data-property latency improved in every comparable pair. ¹ The merge-base OVPhysX articulation data benchmark fails during `body_com_jacobian_w` preflight, while the post-PR suite passes. That data row is excluded instead of mixing unmatched measurements. The new `int64` and Warp selector modes are also excluded from this before/after table because they have no pre-PR equivalent; the post-PR all-mode matrix passes across all nine backend/asset pairs. ## Type of change - Bug fix (non-breaking change which fixes an issue) - New feature (non-breaking change which adds functionality) - Documentation update ## Verification - Aggregate ordering, dtype-kernel, proxy-cache, consumer, documentation, and benchmark matrix: **868 passed**. - Shared articulation, rigid-object, and rigid-object-collection interface suites: **6,059 passed, 71 skipped, 68 expected failures**. - OVPhysX computed dynamics: **4 CUDA tests passed** and **4 CPU tests passed** in separate processes due the backend process-global device lock. - Changelog tooling: **90 passed**. - `./isaaclab.sh -f`: all hooks passed at the pushed HEAD. - Independent aggregate review: no remaining Critical, Important, or Minor findings. Full Kit-backed PhysX/Newton live asset suites were not completed locally because the available Kit environment timed out during startup; CI should provide that coverage. ## Screenshots Not applicable. ## Checklist - [x] I have read and understood the contribution guidelines - [x] I have run the pre-commit checks with `./isaaclab.sh -f` - [x] I have made corresponding changes to the documentation - [x] My changes generate no unexpected new warnings - [x] I have added tests that prove the fixes and features are effective - [x] I have added one changelog fragment under `source/<pkg>/changelog.d/` for every touched package - [x] My name already exists in `CONTRIBUTORS.md` --------- Co-authored-by: Kelly Guo <[email protected]>
8 tasks done
matthewtrepte
pushed a commit
to matthewtrepte/IsaacLab
that referenced
this pull request
Aug 4, 2026
# Description This aggregate PR preserves the ancestry of the articulation reordering and selector stack so it can be reviewed and merged as one coherent change. Merge order preserved in this branch: - isaac-sim#6507 — articulation ordering element-kind refactor - isaac-sim#6479 — P9 cached articulation reads across Newton, PhysX, and OVPhysX, including OVPhysX computed dynamics - isaac-sim#6741 — rigid asset cache invalidation - isaac-sim#6652 — P10 signed `int32`/`int64` selector support inside Warp work kernels - isaac-sim#6740 — P11 per-asset cached `ProxyArray` finder selectors and explicit legacy return modes The P10 commits remain ancestors of P11. The source PRs should stay open and unchanged until this aggregate PR merges; they can then be closed as superseded. Related overlap: isaac-sim#6674. This branch includes the OVPhysX Jacobian, mass-matrix, and gravity-compensation side folded into P9. Key outcomes: - Articulation work kernels accept signed 32-bit and signed 64-bit item selectors without Torch conversion allocations. - Raw kernel APIs use dtype-aware factories while retaining compatibility aliases for deprecated kernels. - Stable articulation reads are cached for Newton, PhysX, and OVPhysX. - OVPhysX exposes computed dynamics through the backend-agnostic articulation data API. - Asset finders provide opt-in cached, immutable `ProxyArray` selectors with zero-copy Torch and Warp views and per-asset LRU ownership. - Implicit legacy finder returns are deprecated; `as_proxy=False` retains them explicitly during migration. - Rigid asset state/property writes invalidate same-timestamp derived caches correctly. - Changelog entries are consolidated to one fragment per touched package. ## Asset performance before and after this PR The table compares the PR merge-base (`a050ceade7`) with the pushed PR head (`00c8c25cb1`) on an RTX 5090 using CUDA, 4,096 instances, 100 warmup calls, and 1,000 measured calls per operation. It contains only timed asset method/property calls; application and benchmark startup are excluded. Values are the equal-weight mean of the per-operation mean latencies for operations present on both revisions. The pre-PR `torch_tensor` mode and post-PR `torch_tensor_int32` mode both generate CUDA `torch.int32` selectors. Lower is better. | Backend | Asset | Matched methods / data properties | API methods, before → after | Data properties, before → after | |---|---|---:|---:|---:| | PhysX | Articulation | 24 / 65 | 129.12 → 90.82 µs (-29.7%) | 6.94 → 5.22 µs (-24.8%) | | PhysX | Rigid object | 13 / 40 | 82.48 → 54.65 µs (-33.7%) | 16.36 → 7.86 µs (-51.9%) | | PhysX | Rigid-object collection | 13 / 69 | 218.32 → 131.36 µs (-39.8%) | 64.13 → 27.86 µs (-56.6%) | | Newton | Articulation | 24 / 64 | 108.64 → 62.01 µs (-42.9%) | 6.48 → 4.70 µs (-27.4%) | | Newton | Rigid object | 8 / 40 | 66.34 → 43.16 µs (-34.9%) | 15.21 → 10.28 µs (-32.5%) | | Newton | Rigid-object collection | 8 / 78 | 83.08 → 50.47 µs (-39.3%) | 37.99 → 12.12 µs (-68.1%) | | OVPhysX | Articulation | 24 / — | 237.21 → 209.79 µs (-11.6%) | Baseline failed preflight¹ | | OVPhysX | Rigid object | 8 / 40 | 144.43 → 142.74 µs (-1.2%) | 18.57 → 15.36 µs (-17.3%) | | OVPhysX | Rigid-object collection | 8 / 78 | 185.65 → 191.17 µs (+3.0%) | 46.75 → 41.31 µs (-11.6%) | API-method latency improved in 8 of 9 backend/asset pairs. Data-property latency improved in every comparable pair. ¹ The merge-base OVPhysX articulation data benchmark fails during `body_com_jacobian_w` preflight, while the post-PR suite passes. That data row is excluded instead of mixing unmatched measurements. The new `int64` and Warp selector modes are also excluded from this before/after table because they have no pre-PR equivalent; the post-PR all-mode matrix passes across all nine backend/asset pairs. ## Type of change - Bug fix (non-breaking change which fixes an issue) - New feature (non-breaking change which adds functionality) - Documentation update ## Verification - Aggregate ordering, dtype-kernel, proxy-cache, consumer, documentation, and benchmark matrix: **868 passed**. - Shared articulation, rigid-object, and rigid-object-collection interface suites: **6,059 passed, 71 skipped, 68 expected failures**. - OVPhysX computed dynamics: **4 CUDA tests passed** and **4 CPU tests passed** in separate processes due the backend process-global device lock. - Changelog tooling: **90 passed**. - `./isaaclab.sh -f`: all hooks passed at the pushed HEAD. - Independent aggregate review: no remaining Critical, Important, or Minor findings. Full Kit-backed PhysX/Newton live asset suites were not completed locally because the available Kit environment timed out during startup; CI should provide that coverage. ## Screenshots Not applicable. ## Checklist - [x] I have read and understood the contribution guidelines - [x] I have run the pre-commit checks with `./isaaclab.sh -f` - [x] I have made corresponding changes to the documentation - [x] My changes generate no unexpected new warnings - [x] I have added tests that prove the fixes and features are effective - [x] I have added one changelog fragment under `source/<pkg>/changelog.d/` for every touched package - [x] My name already exists in `CONTRIBUTORS.md` --------- Co-authored-by: Kelly Guo <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Depends on #6479.
Simulation state and property writes do not advance
_sim_timestamp, so lazyArticulationData,RigidObjectData, andRigidObjectCollectionDatabuffers could return pre-write values until the next simulation step.This change:
No new dependencies are required.
Type of change
Screenshots
Not applicable.
Testing
./isaaclab.sh -f: all hooks passed.c7ae7c7, while current P9 pinsd7581b7; the installedModelBuilder.replicatelacks P9'sxformsargument. The failing P9 cloner file is unchanged by this branch.Checklist
pre-commitchecks with./isaaclab.sh --formatsource/<pkg>/changelog.d/for every touched package.CONTRIBUTORS.md.