Repository navigation
feat: GPU-accelerated FrameView local poses + a new xform_space_writer API - #5677
Conversation
There was a problem hiding this comment.
🔍 Code Review Update
Review of new commits: PR was rebased and expanded since last review.
Previously reviewed:b15d6235| Now reviewing:80838c00
Summary
The PR has been expanded from 5 to 6 commits, adding Fabric-accelerated get/set_local_poses:
- Service locator infrastructure on
SimulationContext - Service locator tests + changelog
- Indexed Fabric transform kernels in
isaaclab.utils.warp.fabric FabricStageCacheas a shared hierarchy handle- (NEW) Merge commit to consolidate branches
- (NEW)
FabricFrameViewrewrite withget/set_local_poses+ dirty tracking
✅ New Additions Since Last Review
- Fabric-accelerated local poses:
set_local_poses/get_local_posesnow usewp.indexedfabricarrayto read/writeomni:fabric:localMatrixdirectly on the GPU - Bidirectional world↔local sync:
set_world_poses→ recomputes localMatrix via_sync_local_from_world()set_local_poses→ marks_world_dirty, world recomputed on nextget_world_poses
- Per-view dirty tracking:
_world_dirtyflag is instance-scoped, so concurrent views on the same stage don't clear each other's flag - Parent matrix handling:
_build_parent_indexed_array()+_compute_parent_fabric_indices()for parent world matrix lookups - Topology-adaptive:
PrepareForReuse()calls +_rebuild_trans_ro_arrays()for automatic recovery - Comprehensive tests: 13 new integration tests covering local/world consistency, rotated/scaled parents, multi-view isolation
🔧 Remaining Observations
[Minor] Index array dtype mismatch still present
The kernels declare indices: ArrayUInt32, but _compute_fabric_indices() returns dtype=wp.int32:
# fabric_frame_view.py
return wp.array(indices, dtype=wp.int32, device=self._device)Warp will silently cast, so this works in practice. Suggestion: switch to dtype=wp.uint32 for consistency with the kernel signatures. Not blocking.
[Minor] Undefined buffer references in get_local_poses
get_local_poses references self._fabric_local_translations_buf and self._fabric_local_orientations_buf:
if use_cached:
translations_wp = self._fabric_local_translations_buf
orientations_wp = self._fabric_local_orientations_bufThese don't appear to be initialized in _initialize_fabric(). Verify these buffers are created alongside the existing world-pose buffers.
📋 Architecture Notes
The world↔local propagation design is clean:
- Write world → update local:
_sync_local_from_world()runsupdate_indexed_local_matrix_from_worldkernel immediately after world writes - Write local → lazy world update:
_world_dirtyflag defersupdate_indexed_world_matrix_from_localuntil the next world read
This asymmetry makes sense: world writes are typically followed by physics steps (which don't need locals), while local writes are often followed by world reads for rendering.
📋 Verdict
LGTM — the new local-pose acceleration is a significant feature addition. The bidirectional sync logic is well-designed, and the test coverage is comprehensive (33 test functions across all new modules). The minor dtype observation from the previous review remains, plus one potential undefined buffer issue to double-check.
Automated review by isaaclab-review-bot • Reviewed at 80838c00
There was a problem hiding this comment.
🔍 Code Review Update
Review of new commits: PR was rebased and expanded since last review.
Previously reviewed:eb5582ec| Now reviewing:9ff3155
Summary
This PR delivers a well-architected feature: GPU-accelerated local-pose operations for FabricFrameView. The implementation is comprehensive and addresses the core limitation where local poses previously fell back to USD round-trips.
✅ Strengths
1. Clean Architecture
FabricStageCacheprovides shared hierarchy handles via the service locator pattern, avoiding per-view duplication- Three persistent selections (
trans_sel_ro,world_sel_rw,local_sel_rw) cleanly separate read vs. write access patterns - Factory dispatch in
FrameView._get_backend()correctly routes toUsdFrameViewwhen Fabric is unavailable
2. Robust World↔Local Consistency
- Bidirectional dirty tracking:
set_local_posesmarks_world_dirty, deferred until next world read _sync_local_from_world()/_sync_world_from_local_if_dirty()keep matrices consistent- Per-view dirty flags prevent concurrent views from clearing each other's pending syncs
3. Topology-Adaptive Design
PrepareForReuse()+ lazy array rebuild in_get_*_array()handles Fabric memory layout changes_rebuild_trans_ro_arrays()consolidates index and indexed-array refresh
4. Excellent Test Coverage
- 13+ new integration tests covering rotated parents, scaled parents, multi-view isolation
test_set_local_then_get_world_with_rotated_parentvalidates transpose-convention correctnesstest_multi_view_per_view_dirty_isolationcatches per-stage vs. per-view flag bugs
🔧 Minor Observations
[Minor] Index array dtype mismatch
_compute_fabric_indices() returns dtype=wp.int32, but kernels declare indices: ArrayUInt32:
return wp.array(indices, dtype=wp.int32, device=self._device)Warp silently casts, so this works. Suggestion: use dtype=wp.uint32 for consistency with kernel signatures. Not blocking.
[Nit] Docstring transpose-convention note
The docstrings for update_indexed_local_matrix_from_world and update_indexed_world_matrix_from_local explain the transpose identity well. Consider adding a brief note that this relies on Fabric's row-major storage convention for future maintainers.
[Style] Empty sentinel shape
_fabric_empty_2d_array_sentinel uses shape (0, 0):
self._fabric_empty_2d_array_sentinel = wp.zeros((0, 0), dtype=wp.float32, device=self._device)This is fine since the kernels gate on shape[0] > 0, but (0, 3) or (0, 4) might be slightly more self-documenting for unused position/quaternion slots.
📋 Architecture Notes
The asymmetric sync strategy is well-reasoned:
- Write world → sync local immediately:
_sync_local_from_world()runs right after world writes because downstream code (e.g., rendering) typically reads locals soon after - Write local → lazy world sync:
_world_dirtyflag defers theworld = parent * localkernel until the next world read, avoiding unnecessary computation when multiple local writes occur before a world read
📋 CI Status
CI checks are currently pending. The pre-commit and changelog checks have passed.
📋 Verdict
LGTM — This is a significant feature addition that completes the Fabric acceleration story for FabricFrameView. The bidirectional sync logic is sound, test coverage is thorough, and the codebase is well-documented. The minor dtype observation is non-blocking.
Automated review by isaaclab-review-bot • Reviewed at 9ff31550
Update (d13ed999→7f1a012c): Reviewed large incremental batch (50+ files changed). This batch contains no changes to the core FabricFrameView implementation — the Fabric local-poses feature code is identical to the previously reviewed state.
Key changes in this batch (all outside the PR's core feature scope):
-
isaaclab_ppispmade fully optional: All packages (isaaclab_physx,isaaclab_newton,isaaclab_ov,isaaclab_ovphysx) removed hardisaaclab_ppispfromdependencies. Lazytry/except ModuleNotFoundErrorwith_raise_missing_ppisp_error()helper provides actionable install hints only whenisp_cfgis actually set. Clean pattern, consistently applied. -
Cloner refactoring to
ReplicateContextclasses:physx_replicate,newton_physics_replicate, andovphysx_replicatelegacy functions now delegate to newPhysxReplicateContext,NewtonReplicateContext, andOvPhysxReplicateContextclasses. Asset constructors callqueue_*_replication(cfg)to register onREPLICATION_QUEUE. Well-structured — separates queueing from execution, enables batched replication. -
MJWarp
ls_paralleldeprecated: Config field emitsDeprecationWarningvia__post_init__(),_build_solver()ignores it. Removed from all test configurations. -
Newton manager lifecycle fix:
close()now callssuper().close()beforecls.clear(), ensuring sensor invalidation callbacks fire while Newton state is still alive, preventing stale registrations leaking. -
OvPhysX/OVRTX runtime guards:
import_ovphysx()helper with actionable install messages,ovphysx==0.4.13pin. -
PhysxManager rigid body view: Now detects name collisions between rigid and non-rigid prims (e.g.,
JointWrenchSensorframe prim vs. rigid link with same name) and uses exact paths for ambiguous names. -
Version bumps and changelog consolidation: All changelog fragment files moved into proper versioned CHANGELOG.rst entries.
Previous inline comments status:
- ⏳ P1 (Missing
wp.synchronize()in indexed getter paths): Still present — no changes tofabric_frame_view.pyin this batch. Remains non-blocking per previous assessment. - ✅ P2 (Redundant kernel launch): Fixed in earlier commits (confirmed).
No new issues found in the incremental changes. All additions are well-implemented and follow established patterns. LGTM.
Automated incremental review by isaaclab-review-bot • Reviewed at 7f1a012c
Update (7f1a012c→999cf3c6): Major architectural refactor reviewed.
Changes in this batch
The lazy dirty-flag mechanism (_DirtyFlag enum, _dirty field, _sync_*_if_dirty helpers, interleaved-write warning) has been removed entirely and replaced with a context-managed writer scope API (FrameViewSpaceWriterBase). This is a substantial and well-executed improvement:
-
New
xform_space_writer()context manager: Opens a scoped write session ("world"or"local"). On__exit__, derives the opposite-space matrices once via a single Warp kernel and callswp.synchronize()once. Clean, predictable, no more subtle interleaving bugs. -
Single-active-writer invariant: Per-view lock prevents concurrent scopes —
RuntimeErroron double-entry. Well-tested. -
Hierarchy listener pause/restore:
_FabricWriterMixin._enter_impl()pausestrack_local_xform_changes/track_world_xform_changesduring writes, restoring prior state on exit. Correctly handles pre-paused listeners (no accidental re-enable). -
Deprecated shims preserved:
set_world_poses()/set_local_poses()remain as thin wrappers that open one-shot writer scopes internally + emitDeprecationWarning. Clean migration path. -
set_world_scales/set_local_scalesremoved (breaking): Since these were introduced in this release cycle without stable downstream users, removal without deprecation is appropriate. Changelog documents it. -
Test coverage: Comprehensive new tests for the writer contract — single-active invariant, derive-on-exit counting, empty-scope no-op, getter-raises-inside-scope, hierarchy tracking restore.
Previous comments status
- ✅ P2 (Redundant kernel launch): Fixed — the
_sync_fabric_from_usd_initial()path now only composes localMatrix then calls_recompute_world_from_local_all(). The redundant world compose is gone. - ⏳ P1 (Missing
wp.synchronize()in indexed getter paths): Still present in the non-cached decompose paths. Remains non-blocking per previous assessment (callers on the same CUDA stream see correct ordering; only cross-stream or immediate.numpy()usage is affected). - ✅ Minor observations (dtype, docstring, sentinel shape): These were non-blocking nits and remain unchanged. The sentinel shape
(0, 0)is now less relevant since it is only used internally by the writer compose kernel.
New observations
No new issues found. The architectural shift from lazy dirty-flag tracking to eager derive-on-scope-exit is a clear improvement in correctness and readability. The _FabricWriterMixin pattern cleanly separates Fabric lifecycle management from the write logic. LGTM.
Automated incremental review by isaaclab-review-bot • Reviewed at 999cf3c6
|
Superseded by the consolidated PR #5728 (pv/fabric-full-stack). |
Greptile SummaryThis PR adds Fabric-accelerated
Confidence Score: 4/5Safe to merge after resolving the shared scales buffer in FabricFrameView; all other changes are correct and well-tested. The core dirty-flag design, indexed kernel math, and world↔local propagation are sound and well-covered by the new test suite. The one functional defect is that get_world_scales and get_local_scales write into the same pre-allocated buffer, so calling both on the same view in sequence silently returns stale data from the second call in the first caller's handle — unlike the pose buffers which are correctly kept separate. source/isaaclab_physx/isaaclab_physx/sim/views/fabric_frame_view.py — the shared _fabric_scales_buf between get_world_scales and get_local_scales needs a separate buffer per getter, mirroring the pose buffer pattern. Important Files Changed
Sequence DiagramsequenceDiagram
participant User
participant FFV as FabricFrameView
participant Kernel as Warp Kernels
participant Fabric as Fabric (GPU)
Note over FFV: _dirty = NONE (initial)
User->>FFV: set_local_poses(translations, orientations)
FFV->>FFV: _sync_world_from_local_if_dirty() [no-op]
FFV->>Kernel: compose_indexed_fabric_transforms(localMatrix)
Kernel->>Fabric: write localMatrix
FFV->>FFV: "_dirty = WORLD"
User->>FFV: get_world_poses()
FFV->>FFV: _sync_world_from_local_if_dirty() [fires]
FFV->>Kernel: update_indexed_world_matrix_from_local
Kernel->>Fabric: "worldMatrix = parentWorld x childLocal"
FFV->>FFV: "_dirty = NONE"
FFV->>Kernel: decompose_indexed_fabric_transforms(worldMatrix)
FFV-->>User: (positions, orientations)
User->>FFV: set_world_scales(scales)
FFV->>FFV: _sync_world_from_local_if_dirty() [no-op]
FFV->>Kernel: compose_indexed_fabric_transforms(worldMatrix, scale only)
Kernel->>Fabric: RMW worldMatrix scale
FFV->>FFV: "_dirty = LOCAL"
User->>FFV: get_local_scales()
FFV->>FFV: _sync_local_from_world_if_dirty() [fires]
FFV->>Kernel: update_indexed_local_matrix_from_world
Kernel->>Fabric: "localMatrix = inv(parentWorld) x childWorld"
FFV->>FFV: "_dirty = NONE"
FFV->>Kernel: decompose_indexed_fabric_transforms(localMatrix)
FFV-->>User: ProxyArray(scales)
Reviews (2): Last reviewed commit: "feat: add tests for world and local scal..." | Re-trigger Greptile |
| if use_cached: | ||
| wp.synchronize() | ||
| return self._fabric_local_translations_ta, self._fabric_local_orientations_ta | ||
| return ProxyArray(translations_wp), ProxyArray(orientations_wp) |
There was a problem hiding this comment.
Missing
wp.synchronize() in indexed (non-cached) getter path
When indices is provided, the Warp kernel is launched but control returns to the caller before the GPU has finished writing. Callers that immediately do .numpy() or wp.to_torch() on the returned ProxyArray can read stale zeros. The cached path (lines 384-386) correctly calls wp.synchronize() before returning, proving this is an oversight rather than intentional. The same issue exists in get_world_poses (line 292) and get_scales (line 473), but this PR introduces the new get_local_poses Fabric path — all three non-cached returns should add a wp.synchronize() call.
| # Compose into child worldMatrix. | ||
| wp.launch( | ||
| kernel=fabric_utils.compose_indexed_fabric_transforms, | ||
| dim=self.count, | ||
| inputs=[ | ||
| self._world_ifa, | ||
| _to_float32_2d(pos_ta.warp), | ||
| _to_float32_2d(ori_ta.warp), | ||
| _to_float32_2d(scales_wp), | ||
| False, | ||
| False, | ||
| False, | ||
| self._view_indices, | ||
| ], | ||
| device=self._device, | ||
| ) |
There was a problem hiding this comment.
Redundant kernel launch for child worldMatrix
The compose kernel here writes the child worldMatrix using pos_ta (world pos), ori_ta (world ori) and scales_wp (local scale, not world scale). The scale is already wrong for a parent with non-unit scale, but more critically _recompute_world_from_local() at line 812 immediately overwrites the result of this launch with parent_world × child_local. The first kernel launch can be removed entirely — only the localMatrix compose (lines 743-757) and the parent worldMatrix compose are load-bearing before _recompute_world_from_local().
🔄 Incremental Review Update
SummaryThis batch completes the Fabric-accelerated local-pose implementation. The core feature is production-ready. ✅ Verified in New CommitsFabricFrameView local-pose operations (GPU-accelerated):
Scale API redesign:
Test coverage:
📋 Previous Inline Comments Status
P1 note: 📋 Minor Observations (Unchanged, Non-blocking)
✅ VerdictLGTM — No new issues found. Core feature is complete with excellent test coverage. Automated review by isaaclab-review-bot • Reviewed at |
…pagation Add Warp kernels that operate on wp.indexedfabricarray for direct local↔world matrix propagation without round-tripping through USD: - decompose_indexed_fabric_transforms: extract pos/quat/scale from ifa - compose_indexed_fabric_transforms: write pos/quat/scale into ifa - update_indexed_local_matrix_from_world: local = inv(parent) * world - update_indexed_world_matrix_from_local: world = parent * local Also refactor existing kernels to use wp.where (branchless) instead of if/else for broadcast index selection. These kernels are the foundation for Fabric-accelerated get/set_local_poses in FabricFrameView.
- Replace indexedfabricarray hacks with plain wp.array(dtype=wp.mat44d) test kernels - Test kernels mirror production math: local^T = world^T * inv(parent^T) - Add 5 tests for world↔local transforms including non-orthogonal/sheared cases - All tests run on CPU without USDRT/Fabric runtime - Convert existing class-based tests to plain functions (IsaacLab guideline)
- Add _local_from_world() and _world_from_local() as @wp.func - Production fabric kernels delegate to these shared funcs - Test kernels import and call the same funcs via wp.array adapters - Zero copy-pasted math: tests exercise identical code paths as production
- Add _local_from_world_transposed() and _world_from_local_transposed() as @wp.func (names make explicit they operate on transposed storage matrices) - Production fabric kernels delegate to these shared funcs - Test kernels import and call the same funcs via wp.array adapters - Remove __all__ (not an IsaacLab convention) - Remove importability/export tests (unnecessary) - Remove batch test (Warp handles batching) - Add inline det != 0 assertions to world↔local tests
The world-body fallback in NewtonSiteFrameView._resolve_source_prim resolved the reference prim directly from source_root, instead of stripping the clone-template suffix as the prior code did. For heterogeneous (multi-asset spawner) scenes this resolved the wrong reference frame, offsetting site world poses and breaking rendering-correctness (dexsuite kuka hetero kitless). Restore the split_clone_template/get_suffix-based ref_path computation (and the dropped imports). Homogeneous scenes were unaffected; hetero rgb/depth now match golden images again.
|
|
||
| # -- get_world_scales ---------------------------------------------- | ||
| if is_newton: | ||
| torch.cuda.synchronize() |
There was a problem hiding this comment.
we could use wp.synchronize directly here instead of torch
| DeprecationWarning, | ||
| stacklevel=2, | ||
| ) | ||
| with self.xform_world_space_writer() as writer: |
There was a problem hiding this comment.
I think forcing users to apply the scope could be extra complexity burden on the users. what if we don't deprecate these APIs so that users can still use them if they want to, but we still update our examples to use the scopes so that we get the performance benefit? so we leave both options available, depending on whether users want extra performance / more code complexity or code simplicity / possibly lower perf
…e setters as convenience APIs (undeprecate)
Reconcile against the split-out changes that have since merged: - Drop the renderer-pinning ISAACLAB_PIN_KIT_GPU block and its changelog fragment; superseded by isaac-sim#5933 (default one-GPU + ISAACLAB_FABRIC_USE_GPU_INTEROP). - Drop the inline newton_manager.py torch/Warp device pins and take develop's version; superseded by isaac-sim#6322 (centralized set_cuda_device + ScopedCapture(device=device)). - Resolve test_views_xform_prim_fabric.py: keep develop's isaac-sim#5677/isaac-sim#5380 test bodies, retain the device_scope test_devices() parametrization.
…r API (isaac-sim#5677) # Fast GPU pose/scale ops on Fabric + a new writer-scope API ## What this does Two things: 1. **Local-space pose and scale ops are now GPU-fast on the Fabric backend.** They go through the same Warp-kernel path that world-space ops already used. The old USD fallback for local-space is ~100× slower (see the table below). 2. **All transform writes go through a small context manager.** You open a scope, do your writes inside it, and the scope handles the cleanup: ```python with view.xform_world_space_writer() as writer: writer.set_poses(positions=p, orientations=o) writer.set_scales(scales=s) ``` Use `view.xform_local_space_writer()` for local-space writes. Builds on Piotr's prototype at [`bareya/pbarejko/camera-update`](https://github.com/bareya/IsaacLab/tree/pbarejko/camera-update). ## Why a scope? A FrameView keeps two copies of each prim's transform in Fabric storage: the `omni:fabric:worldMatrix` and `omni:fabric:localMatrix` attributes. When you write one, the other has to be recomputed so they stay consistent. Without a scope, that recompute has to run after every single write. With a scope, it runs **once**, when the scope closes. You can call `set_poses` and `set_scales` as many times as you want inside the scope; on exit, one Warp kernel derives the other space and one `wp.synchronize()` runs. Empty scopes cost nothing. The scope also pauses **Fabric Hierarchy**'s transform-change tracking while you're writing, then restores it on exit. (Fabric itself is just the data store; Fabric Hierarchy, exposed through USDRT's `IFabricHierarchy`, is the plugin that watches writes to `omni:fabric:localMatrix` / `omni:fabric:worldMatrix` and keeps them mutually consistent across the hierarchy.) Its tracking is pull-based: a per-attribute listener records writes into a changelog, and the plugin drains and processes that changelog on the next call to `IFabricHierarchy::update_world_xforms()`. Pausing the listener does not block the writes themselves — they still land in Fabric storage — it just keeps them out of the changelog. With the changelog empty, the next tick has nothing to "catch up on" for these prims, and can't decide one of the two spaces is canonical and derive the other from it. See the next section for why that matters. Rules: - Only one writer can be open on a view at a time. Opening a second one raises `RuntimeError`. - While a writer is open, the view's own getters (`get_world_poses`, etc.) raise. Read through the writer (`writer.get_poses()`) inside the scope, or close the scope first. - **Do not advance the simulation or render from inside the scope.** No `sim.step()`, no `world.render()`, no `SimulationApp.update()`. The matrices are mid-write until exit, and rendering against that state would read torn data. Keep scopes short and close them before stepping. - If something raises inside the scope (a user-code bug, a notebook cell interrupt, etc.), the scope still runs the opposite-space recompute on exit so the world and local matrices stay consistent prim-by-prim. The partial write itself is not rolled back — if you need all-or-nothing, snapshot the matrices yourself before entering. ## Why we have to coordinate with Fabric Hierarchy (renderer correctness) A writer scope is synchronous Python code, so the renderer can't see anything mid-scope — no tick runs until we exit. The risk is on the **next** render/sim tick after the scope closes. On that next tick, Fabric Hierarchy runs its `IFabricHierarchy::update_world_xforms()` step, which can recompute `omni:fabric:worldMatrix` from `omni:fabric:localMatrix` (or vice versa). If it thinks one of the two was the user's most recent edit, it derives the other from it; the derived value — not what we wrote — is then what the **Fabric Scene Delegate (FSD)** hands to RTX on the render path. Three things in this PR keep that next-tick recompute from clobbering our work: 1. **Opposite-space derive at scope exit.** By the time the scope closes, `omni:fabric:worldMatrix` and `omni:fabric:localMatrix` are mutually consistent prim-by-prim, so any recompute Fabric Hierarchy does is a no-op. 2. **Fabric-Hierarchy change tracking is paused for the whole scope.** The writer calls `track_local_xform_changes(False)` and `track_world_xform_changes(False)` on enter (saving the prior state) and restores them on exit. While tracking is paused, the listeners don't record our writes in their changelog, so when the next tick runs there's nothing for `update_world_xforms()` to "catch up on". 3. **Two persistent selections with explicit read-only / read-write flags.** Outside the scope, the view's selection is fully read-only — both `omni:fabric:worldMatrix` and `omni:fabric:localMatrix` are flagged RO. Inside the scope, the writer flips to a fully read-write selection. ``` _sel_ro : worldMatrix=RO, localMatrix=RO (steady state, between writes) _sel_rw : worldMatrix=RW, localMatrix=RW (active during a writer scope) ``` Both selections are built once when the view is initialized and kept alive for its lifetime. The writer scope flips a single flag (`_is_rw`) on enter/exit; nothing is rebuilt. The RO steady state tells Fabric Hierarchy's next-tick `update_world_xforms()` that no attribute is user-authored, so it leaves both alone. ## Backend support - **Fabric (PhysX):** the fast GPU path described above. - **USD, Newton, OVPhysX:** the writer is a thin wrapper. Writes go straight to the backend's existing storage. No batching, no extra recompute (there is no second matrix to keep in sync). Same API across all four backends. Newton has two different "scale" ideas, and the API keeps them apart: - `NewtonSiteFrameView.set_scales(...)` (deprecated) writes the **Newton collision-shape geometry** size. - The writer's `set_scales(...)` writes per-site **transform scale**, matching what USD FrameView does. They operate on different state and are not merged. ## API changes **New (recommended):** - `view.xform_world_space_writer()` / `view.xform_local_space_writer()` — a context manager with `set_poses`, `set_scales`, `get_poses`, `get_scales`. **Deprecated (still works, warns once per class on first use):** - `set_world_poses` / `set_local_poses` — use the writer scope. - `get_scales` / `set_scales` — use `get_local_scales` / `get_world_scales`, or the writer's `set_scales`. ## Benchmark (1024 prims, 50 iterations, Blackwell RTX PRO 5000) Per-iteration timings (lower is better): | Operation | USD (ms) | Fabric (ms) | Newton Site (ms) | |----------------------------|---------:|------------:|-----------------:| | Get World Poses | 8.6148 | 0.0375 | 0.0307 | | Set World Poses | 19.1357 | 0.1090 | 0.0368 | | Get Local Poses | 5.9556 | 0.0374 | 0.0497 | | Set Local Poses | 7.9794 | 0.0979 | 0.0790 | | Get World Scales | 13.1193 | 0.0371 | 0.0015 | | Set World Scales | 21.4571 | 0.1014 | 0.0612 | | Get Local Scales | 3.2544 | 0.0375 | 0.0022 | | Set Local Scales | 3.8350 | 0.0937 | 0.0587 | | Get Both (World+Local) | 14.7506 | 0.0738 | 0.1302 | | Interleaved World Set→Get | 28.1046 | 0.1432 | 0.1588 | | **Per-iter total** | **126.2** | **0.77** | **0.61** | Speedup vs USD (per-iter ops; one-time view construction excluded): | Operation | Fabric × | Newton Site × | |----------------------------|---------:|--------------:| | Get World Poses | 229.6× | 280.2× | | Set World Poses | 175.6× | 519.8× | | Get Local Poses | 159.0× | 119.9× | | Set Local Poses | 81.5× | 101.0× | | Get World Scales | 353.9× | 8911.5× | | Set World Scales | 211.6× | 350.4× | | Get Local Scales | 86.8× | 1489.9× | | Set Local Scales | 40.9× | 65.4× | | Get Both (World+Local) | 200.0× | 113.3× | | Interleaved World Set→Get | 196.2× | 177.0× | | **Overall (per-iter)** | **164×** | **207×** | One-time view construction (reported separately, not part of the per-iter total): USD 4.6 ms, Fabric 4.4 ms, Newton Site 1013 ms — the Newton number is dominated by stage population on the first call. Steady-state per-iteration cost is what the speedup row reflects. ## Notes for reviewers - Getters call `wp.synchronize()` before returning, so the returned `ProxyArray` is always immediately readable from both GPU and host code — no caller-side sync needed. (Both the cached and the per-indices paths sync; this used to be asymmetric.) --------- Co-authored-by: pv-nvidia <[email protected]> Co-authored-by: pv-nvidia <{"message":"Not Found","documentation_url":"https://docs.github.com/rest/users/emails#list-email-addresses-for-the-authenticated-user","status":"404"}>
) # Description Camera world-pose resolution stalled at high environment counts on the PhysX backend, badly enough to time out benchmarks. There are two independent bottlenecks; the PR also adds a lifecycle hook that came out of review. ### 1. `FabricFrameView` resolved prim paths on the host, against the whole stage Cameras read their poses from Fabric. To do that the frame view needs to know where each camera's data sits in Fabric memory, so it builds a lookup table from "camera number" to "Fabric slot". Building that table was very slow. The view selected prims by requiring the Fabric world and local matrix attributes — but every xformable in the stage carries those, so the selection matched the **entire stage** (~1.1M prims at 8192 environments), not the view's handful of cameras. Finding its own prims in that list then meant building a Python dictionary over all of it, on the host: ```python path_to_idx = {str(p): i for i, p in enumerate(selection.GetPaths())} ``` That ran twice per rebuild (once for the children, once for their parents), and rebuilt whenever `PrepareForReuse()` reported a bucket change — in practice on every environment reset. The cost of that dictionary scales with the size of the whole scene, not with the number of cameras: it converts every path in the stage to a Python string and inserts it. Measured directly, one full rebuild takes 10 ms on a bare stage but **556 ms once 100k unrelated prims are present** (table below), and it grows linearly from there — seconds of host work per reset at the ~1.1M prims of an 8192-environment scene. **Fix:** author a private per-view `uint` index attribute on each managed prim (and on each unique parent), holding that prim's view index. Every selection requires the matching index attribute, so **selections resolve to exactly the view's prims**. The view-to-Fabric slot mapping is then rebuilt by inverting that attribute in a single Warp kernel launch: ```python fabric_slots[view_indices[fabric_slot]] = fabric_slot ``` That is `O(view)` device work with no host-side path resolution and no Python objects created per frame. There is also **no cache**, so there is nothing to invalidate. The table is rebuilt from live Fabric data on every access, which means a bucket reorder can never leave a stale mapping behind. Selections are still checked with `GetCount()`, which is exact here: the index attribute belongs to one view, so the count can only change if one of that view's prims actually disappeared — and then the view raises a clear error instead of silently reading the wrong prim. Attribute names embed a process-wide monotonic uid, so a dead view's leftover attributes can never satisfy a live view's selection — and since review, they are removed outright when the view is released (section 3). Parent reads get their own read-only selection, keeping the child RO/RW flip semantics from #5677 intact. ### 2. `SceneDataProvider.create_mapping` did a linear scan per item ```python for i, path in enumerate(input_paths): mapping[i] = paths.index(path) # O(N) scan, per path ``` **Fix:** build the reverse dict once (first occurrence wins, matching `list.index` semantics), then resolve each path in `O(1)`. Measured over 200k paths, preserving first-occurrence semantics costs nothing versus an unguarded dict comprehension, so the fix carries no behaviour change. ### 3. Index attributes are removed when a view is released (from review) The per-view index attributes from fix 1 were initially never removed, so views recreated over the same prims on a long-lived stage accumulated attribute pairs, widening those prims' Fabric buckets. Measured over 8 successive views on one stage (512 prims), attributes on a single prim went 1 → 8 and first-access rose monotonically from 120 ms to 173 ms. **Fix:** `FabricFrameView.close()` removes the view's tags (measured at 4.7 µs per prim, ~77 ms for an 8192-env view) and is safe to call more than once. `BaseFrameView` gains a no-op `close()` so callers can close any backend uniformly. Every in-repo callsite now closes its view: `Camera` when invalidated **and when dropped** (`__del__`), `prim_world_positions` after each per-env view it creates in a loop, and `SceneAsset` before replacing its cached view. Views dropped without `close()` are cleaned up best-effort from `__del__`, following the shutdown-safe idiom the env classes already use (`sys` bound as a default argument; nothing runs during interpreter finalization, where Fabric dies with the process anyway), and a warning names the view so the missing `close()` call can be fixed. ## How the problem was found The stall was invisible in Tracy. Comparing captures before and after the commit that introduced it, Kit's own per-frame work is unchanged — `App Update` totals 65.1 s before and 62.3 s after, over ~120 frames. All the lost time sits in the gaps *between* frames, where the main thread is blocked in Python and Kit records nothing. A `py-spy` capture found the cause: `_compute_fabric_indices_for` accounted for **11.86% of samples (23.2 s of a 195 s run)**, reached through `camera.reset()` → `get_world_poses()` → the selection rebuild. Every frame on that chain carries essentially the same share, so the whole cost is that one function. Fixes nvbug 6535498. ## Type of change - Bug fix (non-breaking change which fixes an issue) - New feature (non-breaking change which adds functionality) — `FrameView.close()` ## Benchmarks ### End-to-end symptom Task `Isaac-Lift-KukaAllegro-Camera`, 8192 environments, `presets=physx,isaacsim_rtx_renderer,duo_camera`. Commit `69888c34e471` (which introduced the problem) against its parent `e5f99d320338`: | | Parent | With the problem | | --- | ---: | ---: | | Mean environment step | 699 ms | 7193 ms | | Slow steps (over 3 s) | 1 of 100 | 28 of 100, averaging 18.9 s | | GPU utilization | 23.4% | 4.7% | GPU and CPU utilization both drop during the slow steps, which is what a stall looks like — the pipeline is waiting, not doing extra work. With this PR, the same task at 8192 environments steps at **mean 1.554 s, peak 1.663 s** — peak within 7% of mean, i.e. the stalls are gone. (Measured on an RTX A6000, so the absolute step time is not comparable to the table above, which was captured on different hardware; the stall signature is the comparison that matters.) ### Selection size — the actual fix L40, `cuda:0`, 1024-prim view (1024 children + 1024 parents). "Filler" is xformable prims **not** in the view but carrying Fabric matrices — i.e. the rest of a real scene. | filler prims | `develop` selection | this PR | | ---: | ---: | ---: | | 0 | 2,048 | 1,024 | | 10,000 | 12,048 | 1,024 | | 100,000 | 102,048 | **1,024** | `develop` scales with the stage; this PR is pinned to the view. ### Slot-mapping rebuild (mean ms, the path hit on every reset) | filler prims | `develop` child | `develop` parent | `develop` full RO rebuild | PR child | PR parent | | ---: | ---: | ---: | ---: | ---: | ---: | | 0 | 4.67 | 5.40 | 10.24 | 0.137 | 0.191 | | 10,000 | 24.05 | 24.69 | 62.47 | 0.139 | 0.193 | | 100,000 | 274.21 | 270.47 | **556.41** | **0.137** | **0.190** | `develop` grows linearly with stage size — **556 ms per rebuild** at 100k filler prims. This PR is flat at **~0.14 ms**, a **~2000×** reduction, and unchanged from 0 to 100k filler prims. First access at 100k filler: 1824 ms → 383 ms. ### `create_mapping` (pure Python, reversed path order) | N | `develop` | this PR | speedup | | ---: | ---: | ---: | ---: | | 1,000 | 0.0038 s | 0.0001 s | 27× | | 5,000 | 0.0862 s | 0.0007 s | 120× | | 20,000 | 1.3241 s | 0.0030 s | 434× | | 50,000 | 8.5507 s | 0.0092 s | **929×** | | 200,000 | (not run) | 0.0467 s | — | Outputs verified identical at every N. At the ~200k rigid bodies of an 8192-environment scene the old path takes minutes. ## Tests | Suite | Result | | --- | --- | | `isaaclab_physx/test/sim/test_views_xform_prim_fabric.py` | 79 passed, 4 skipped (`cpu` + `cuda:0` on an L40) | | `isaaclab/test/sim/test_views_xform_prim.py` (USD contract) | 63 passed | | `isaaclab_newton/test/sim/test_views_xform_prim_newton.py` | 58 passed | | `isaaclab/test/sensors/test_camera.py` (main consumer, incl. the new `close()` call) | 35 passed, 0 missing-`close()` warnings | | `isaaclab/test/utils/warp/test_proxy_array.py` | 81 passed | New tests: - `test_selections_match_only_the_view_prims` asserts each selection matches exactly the prims the view manages. Verified to fail without the fix — with the selections unscoped it reports `matched 8 prims, expected 4`, because the child selections pick up the parents too. - `test_close_removes_index_attributes` asserts the tag-scoped selection drops to zero after `close()` and that a second `close()` is a no-op. - `test_garbage_collection_removes_index_attributes_and_warns` asserts a view dropped without `close()` still removes its tags on collection and logs the warning. `test_fabric_rebuild_after_topology_change` was updated to drive the new refresh paths instead of the removed `_rebuild_{ro,rw}_arrays`. The 4 skips are environmental: empty device parameter sets, and Fabric hierarchy bindings that are unavailable in a headless experience. **Coverage gap:** `test_physx_scene_data_backend.py` and `test_ovphysx_scene_data_backend.py` both skip at collection on the machine used here, so the `create_mapping` change is exercised only by the standalone benchmark above, not by the test suite. Worth a look in CI, where those backends are available. ## Screenshots Not applicable — no visual change. The benchmarks above cover the behaviour change. ## Notes for reviewers **Review feedback addressed so far:** the index-attribute accumulation is fixed by `close()` (section 3); the opposite-space recompute no longer refreshes the same selection twice on writer-scope exit; `create_mapping` keeps `list.index`'s first-occurrence semantics for duplicate paths (measured free at 200k paths); and docstrings/changelogs were trimmed to the observable contract. **The `isaaclab`/`isaaclab_physx` changelog fragments are still named `fix-physx-newton-camera-pose-scaling.rst`**, inherited from #6554 — nothing here touches Newton or scaling. The new `isaaclab_mimic` fragment uses the branch slug. Happy to rename if reviewers prefer. **A handful of tests still drop views without `close()`** and now log the new warning during runs; harmless, cleanup to follow. EDIT: fixed — the only remaining warning is the one `test_garbage_collection_removes_index_attributes_and_warns` asserts on. `Camera` previously closed its view only on invalidation, so a dropped camera still went through `__del__`; it now closes in `Camera.__del__` too. `test_camera.py` went from 3 warnings to 0. ## Relationship to #6554 #6554 found the same two slow paths. This PR takes its `SceneDataProvider` fix unchanged (credited with a `Co-authored-by` line) and replaces its Fabric frame view fix. #6554 kept the whole-stage selection and the Python dictionary, and cached the result, reusing it while the number of selected prims stayed the same. Two problems with that. The cache key is unsafe: an equal prim count does not mean the prims or their order stayed the same, so after a bucket reorder or a same-count membership change the cached indices point at the wrong prims and cameras silently read another prim's transform. And it treats the symptom — the underlying operation is still proportional to the size of the whole scene, just performed less often. Making the selection small removes the need for a cache at all, so both problems go away. ## 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 a changelog fragment under `source/<pkg>/changelog.d/` for every touched package (do **not** edit `CHANGELOG.rst` or bump `extension.toml` — CI handles that) - [x] I have added my name to the `CONTRIBUTORS.md` or my name already exists there --------- Co-authored-by: pv-nvidia <[email protected]> Co-authored-by: yts-nv <[email protected]> Co-authored-by: Kelly Guo <[email protected]>
…r API (isaac-sim#5677) Two things: 1. **Local-space pose and scale ops are now GPU-fast on the Fabric backend.** They go through the same Warp-kernel path that world-space ops already used. The old USD fallback for local-space is ~100× slower (see the table below). 2. **All transform writes go through a small context manager.** You open a scope, do your writes inside it, and the scope handles the cleanup: ```python with view.xform_world_space_writer() as writer: writer.set_poses(positions=p, orientations=o) writer.set_scales(scales=s) ``` Use `view.xform_local_space_writer()` for local-space writes. Builds on Piotr's prototype at [`bareya/pbarejko/camera-update`](https://github.com/bareya/IsaacLab/tree/pbarejko/camera-update). A FrameView keeps two copies of each prim's transform in Fabric storage: the `omni:fabric:worldMatrix` and `omni:fabric:localMatrix` attributes. When you write one, the other has to be recomputed so they stay consistent. Without a scope, that recompute has to run after every single write. With a scope, it runs **once**, when the scope closes. You can call `set_poses` and `set_scales` as many times as you want inside the scope; on exit, one Warp kernel derives the other space and one `wp.synchronize()` runs. Empty scopes cost nothing. The scope also pauses **Fabric Hierarchy**'s transform-change tracking while you're writing, then restores it on exit. (Fabric itself is just the data store; Fabric Hierarchy, exposed through USDRT's `IFabricHierarchy`, is the plugin that watches writes to `omni:fabric:localMatrix` / `omni:fabric:worldMatrix` and keeps them mutually consistent across the hierarchy.) Its tracking is pull-based: a per-attribute listener records writes into a changelog, and the plugin drains and processes that changelog on the next call to `IFabricHierarchy::update_world_xforms()`. Pausing the listener does not block the writes themselves — they still land in Fabric storage — it just keeps them out of the changelog. With the changelog empty, the next tick has nothing to "catch up on" for these prims, and can't decide one of the two spaces is canonical and derive the other from it. See the next section for why that matters. Rules: - Only one writer can be open on a view at a time. Opening a second one raises `RuntimeError`. - While a writer is open, the view's own getters (`get_world_poses`, etc.) raise. Read through the writer (`writer.get_poses()`) inside the scope, or close the scope first. - **Do not advance the simulation or render from inside the scope.** No `sim.step()`, no `world.render()`, no `SimulationApp.update()`. The matrices are mid-write until exit, and rendering against that state would read torn data. Keep scopes short and close them before stepping. - If something raises inside the scope (a user-code bug, a notebook cell interrupt, etc.), the scope still runs the opposite-space recompute on exit so the world and local matrices stay consistent prim-by-prim. The partial write itself is not rolled back — if you need all-or-nothing, snapshot the matrices yourself before entering. correctness) A writer scope is synchronous Python code, so the renderer can't see anything mid-scope — no tick runs until we exit. The risk is on the **next** render/sim tick after the scope closes. On that next tick, Fabric Hierarchy runs its `IFabricHierarchy::update_world_xforms()` step, which can recompute `omni:fabric:worldMatrix` from `omni:fabric:localMatrix` (or vice versa). If it thinks one of the two was the user's most recent edit, it derives the other from it; the derived value — not what we wrote — is then what the **Fabric Scene Delegate (FSD)** hands to RTX on the render path. Three things in this PR keep that next-tick recompute from clobbering our work: 1. **Opposite-space derive at scope exit.** By the time the scope closes, `omni:fabric:worldMatrix` and `omni:fabric:localMatrix` are mutually consistent prim-by-prim, so any recompute Fabric Hierarchy does is a no-op. 2. **Fabric-Hierarchy change tracking is paused for the whole scope.** The writer calls `track_local_xform_changes(False)` and `track_world_xform_changes(False)` on enter (saving the prior state) and restores them on exit. While tracking is paused, the listeners don't record our writes in their changelog, so when the next tick runs there's nothing for `update_world_xforms()` to "catch up on". 3. **Two persistent selections with explicit read-only / read-write flags.** Outside the scope, the view's selection is fully read-only — both `omni:fabric:worldMatrix` and `omni:fabric:localMatrix` are flagged RO. Inside the scope, the writer flips to a fully read-write selection. ``` _sel_ro : worldMatrix=RO, localMatrix=RO (steady state, between writes) _sel_rw : worldMatrix=RW, localMatrix=RW (active during a writer scope) ``` Both selections are built once when the view is initialized and kept alive for its lifetime. The writer scope flips a single flag (`_is_rw`) on enter/exit; nothing is rebuilt. The RO steady state tells Fabric Hierarchy's next-tick `update_world_xforms()` that no attribute is user-authored, so it leaves both alone. - **Fabric (PhysX):** the fast GPU path described above. - **USD, Newton, OVPhysX:** the writer is a thin wrapper. Writes go straight to the backend's existing storage. No batching, no extra recompute (there is no second matrix to keep in sync). Same API across all four backends. Newton has two different "scale" ideas, and the API keeps them apart: - `NewtonSiteFrameView.set_scales(...)` (deprecated) writes the **Newton collision-shape geometry** size. - The writer's `set_scales(...)` writes per-site **transform scale**, matching what USD FrameView does. They operate on different state and are not merged. **New (recommended):** - `view.xform_world_space_writer()` / `view.xform_local_space_writer()` — a context manager with `set_poses`, `set_scales`, `get_poses`, `get_scales`. **Deprecated (still works, warns once per class on first use):** - `set_world_poses` / `set_local_poses` — use the writer scope. - `get_scales` / `set_scales` — use `get_local_scales` / `get_world_scales`, or the writer's `set_scales`. Per-iteration timings (lower is better): | Operation | USD (ms) | Fabric (ms) | Newton Site (ms) | |----------------------------|---------:|------------:|-----------------:| | Get World Poses | 8.6148 | 0.0375 | 0.0307 | | Set World Poses | 19.1357 | 0.1090 | 0.0368 | | Get Local Poses | 5.9556 | 0.0374 | 0.0497 | | Set Local Poses | 7.9794 | 0.0979 | 0.0790 | | Get World Scales | 13.1193 | 0.0371 | 0.0015 | | Set World Scales | 21.4571 | 0.1014 | 0.0612 | | Get Local Scales | 3.2544 | 0.0375 | 0.0022 | | Set Local Scales | 3.8350 | 0.0937 | 0.0587 | | Get Both (World+Local) | 14.7506 | 0.0738 | 0.1302 | | Interleaved World Set→Get | 28.1046 | 0.1432 | 0.1588 | | **Per-iter total** | **126.2** | **0.77** | **0.61** | Speedup vs USD (per-iter ops; one-time view construction excluded): | Operation | Fabric × | Newton Site × | |----------------------------|---------:|--------------:| | Get World Poses | 229.6× | 280.2× | | Set World Poses | 175.6× | 519.8× | | Get Local Poses | 159.0× | 119.9× | | Set Local Poses | 81.5× | 101.0× | | Get World Scales | 353.9× | 8911.5× | | Set World Scales | 211.6× | 350.4× | | Get Local Scales | 86.8× | 1489.9× | | Set Local Scales | 40.9× | 65.4× | | Get Both (World+Local) | 200.0× | 113.3× | | Interleaved World Set→Get | 196.2× | 177.0× | | **Overall (per-iter)** | **164×** | **207×** | One-time view construction (reported separately, not part of the per-iter total): USD 4.6 ms, Fabric 4.4 ms, Newton Site 1013 ms — the Newton number is dominated by stage population on the first call. Steady-state per-iteration cost is what the speedup row reflects. - Getters call `wp.synchronize()` before returning, so the returned `ProxyArray` is always immediately readable from both GPU and host code — no caller-side sync needed. (Both the cached and the per-indices paths sync; this used to be asymmetric.) --------- Co-authored-by: pv-nvidia <[email protected]> Co-authored-by: pv-nvidia <{"message":"Not Found","documentation_url":"https://docs.github.com/rest/users/emails#list-email-addresses-for-the-authenticated-user","status":"404"}>
…aac-sim#6805) Camera world-pose resolution stalled at high environment counts on the PhysX backend, badly enough to time out benchmarks. There are two independent bottlenecks; the PR also adds a lifecycle hook that came out of review. whole stage Cameras read their poses from Fabric. To do that the frame view needs to know where each camera's data sits in Fabric memory, so it builds a lookup table from "camera number" to "Fabric slot". Building that table was very slow. The view selected prims by requiring the Fabric world and local matrix attributes — but every xformable in the stage carries those, so the selection matched the **entire stage** (~1.1M prims at 8192 environments), not the view's handful of cameras. Finding its own prims in that list then meant building a Python dictionary over all of it, on the host: ```python path_to_idx = {str(p): i for i, p in enumerate(selection.GetPaths())} ``` That ran twice per rebuild (once for the children, once for their parents), and rebuilt whenever `PrepareForReuse()` reported a bucket change — in practice on every environment reset. The cost of that dictionary scales with the size of the whole scene, not with the number of cameras: it converts every path in the stage to a Python string and inserts it. Measured directly, one full rebuild takes 10 ms on a bare stage but **556 ms once 100k unrelated prims are present** (table below), and it grows linearly from there — seconds of host work per reset at the ~1.1M prims of an 8192-environment scene. **Fix:** author a private per-view `uint` index attribute on each managed prim (and on each unique parent), holding that prim's view index. Every selection requires the matching index attribute, so **selections resolve to exactly the view's prims**. The view-to-Fabric slot mapping is then rebuilt by inverting that attribute in a single Warp kernel launch: ```python fabric_slots[view_indices[fabric_slot]] = fabric_slot ``` That is `O(view)` device work with no host-side path resolution and no Python objects created per frame. There is also **no cache**, so there is nothing to invalidate. The table is rebuilt from live Fabric data on every access, which means a bucket reorder can never leave a stale mapping behind. Selections are still checked with `GetCount()`, which is exact here: the index attribute belongs to one view, so the count can only change if one of that view's prims actually disappeared — and then the view raises a clear error instead of silently reading the wrong prim. Attribute names embed a process-wide monotonic uid, so a dead view's leftover attributes can never satisfy a live view's selection — and since review, they are removed outright when the view is released (section 3). Parent reads get their own read-only selection, keeping the child RO/RW flip semantics from isaac-sim#5677 intact. ```python for i, path in enumerate(input_paths): mapping[i] = paths.index(path) # O(N) scan, per path ``` **Fix:** build the reverse dict once (first occurrence wins, matching `list.index` semantics), then resolve each path in `O(1)`. Measured over 200k paths, preserving first-occurrence semantics costs nothing versus an unguarded dict comprehension, so the fix carries no behaviour change. review) The per-view index attributes from fix 1 were initially never removed, so views recreated over the same prims on a long-lived stage accumulated attribute pairs, widening those prims' Fabric buckets. Measured over 8 successive views on one stage (512 prims), attributes on a single prim went 1 → 8 and first-access rose monotonically from 120 ms to 173 ms. **Fix:** `FabricFrameView.close()` removes the view's tags (measured at 4.7 µs per prim, ~77 ms for an 8192-env view) and is safe to call more than once. `BaseFrameView` gains a no-op `close()` so callers can close any backend uniformly. Every in-repo callsite now closes its view: `Camera` when invalidated **and when dropped** (`__del__`), `prim_world_positions` after each per-env view it creates in a loop, and `SceneAsset` before replacing its cached view. Views dropped without `close()` are cleaned up best-effort from `__del__`, following the shutdown-safe idiom the env classes already use (`sys` bound as a default argument; nothing runs during interpreter finalization, where Fabric dies with the process anyway), and a warning names the view so the missing `close()` call can be fixed. The stall was invisible in Tracy. Comparing captures before and after the commit that introduced it, Kit's own per-frame work is unchanged — `App Update` totals 65.1 s before and 62.3 s after, over ~120 frames. All the lost time sits in the gaps *between* frames, where the main thread is blocked in Python and Kit records nothing. A `py-spy` capture found the cause: `_compute_fabric_indices_for` accounted for **11.86% of samples (23.2 s of a 195 s run)**, reached through `camera.reset()` → `get_world_poses()` → the selection rebuild. Every frame on that chain carries essentially the same share, so the whole cost is that one function. Fixes nvbug 6535498. - Bug fix (non-breaking change which fixes an issue) - New feature (non-breaking change which adds functionality) — `FrameView.close()` Task `Isaac-Lift-KukaAllegro-Camera`, 8192 environments, `presets=physx,isaacsim_rtx_renderer,duo_camera`. Commit `69888c34e471` (which introduced the problem) against its parent `e5f99d320338`: | | Parent | With the problem | | --- | ---: | ---: | | Mean environment step | 699 ms | 7193 ms | | Slow steps (over 3 s) | 1 of 100 | 28 of 100, averaging 18.9 s | | GPU utilization | 23.4% | 4.7% | GPU and CPU utilization both drop during the slow steps, which is what a stall looks like — the pipeline is waiting, not doing extra work. With this PR, the same task at 8192 environments steps at **mean 1.554 s, peak 1.663 s** — peak within 7% of mean, i.e. the stalls are gone. (Measured on an RTX A6000, so the absolute step time is not comparable to the table above, which was captured on different hardware; the stall signature is the comparison that matters.) L40, `cuda:0`, 1024-prim view (1024 children + 1024 parents). "Filler" is xformable prims **not** in the view but carrying Fabric matrices — i.e. the rest of a real scene. | filler prims | `develop` selection | this PR | | ---: | ---: | ---: | | 0 | 2,048 | 1,024 | | 10,000 | 12,048 | 1,024 | | 100,000 | 102,048 | **1,024** | `develop` scales with the stage; this PR is pinned to the view. | filler prims | `develop` child | `develop` parent | `develop` full RO rebuild | PR child | PR parent | | ---: | ---: | ---: | ---: | ---: | ---: | | 0 | 4.67 | 5.40 | 10.24 | 0.137 | 0.191 | | 10,000 | 24.05 | 24.69 | 62.47 | 0.139 | 0.193 | | 100,000 | 274.21 | 270.47 | **556.41** | **0.137** | **0.190** | `develop` grows linearly with stage size — **556 ms per rebuild** at 100k filler prims. This PR is flat at **~0.14 ms**, a **~2000×** reduction, and unchanged from 0 to 100k filler prims. First access at 100k filler: 1824 ms → 383 ms. | N | `develop` | this PR | speedup | | ---: | ---: | ---: | ---: | | 1,000 | 0.0038 s | 0.0001 s | 27× | | 5,000 | 0.0862 s | 0.0007 s | 120× | | 20,000 | 1.3241 s | 0.0030 s | 434× | | 50,000 | 8.5507 s | 0.0092 s | **929×** | | 200,000 | (not run) | 0.0467 s | — | Outputs verified identical at every N. At the ~200k rigid bodies of an 8192-environment scene the old path takes minutes. | Suite | Result | | --- | --- | | `isaaclab_physx/test/sim/test_views_xform_prim_fabric.py` | 79 passed, 4 skipped (`cpu` + `cuda:0` on an L40) | | `isaaclab/test/sim/test_views_xform_prim.py` (USD contract) | 63 passed | | `isaaclab_newton/test/sim/test_views_xform_prim_newton.py` | 58 passed | | `isaaclab/test/sensors/test_camera.py` (main consumer, incl. the new `close()` call) | 35 passed, 0 missing-`close()` warnings | | `isaaclab/test/utils/warp/test_proxy_array.py` | 81 passed | New tests: - `test_selections_match_only_the_view_prims` asserts each selection matches exactly the prims the view manages. Verified to fail without the fix — with the selections unscoped it reports `matched 8 prims, expected 4`, because the child selections pick up the parents too. - `test_close_removes_index_attributes` asserts the tag-scoped selection drops to zero after `close()` and that a second `close()` is a no-op. - `test_garbage_collection_removes_index_attributes_and_warns` asserts a view dropped without `close()` still removes its tags on collection and logs the warning. `test_fabric_rebuild_after_topology_change` was updated to drive the new refresh paths instead of the removed `_rebuild_{ro,rw}_arrays`. The 4 skips are environmental: empty device parameter sets, and Fabric hierarchy bindings that are unavailable in a headless experience. **Coverage gap:** `test_physx_scene_data_backend.py` and `test_ovphysx_scene_data_backend.py` both skip at collection on the machine used here, so the `create_mapping` change is exercised only by the standalone benchmark above, not by the test suite. Worth a look in CI, where those backends are available. Not applicable — no visual change. The benchmarks above cover the behaviour change. **Review feedback addressed so far:** the index-attribute accumulation is fixed by `close()` (section 3); the opposite-space recompute no longer refreshes the same selection twice on writer-scope exit; `create_mapping` keeps `list.index`'s first-occurrence semantics for duplicate paths (measured free at 200k paths); and docstrings/changelogs were trimmed to the observable contract. **The `isaaclab`/`isaaclab_physx` changelog fragments are still named `fix-physx-newton-camera-pose-scaling.rst`**, inherited from isaac-sim#6554 — nothing here touches Newton or scaling. The new `isaaclab_mimic` fragment uses the branch slug. Happy to rename if reviewers prefer. **A handful of tests still drop views without `close()`** and now log the new warning during runs; harmless, cleanup to follow. EDIT: fixed — the only remaining warning is the one `test_garbage_collection_removes_index_attributes_and_warns` asserts on. `Camera` previously closed its view only on invalidation, so a dropped camera still went through `__del__`; it now closes in `Camera.__del__` too. `test_camera.py` went from 3 warnings to 0. `SceneDataProvider` fix unchanged (credited with a `Co-authored-by` line) and replaces its Fabric frame view fix. cached the result, reusing it while the number of selected prims stayed the same. Two problems with that. The cache key is unsafe: an equal prim count does not mean the prims or their order stayed the same, so after a bucket reorder or a same-count membership change the cached indices point at the wrong prims and cameras silently read another prim's transform. And it treats the symptom — the underlying operation is still proportional to the size of the whole scene, just performed less often. Making the selection small removes the need for a cache at all, so both problems go away. - [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 a changelog fragment under `source/<pkg>/changelog.d/` for every touched package (do **not** edit `CHANGELOG.rst` or bump `extension.toml` — CI handles that) - [x] I have added my name to the `CONTRIBUTORS.md` or my name already exists there --------- Co-authored-by: pv-nvidia <[email protected]> Co-authored-by: yts-nv <[email protected]> Co-authored-by: Kelly Guo <[email protected]> (cherry picked from commit 480370c)
The isaac-sim#5677 cherry-pick brought in OvPhysxFrameView code calling OvPhysxView (try_binding_for / read_into). That class arrives with isaac-sim#6224, which is not on this release branch, so the module import raised ModuleNotFoundError as soon as an OVPhysX frame view was initialized. Restore the direct physx.create_tensor_binding / binding.read calls this branch provides.
…coped Fabric selections (#6805) (#7342) # Description Backports two already-merged FrameView PRs to `release/3.0.0-beta2`, cherry-picked in merge order: - #5677 — GPU-accelerated FrameView local poses + `xform_space_writer` API (upstream `69888c34e471`) - #6805 — scale `FabricFrameView` selections to the view, not the stage (upstream `480370cdc5b0`, nvbug 6535498) Two support commits, because this branch predates some prerequisites: - `Shim needed for Arena compatibility.` (@amillane) adds `split_clone_template`, backported from #6071. Ordered first so no commit imports it before it exists. - `fix: use the OVPhysX tensor binding API…` restores this branch's `physx.create_tensor_binding()` / `binding.read()`. The #5677 pick referenced `OvPhysxView`, which arrives with #6224 and is absent here, so `OvPhysxFrameView` init raised `ModuleNotFoundError`. Conflict resolutions converge each touched file on its post-#6805 state from `develop`, so the backported code is byte-identical to what has been running and tested there. Two consequences of that choice: - `get_scales()` now returns `ProxyArray` in all backends, as on `develop`. On this branch it previously returned `wp.array`, so callers that pass the result straight to Warp APIs need `.warp` (Torch users: `.torch`). This is the one API change the backport carries. - The Fabric-hierarchy import stays unconditional (the optional import is #6499, not backported). The only deviation from `develop`'s state is test-infra: device parametrization uses literal `["cpu", "cuda:0"]` because `test_devices()` does not exist on this branch. ## Type of change - Bug fix (non-breaking change which fixes an issue) - New feature (non-breaking change which adds functionality) — `FrameView.close()`, writer-scope API - Breaking change (relative to this release branch only): `get_scales()` returns `ProxyArray` instead of `wp.array`, matching `develop` ## Tests - `test_views_xform_prim_ovphysx.py` — 49 passed (26 `cpu` + 24 `cuda:0`; needs one process per device, `ovphysx<=0.3.7` binds device mode in C++ on first `PhysX(...)`) - `test_views_xform_prim_newton.py` — 58 passed --------- Co-authored-by: alex <[email protected]> Co-authored-by: pv-nvidia <[email protected]> Co-authored-by: pv-nvidia <[email protected]> Co-authored-by: yts-nv <[email protected]> Co-authored-by: Kelly Guo <[email protected]>
Fast GPU pose/scale ops on Fabric + a new writer-scope API
What this does
Two things:
Local-space pose and scale ops are now GPU-fast on the Fabric backend.
They go through the same Warp-kernel path that world-space ops already used.
The old USD fallback for local-space is ~100× slower (see the table below).
All transform writes go through a small context manager. You open a
scope, do your writes inside it, and the scope handles the cleanup:
Use
view.xform_local_space_writer()for local-space writes.Builds on Piotr's prototype at
bareya/pbarejko/camera-update.Why a scope?
A FrameView keeps two copies of each prim's transform in Fabric storage:
the
omni:fabric:worldMatrixandomni:fabric:localMatrixattributes.When you write one, the other has to be recomputed so they stay
consistent.
Without a scope, that recompute has to run after every single write. With
a scope, it runs once, when the scope closes. You can call
set_posesand
set_scalesas many times as you want inside the scope; on exit, oneWarp kernel derives the other space and one
wp.synchronize()runs.Empty scopes cost nothing.
The scope also pauses Fabric Hierarchy's transform-change tracking
while you're writing, then restores it on exit. (Fabric itself is just
the data store; Fabric Hierarchy, exposed through USDRT's
IFabricHierarchy, is the plugin that watches writes toomni:fabric:localMatrix/omni:fabric:worldMatrixand keeps themmutually consistent across the hierarchy.) Its tracking is pull-based:
a per-attribute listener records writes into a changelog, and the
plugin drains and processes that changelog on the next call to
IFabricHierarchy::update_world_xforms(). Pausing the listener doesnot block the writes themselves — they still land in Fabric storage —
it just keeps them out of the changelog. With the changelog empty, the
next tick has nothing to "catch up on" for these prims, and can't
decide one of the two spaces is canonical and derive the other from
it. See the next section for why that matters.
Rules:
raises
RuntimeError.get_world_poses, etc.)raise. Read through the writer (
writer.get_poses()) inside the scope,or close the scope first.
No
sim.step(), noworld.render(), noSimulationApp.update().The matrices are mid-write until exit, and rendering against that state
would read torn data. Keep scopes short and close them before stepping.
cell interrupt, etc.), the scope still runs the opposite-space recompute
on exit so the world and local matrices stay consistent prim-by-prim.
The partial write itself is not rolled back — if you need
all-or-nothing, snapshot the matrices yourself before entering.
Why we have to coordinate with Fabric Hierarchy (renderer correctness)
A writer scope is synchronous Python code, so the renderer can't see
anything mid-scope — no tick runs until we exit. The risk is on the
next render/sim tick after the scope closes.
On that next tick, Fabric Hierarchy runs its
IFabricHierarchy::update_world_xforms()step, which can recomputeomni:fabric:worldMatrixfromomni:fabric:localMatrix(or viceversa). If it thinks one of the two was the user's most recent edit,
it derives the other from it; the derived value — not what we wrote —
is then what the Fabric Scene Delegate (FSD) hands to RTX on the
render path.
Three things in this PR keep that next-tick recompute from clobbering our
work:
Opposite-space derive at scope exit. By the time the scope closes,
omni:fabric:worldMatrixandomni:fabric:localMatrixare mutuallyconsistent prim-by-prim, so any recompute Fabric Hierarchy does is a
no-op.
Fabric-Hierarchy change tracking is paused for the whole scope.
The writer calls
track_local_xform_changes(False)andtrack_world_xform_changes(False)on enter (saving the prior state)and restores them on exit. While tracking is paused, the listeners
don't record our writes in their changelog, so when the next tick
runs there's nothing for
update_world_xforms()to "catch up on".Two persistent selections with explicit read-only / read-write
flags. Outside the scope, the view's selection is fully read-only —
both
omni:fabric:worldMatrixandomni:fabric:localMatrixareflagged RO. Inside the scope, the writer flips to a fully read-write
selection.
Both selections are built once when the view is initialized and kept
alive for its lifetime. The writer scope flips a single flag (
_is_rw)on enter/exit; nothing is rebuilt. The RO steady state tells Fabric
Hierarchy's next-tick
update_world_xforms()that no attribute isuser-authored, so it leaves both alone.
Backend support
to the backend's existing storage. No batching, no extra recompute (there
is no second matrix to keep in sync). Same API across all four backends.
Newton has two different "scale" ideas, and the API keeps them apart:
NewtonSiteFrameView.set_scales(...)(deprecated) writes the Newtoncollision-shape geometry size.
set_scales(...)writes per-site transform scale,matching what USD FrameView does.
They operate on different state and are not merged.
API changes
New (recommended):
view.xform_world_space_writer()/view.xform_local_space_writer()—a context manager with
set_poses,set_scales,get_poses,get_scales.Deprecated (still works, warns once per class on first use):
set_world_poses/set_local_poses— use the writer scope.get_scales/set_scales— useget_local_scales/get_world_scales, or the writer'sset_scales.Benchmark (1024 prims, 50 iterations, Blackwell RTX PRO 5000)
Per-iteration timings (lower is better):
Speedup vs USD (per-iter ops; one-time view construction excluded):
One-time view construction (reported separately, not part of the per-iter total): USD 4.6 ms, Fabric 4.4 ms, Newton Site 1013 ms — the Newton number is dominated by stage population on the first call. Steady-state per-iteration cost is what the speedup row reflects.
Notes for reviewers
wp.synchronize()before returning, so the returnedProxyArrayis always immediately readable from both GPU and hostcode — no caller-side sync needed. (Both the cached and the
per-indices paths sync; this used to be asymmetric.)