Skip to content

perf: add PrepareForReuse to FabricFrameView, remove sync_usd_on_fabric_write - #5380

Merged
pbarejko merged 15 commits into
isaac-sim:developfrom
pv-nvidia:fix/fabric-prepare-for-reuse
May 6, 2026
Merged

pbarejko merged 15 commits into
isaac-sim:developfrom
pv-nvidia:fix/fabric-prepare-for-reuse

Conversation

@pv-nvidia

@pv-nvidia pv-nvidia commented Apr 23, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Replace the sync_usd_on_fabric_write workaround in FabricFrameView with proper PrepareForReuse() calls on the Fabric PrimSelection. This tells the renderer (FSD/Storm) that Fabric data has changed, so the next rendered frame reflects updated transforms — eliminating the need to copy Fabric writes back to USD.

Motivation

The existing sync_usd_on_fabric_write flag worked by mirroring every Fabric write back to USD, which defeated the performance benefits of Fabric. With PrepareForReuse(), the rendering pipeline is properly notified of Fabric data changes without any USD writeback.

Additionally, the old code incorrectly fell back to USD for CPU devices — Warp handles CPU Fabric buffers correctly, so the fallback was unnecessary.

This addresses two of the issues raised in @pbarejko Piotr's review of PR #4923:

Changes

Core (FabricFrameView)

  • Call _prepare_for_reuse() in write paths (set_world_poses, set_scales) to notify the renderer
  • Remove sync_usd_on_fabric_write parameter (accepted via **kwargs for backward compat)
  • Remove incorrect CPU/device fallback warnings — Warp handles CPU Fabric buffers correctly
  • Add _rebuild_fabric_arrays() for topology change recovery when PrepareForReuse() returns True, with assertion guarding the prim-count invariant

Camera

  • Remove sync_usd_on_fabric_write=True from FrameView construction in camera.py

Benchmark Results

1024 prims, 50 iterations, NVIDIA L40 GPU:

Operation USD (ms) Fabric (ms) Speedup
Get World Poses 14.71 0.07 203x
Set World Poses 40.75 0.16 259x
Interleaved Set→Get 55.90 0.24 232x
Get Local Poses 11.08 11.12 1.0x
Set Local Poses 16.14 16.28 1.0x

Local poses fall back to USD (expected — Fabric only accelerates world poses via omni:fabric:worldMatrix).

Tests Added

Test What it validates
test_camera_pose_update_reflected_in_render Camera pose changes propagate to rendered depth (close vs far) for CPU/GPU, tiled/non-tiled
test_fabric_set_world_does_not_write_back_to_usd Fabric writes stay in Fabric, USD prim unchanged
test_set_world_updates_local (xfail) Documents Issue #5: set_world_poses doesn't update local pose in Fabric mode

Test Results

Test Suite Passed Skipped Xfailed Total
Fabric contract tests (test_views_xform_prim_fabric.py) 17 16 1 34
USD contract tests (test_views_xform_prim.py) 45 0 0 45
Camera render test (test_tiled_camera.py) 8 0 0 8

Type of change

  • Performance improvement (removes redundant USD writeback on Fabric operations)

Checklist

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

No doc changes needed (parameter wasn't referenced in any docs)

@github-actions github-actions Bot added bug Something isn't working isaac-sim Related to Isaac Sim team isaac-lab Related to Isaac Lab team labels Apr 23, 2026

@isaaclab-review-bot isaaclab-review-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 Isaac Lab Review Bot

Summary

This PR replaces the sync_usd_on_fabric_write workaround in FabricFrameView with proper PrepareForReuse() calls to notify the RTX renderer of Fabric data changes. The change removes the performance-defeating USD writeback pattern while maintaining correct rendering behavior. The implementation is architecturally sound with good test coverage, though there are a few correctness concerns around the placement and frequency of _prepare_for_reuse() calls.

Architecture Impact

  • Camera sensor: Removes sync_usd_on_fabric_write=True from FrameView construction, now relying on PrepareForReuse() for renderer synchronization.
  • FabricFrameView: Internal API change - sync_usd_on_fabric_write parameter removed (with deprecation warning via **kwargs).
  • Downstream callers: Any code passing sync_usd_on_fabric_write=True to FrameView will now get a deprecation warning but continue to function (the flag is simply ignored).
  • Kit extensions: Adds omni.kit.viewport.window and omni.kit.hydra_texture as dependencies for headless rendering.

Implementation Verdict

Minor fixes needed — The core approach is correct, but _prepare_for_reuse() is called in getters where it shouldn't be, and there's a potential race condition in the initialization flow.

Test Coverage

Good coverage for this change:

  • test_camera_pose_update_reflected_in_render: Validates that pose changes propagate to rendered depth (critical regression test)
  • test_fabric_set_world_does_not_write_back_to_usd: Confirms USD writeback removal
  • test_prepare_for_reuse_detects_topology_change: Basic API contract test
  • test_set_world_updates_local: Properly marked as xfail documenting known limitation

Missing: No test for the topology-changed path (_rebuild_fabric_arrays). The test only verifies PrepareForReuse() returns False when topology hasn't changed.

CI Status

No CI checks available yet — cannot verify the changes work on the required Kit version.

Findings

🟡 Warning: source/isaaclab_physx/isaaclab_physx/sim/views/fabric_frame_view.py:189-190 — _prepare_for_reuse() called in get_world_poses() is semantically incorrect

PrepareForReuse() is a write notification mechanism per the PR description ("tells the renderer that Fabric data is about to be modified"). Calling it before a read operation is incorrect — the purpose is to notify before writes, not reads. This could cause unnecessary renderer invalidation on every pose query.

def get_world_poses(self, indices=None):
    ...
    self._prepare_for_reuse()  # <-- Should not be here for a getter

Same issue at line 281 in get_scales(). The calls should only be in set_world_poses() and set_scales().

🟡 Warning: source/isaaclab_physx/isaaclab_physx/sim/views/fabric_frame_view.py:146 — _prepare_for_reuse() called before Fabric arrays may be valid

In set_world_poses(), _prepare_for_reuse() is called at line 146, but _fabric_selection is only set during _initialize_fabric() which happens at line 143. On the first call, _initialize_fabric() runs, sets _fabric_selection, then _prepare_for_reuse() is called. However, if _initialize_fabric() fails partway through, _fabric_selection could be partially initialized. The guard in _prepare_for_reuse() (line 320: if self._fabric_selection is None) handles this, but the ordering is confusing.

Consider calling _prepare_for_reuse() after the writes complete, not before.

🔵 Improvement: source/isaaclab_physx/isaaclab_physx/sim/views/fabric_frame_view.py:326-327 — Topology change handling logs at INFO but doesn't re-sync from USD

When topology changes, _rebuild_fabric_arrays() rebuilds the index mappings but doesn't re-sync transforms from USD. If prims were added, their initial Fabric world matrices may be stale. The existing _sync_fabric_from_usd_once() is a one-shot sync; a topology change might warrant another sync.

def _prepare_for_reuse(self) -> None:
    ...
    if topology_changed:
        logger.info("Fabric topology changed — rebuilding view-to-fabric index mapping.")
        self._rebuild_fabric_arrays()
        # Consider: self._fabric_usd_sync_done = False  # Force re-sync

🔵 Improvement: source/isaaclab_physx/test/sim/test_views_xform_prim_fabric.py:127-132 — The xfail override shadows the parametrized device fixture

The test function test_set_world_updates_local takes device and view_factory as parameters, but there's no @pytest.mark.parametrize("device", ...) decorator. This relies on fixture injection from the shared contract utils. If the shared test was parametrized with multiple devices, this override won't run for all of them.

@pytest.mark.xfail(...)
def test_set_world_updates_local(device, view_factory):  # Where does 'device' come from?

Verify that the device fixture is properly inherited or add explicit parametrization.

🔵 Improvement: source/isaaclab/test/sensors/test_tiled_camera.py:215-216 — Test creates camera without cleanup guard

The setup_camera fixture cleans up a specific camera, but test_camera_pose_update_reflected_in_render creates an additional camera at /World/PoseTestCam. While del camera is called at line 268, if an assertion fails before that line, the camera may leak.

Consider using a context manager or adding the camera to a cleanup list.

🔵 Improvement: source/isaaclab_physx/isaaclab_physx/sim/views/fabric_frame_view.py:63-71 — Constructor signature changed without updating all callers

The old signature had sync_usd_on_fabric_write: bool = False as a positional-or-keyword parameter. Now it's removed and handled via **kwargs. The test file at line 97 shows the update, but any external code calling FabricFrameView(..., sync_usd_on_fabric_write=True) will get a deprecation warning rather than a hard error. This is fine for backward compatibility but should be documented in the changelog.

@greptile-apps

greptile-apps Bot commented Apr 23, 2026 •

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR replaces the sync_usd_on_fabric_write workaround in FabricFrameView with proper PrepareForReuse() calls on write paths (set_world_poses, set_scales), eliminating redundant USD writeback and delivering 200–260× speedups on world-pose operations. It also enables the CPU Fabric path (removing the old CPU fallback), adds _rebuild_fabric_arrays() for topology-change recovery, and backs the changes with a new render-validation test and a no-writeback contract test.

  • P1 — \"cuda\" not remapped for SelectPrims: The removed _initialize_fabric block previously remapped bare \"cuda\" → \"cuda:0\" before calling SelectPrims (with an explicit log warning). Now SelectPrims(device=\"cuda\") is called directly, and no test covers device=\"cuda\" — a potential runtime failure for the common shorthand.

Confidence Score: 3/5

Safe to merge for cuda:0 and cpu users, but the bare 'cuda' device path is an untested regression risk.

One P1 finding: removal of the 'cuda' → 'cuda:0' remap in _initialize_fabric is untested and the old code's explicit warning implied SelectPrims requires an indexed device string. Multiple P1s pull the score below the P1 ceiling of 4.

source/isaaclab_physx/isaaclab_physx/sim/views/fabric_frame_view.py — specifically the _initialize_fabric device handling and _sync_fabric_from_usd_once PrepareForReuse double-call.

Important Files Changed

Filename Overview
source/isaaclab_physx/isaaclab_physx/sim/views/fabric_frame_view.py Core change: replaces sync_usd_on_fabric_write with PrepareForReuse calls on write paths; adds _rebuild_fabric_arrays for topology recovery. CPU Fabric path enabled and cuda device remapping removed — potential P1 regression when device="cuda" passes unindexed string to SelectPrims.
source/isaaclab/isaaclab/sensors/camera/camera.py Removes sync_usd_on_fabric_write=True from FrameView construction; clean follow-on to the FabricFrameView change.
source/isaaclab/isaaclab/sim/views/usd_frame_view.py Doc-only tweak: removes the sync_usd_on_fabric_write mention from the **kwargs docstring.
source/isaaclab_physx/test/sim/test_views_xform_prim_fabric.py Adds Fabric-specific tests (no-writeback assertion, xfail for local-pose stale read). CPU skip removed to match new CPU Fabric support. All parametrizations use ["cpu", "cuda:0"] — "cuda" shorthand not covered.
source/isaaclab/test/sensors/test_tiled_camera.py Adds test_camera_pose_update_reflected_in_render to validate PrepareForReuse propagation to the renderer across cpu/cuda:0 × TiledCamera/Camera. Correctly carries the @pytest.mark.isaacsim_ci marker.
source/isaaclab/test/sensors/test_multi_mesh_ray_caster_camera.py Shifts camera eye from [0,0,5] to [0.1,0,5] to avoid a degenerate view-direction edge case; unrelated to Fabric changes.
source/isaaclab/test/sensors/test_ray_caster_camera.py Same eye-offset fix as test_multi_mesh_ray_caster_camera.py; no functional concerns.
source/isaaclab_physx/config/extension.toml Version bumped from 0.5.29 to 0.5.30 to accompany the Fabric changes.
source/isaaclab_physx/docs/CHANGELOG.rst New 0.5.30 changelog entry documents the PrepareForReuse migration, CPU Fabric enablement, and topology-change recovery.

Sequence Diagram

sequenceDiagram
    participant Caller
    participant FabricFrameView
    participant PrimSelection
    participant WarpKernel
    participant Renderer

    Note over FabricFrameView: set_world_poses / set_scales
    Caller->>FabricFrameView: set_world_poses(positions, orientations)
    FabricFrameView->>FabricFrameView: _initialize_fabric() [if first call]
    FabricFrameView->>PrimSelection: PrepareForReuse()
    PrimSelection-->>FabricFrameView: topology_changed (bool)
    alt topology_changed == True
        FabricFrameView->>FabricFrameView: _rebuild_fabric_arrays()
    end
    FabricFrameView->>Renderer: (invalidate render state)
    FabricFrameView->>WarpKernel: compose_fabric_transformation_matrix(...)
    WarpKernel-->>FabricFrameView: writes to _fabric_world_matrices
    FabricFrameView->>FabricFrameView: _fabric_hierarchy.update_world_xforms()

    Note over FabricFrameView: get_world_poses (no PrepareForReuse)
    Caller->>FabricFrameView: get_world_poses(indices)
    FabricFrameView->>WarpKernel: decompose_fabric_transformation_matrix(...)
    WarpKernel-->>Caller: positions, orientations
Loading

Comments Outside Diff (1)

  1. source/isaaclab_physx/isaaclab_physx/sim/views/fabric_frame_view.py, line 394-405 (link)

    P1 "cuda" device string not remapped for SelectPrims

    The old code explicitly remapped "cuda" → "cuda:0" before calling SelectPrims (with a log warning: "Fabric device is not specified, defaulting to 'cuda:0'"). That remap is now gone, so SelectPrims(device="cuda") is called when self._device == "cuda". Since "cuda" was added to _fabric_supported_devices without confirming that USDRT SelectPrims accepts the un-indexed string, any caller using the common device="cuda" shorthand will silently reach a potential runtime failure. No test in this PR parametrizes with "cuda" to catch a regression.

    # suggested fix in _initialize_fabric:
    fabric_device = self._device
    if self._device == "cuda":
        fabric_device = "cuda:0"   # SelectPrims requires an indexed CUDA device

Reviews (6): Last reviewed commit: "fix: expand device parameterization for ..." | Re-trigger Greptile

@isaaclab-review-bot isaaclab-review-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 Isaac Lab Review Bot

Follow-up Review

Previous concerns have been addressed:

  • ✅ _prepare_for_reuse() calls removed from getters (get_world_poses(), get_scales()) — now only called in write paths as intended
  • ✅ The test test_set_world_updates_local now has proper @pytest.mark.parametrize("device", ...) decorator
  • ✅ Camera cleanup in test now uses try/finally guard

New observation:
The implementation looks correct now. The _prepare_for_reuse() is properly called only in set_world_poses() and set_scales() after initialization, and the topology change detection with _rebuild_fabric_arrays() is a reasonable approach.

Implementation Verdict

Ship it — The changes are clean and the previous concerns have been resolved.

@pv-nvidia pv-nvidia changed the title fix: add PrepareForReuse to FabricFrameView, remove sync_usd_on_fabric_write perf: add PrepareForReuse to FabricFrameView, remove sync_usd_on_fabric_write Apr 28, 2026

@isaaclab-review-bot isaaclab-review-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 Isaac Lab Review Bot

Follow-up Review

All previous concerns have been addressed. The implementation is correct — _prepare_for_reuse() is called only in write paths, tests have proper parametrization, and cleanup uses try/finally.

Implementation Verdict

Ship it — Clean implementation with proper renderer notification via PrepareForReuse() and topology change recovery.

@isaaclab-review-bot isaaclab-review-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 Isaac Lab Review Bot

Follow-up Review

Previous concerns were addressed. The new commit a7bcc405 adds only a contributor name to CONTRIBUTORS.md — no functional code changes since the last review.

Implementation Verdict

Ship it — The PrepareForReuse() implementation is correct, tests are comprehensive, and the contributor addition is trivial.

@pv-nvidia pv-nvidia added enhancement New feature or request and removed bug Something isn't working labels Apr 29, 2026
@pv-nvidia pv-nvidia self-assigned this Apr 29, 2026
@github-actions github-actions Bot added the bug Something isn't working label Apr 29, 2026

@isaaclab-review-bot isaaclab-review-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 Isaac Lab Review Bot

Follow-up Review

The new commit 630a820a adds only a contributor name ("Peter Verswyvelen") to CONTRIBUTORS.md — no functional code changes since the previous review.

Implementation Verdict

Ship it — Previous review approved the PrepareForReuse() implementation. This commit is a trivial contributor addition with no code impact.

@isaaclab-review-bot isaaclab-review-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 Isaac Lab Review Bot

Follow-up Review

Commit eacbc764 introduces no new code changes compared to the previously approved 630a820a — this is the same state (contributor addition only).

Implementation Verdict

Ship it — The PrepareForReuse() implementation was already approved. No new concerns.

@isaaclab-review-bot isaaclab-review-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 Isaac Lab Review Bot

Follow-up Review

Commit a55642a2 adds new test infrastructure compared to the previously approved state:

  1. New test test_camera_pose_update_reflected_in_render — validates that camera pose changes propagate to rendered depth. Well-structured end-to-end test covering CPU/GPU and tiled/non-tiled variants.

  2. New test test_fabric_set_world_does_not_write_back_to_usd — explicitly verifies the removal of sync_usd_on_fabric_write by confirming USD remains stale after Fabric writes.

  3. test_set_world_updates_local xfail override — properly documents Issue #5 limitation where Fabric worldMatrix writes don't update local poses.

The test additions are thorough and correctly validate the PR's behavioral changes. The minor camera eye position change (0.0, 0.0, 5.0) → (0.1, 0.0, 5.0) in ray caster tests appears to be a fix for edge-case numerical stability (looking straight down).

Implementation Verdict

Ship it — Test coverage is comprehensive and implementation remains sound.

pv-nvidia added 9 commits May 4, 2026 11:52
…date device handling for Fabric operations"

This reverts commit 4310d7a566602c44af3c911226158a3d0588e8d1.
The fragment-based changelog system landed in upstream develop (#5434) to
avoid per-PR merge conflicts on the top of CHANGELOG.rst. Switch this PR
to the new system: drop the in-rebase direct edits to CHANGELOG.rst and
config/extension.toml, and ship a fragment under changelog.d/ instead.
* Drop redundant `fabric_device` local in `_initialize_fabric` — every
  assignment was `fabric_device = self._device`, so just use `self._device`
  directly. `self._fabric_device` (the persistent attribute) is preserved.
* Drop the explicit `_fabric_usd_sync_done = True` at the end of
  `_sync_fabric_from_usd_once`. Both `set_world_poses` and `set_scales`
  already set it on success, so the trailing assignment is dead under the
  happy path and would mask a partial failure if either write raised.
* Tighten the no-writeback assertion in
  `test_fabric_set_world_does_not_write_back_to_usd` from `atol=0.1` to
  `atol=0.0`. USD literally must not have moved — any drift indicates a
  residual writeback path, and the loose tolerance would hide a 0.099-unit
  regression.
* Add `test_fabric_rebuild_after_topology_change` covering the
  `_prepare_for_reuse` → `_rebuild_fabric_arrays` branch, which is the
  load-bearing replacement for the removed `sync_usd_on_fabric_write`.
  The test monkeypatches `_prepare_for_reuse` to always take the rebuild
  branch (real Fabric topology changes are hard to provoke from a unit
  test) and verifies that a subsequent write/read still produces correct
  data, proving `_view_to_fabric` and `_fabric_world_matrices` are still
  consistent after the rebuild.

@isaaclab-review-bot isaaclab-review-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 Isaac Lab Review Bot

Follow-up Review

The changes between 4acba70d and 1235be63 consist of:

  1. A similar test tweak in test_ray_caster_camera.py changing camera eye position from (0.001, 0.0, 5.0) to (0.1, 0.0, 5.0) — matching the same fix pattern applied to test_multi_mesh_ray_caster_camera.py in the previous commit.

This is a consistent, minor test fix to avoid degenerate view directions. No new concerns introduced.

Implementation Verdict

Ship it — Ready to merge once CI passes.

CI Status

The Check changelog fragments failure needs investigation — verify the changelog fragment fix-fabric-prepare-for-reuse.rst follows the expected naming/format conventions. Most critical CI jobs are still pending but pre-commit passed.

pv-nvidia added 2 commits May 4, 2026 14:49
CI's "Verify changelog fragments" check flagged isaaclab as a touched
package without a fragment. The change is the camera.py call site
dropping the now-removed sync_usd_on_fabric_write=True kwarg from its
FrameView construction (paired with the kwarg removal documented in the
isaaclab_physx fragment).

@isaaclab-review-bot isaaclab-review-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 Isaac Lab Review Bot

Follow-up Review

The changes from 1235be63 to 53dce4b0 are minimal:

  1. Fixed import in camera.py — consolidated BaseRenderer and CameraRenderSpec into a single import line (cosmetic cleanup).

Previous concerns were minimal (CI check), and the code changes remain sound. The changelog fragment check is now passing (✅).

CI Status

Several CI jobs are failing (isaaclab_physx, isaaclab (core) [1/3], isaaclab_ov, etc.) — these need investigation before merge. The test-curobo and test-skillgen failures appear to be infrastructure/unrelated issues based on typical patterns, but isaaclab_physx failure is concerning given this PR directly modifies that package.

Implementation Verdict

Minor fixes needed — Investigate the isaaclab_physx CI failure before merging. If it's an unrelated flaky test or infrastructure issue, this is ready to ship.

@pv-nvidia
pv-nvidia requested a review from pbarejko May 4, 2026 21:13
pv-nvidia added 2 commits May 5, 2026 15:44
* Move test_camera_pose_update_reflected_in_render from test_tiled_camera.py
  to test_camera.py and drop the TiledCamera variant.  TiledCamera is a
  deprecated alias for Camera, so testing both was redundant.  The two test
  files will eventually be consolidated.
* Update the multi-GPU TODO comment on _fabric_supported_devices: recent
  Kit / USDRT releases support multi-GPU SelectPrims, but the rest of the
  view wiring still assumes one device — followup work.
* Drop the "FSD/Storm" reference in the class docstring; we only target FSD.
* Document **kwargs in FabricFrameView.__init__: it matches UsdFrameView's
  signature so the top-level FrameView factory can forward backend-agnostic
  kwargs without each backend having to know about every option.

@isaaclab-review-bot isaaclab-review-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 Isaac Lab Review Bot

Follow-up Review

The changes from 53dce4b0 to a3940bbc address the previous review:

  1. CI Status: All CI jobs are now pending (fresh run). The previous isaaclab_physx failure appears to have been transient — the code itself was correct.

  2. No new code changes: The diff between the previous review and now shows no substantive code modifications. The implementation remains sound.

Implementation Verdict

Ship it — The PR is well-structured, properly tested, and the previous CI concerns appear resolved. The PrepareForReuse() approach is the correct fix for renderer notification, and the test coverage is thorough (contract tests, regression test for no USD writeback, topology change handling).

@pv-nvidia pv-nvidia mentioned this pull request May 6, 2026
7 tasks done
@pbarejko
pbarejko merged commit efd9d1e into isaac-sim:develop May 6, 2026
55 of 56 checks passed
@github-project-automation github-project-automation Bot moved this from In progress to Done in Isaac Lab May 6, 2026
pbarejko pushed a commit that referenced this pull request May 14, 2026
…5609)

# Description

When calculating the "look-at" quaternion for a camera, an
**orthonormal** rotation matrix is first calculated using the camera's
eye position, look-at target, and world up vectors:
- `forward = target - eye` *("camera forward")*
- `camera_z = -normalize(forward)` *("camera backward")*
- `camera_x = world_up × camera_z ` *("camera right")*
- `camera_y = camera_z × camera_x` *("camera up")*
- return `R = [camera_x, camera_y, camera_z ]` *(OpenGL convention)*

However, if `forward` is parallel to `world_up` then the cross product
`camera_x` is zero, leading to a **singular** non-invertible matrix
returned from `create_rotation_matrix_from_view()`. Then
`quat_from_matrix()` would silently convert this to a non-unit
quaternion and return this garbage back to the caller.

This change fixes both issues as follows:

**`create_rotation_matrix_from_view`:**
- When the cross product collapses, it falls back on the world X-axis as
an alternate `world_up` vector and re-calculates the matrix.
- Previously, `camera_y × camera_z` was used as the fallback, which was
already zero due to the problem described above.
- X-axis is guaranteed to be perpendicular to `world_up` since
`world_up` is restricted to Y or Z.
- When truly undefined input is provided (`eye == target` or non-finite
values) it now returns per-row `NaN` that the caller can detect and
handle.

**`quat_from_matrix`:**
- Now returns `NaN` when the input is not a valid rotation matrix
(singular, reflection, or non-orthonormal).

All callers in IsaacLab have been updated to detect `NaN` where
appropriate and fail gracefully, or avoid passing degenerate input
altogether where possible.

Added 11 new unit tests and removed the 0.1 x-nudge workaround from the
integration tests (PR #5470 and #5380)

## Type of change

- Bug fix (non-breaking change which fixes an issue)

## Checklist

- [x] I have read and understood the [contribution
guidelines](https://isaac-sim.github.io/IsaacLab/main/source/refs/contributing.html)
- [x] I have run the [`pre-commit` checks](https://pre-commit.com/) with
`./isaaclab.sh --format`
- [x] I have made corresponding changes to the documentation
- [x] My changes generate no new warnings
- [x] I have added tests that prove my fix is effective or that my
feature works
- [x] I have updated the changelog and the corresponding version in the
extension's `config/extension.toml` file
- [x] I have added my name to the `CONTRIBUTORS.md` or my name already
exists there
hujc7 added a commit to hujc7/IsaacLab that referenced this pull request Jul 7, 2026
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.
ooctipus added a commit that referenced this pull request Nov 19, 2026
#9038)

## Description

Newton markers currently rebuild and upload a full instance batch for
every prototype—even when only color or scale differs. This change
groups shared primitive geometry and passes Torch tensors directly to
Warp, eliminating repeated transform construction and CPU round trips.

The focused marker-preparation timing in **Improvements** is historical,
measured at `8879a84ada25641fd3846f8598bf458c61f94090`. The environment
throughput below was rerun on November 18 with the revised
implementation at `a94c2e11bef41e0b2219cdc10d55883b0e3faa3c`.

## Improvements

Measured with **2,560 markers and four color prototypes sharing one
geometry**, after five warmup renders and over 100 measured renders:

| Work per render | Before | After | Improvement |
| --- | --- | --- | --- |
| Instance batches | 4 | 1 | 75% fewer |
| Instance records across batches | 10,240 | 2,560 | 75% fewer |
| Transform construction | Once per prototype | Once per render | 4 → 1
in this case |
| Tensor handoff | Torch → CPU/NumPy → Warp | Torch → Warp | Removes
host round trip for same-device tensors |
| CPU render preparation + sink readback | 0.559 ms | 0.202 ms | **64%
less time (2.77×)** |

The timing measures marker preparation and sink readback, not browser
FPS. Instance counts are structural counts, not measured network bytes.
GPU timings are omitted because another playback process was using the
GPU.

## Existing-environment throughput

Fresh measurements from November 18, 2026. Values are **median
vector-environment updates/s (range)** across six accepted 15-second
intervals per variant, from two fresh processes. These measure full
simulation and visualization with a connected Viser WebSocket client and
uncapped visualization, not browser FPS.

| Scene | Original | Newton only | Previous PR (`8879a84ad`) | Revised
PR (`a94c2e11b`) |
| --- | ---: | ---: | ---: | ---: |
| KUKA–Allegro lift, 512 environments | 75.6 (75.4–76.6) | 76.3
(76.0–77.3) | 83.4 (82.8–84.1) | 85.0 (84.6–86.0) |
| ANYmal policy playback, 512 robots, 8×8 terrain | 46.7 (43.8–48.2) |
46.9 (44.6–48.2) | 57.9 (55.6–60.6) | 57.1 (54.9–60.0) |

- **KUKA:** revised is **+12.6%** versus original, **+11.4%** versus
Newton only, and **+2.0%** versus the previous PR.
- **ANYmal:** revised is **+22.2%** versus original and **+21.7%**
versus Newton only. Its median is **-1.5%** versus the previous PR;
their interval ranges overlap substantially, so this run does not
establish a small speedup or slowdown from the simplification.

For each scene, run order was **original → Newton only → previous PR →
revised PR → revised PR → previous PR → Newton only → original**. Each
process warms up for 10 seconds, then collects three 15-second
intervals. The GPU monitor samples compute processes once per second; no
competing process was observed on the measured GPU during any of the 48
accepted intervals. Two additional intervals were discarded because of
observed contention. Other work could run on the shared host or the
other GPU; CPU resources were not reserved.

All runs used RTX 5090 GPU 1, Torch 2.11.0+cu130 with 24 Torch CPU
threads, stock Viser 1.1.1, and the same Newton physics runtime
(`9ca16d498`). Original uses the unoptimized viewer and markers. Newton
only adds the viewer changes from [Newton
#5380](newton-physics/newton#5380), backported
onto that fixed runtime; the previous/revised PR variants also select
their respective marker implementations. Runtime source hashes confirm
that only the three Newton viewer files differ. The same Viser
line-width API adjustment is applied to both runtimes.

KUKA uses zero actions, seed 42, and goal markers. ANYmal uses
checkpoint `6b7z0qkf/model_18800.pt`, seed 43, and the full 8×8 terrain.
Scene source was frozen from the current local scene checkout and used
unchanged for all variants; that checkout has evolved since the
historical experiment. These fresh results replace the earlier
throughput numbers and are not pooled with them.

## What changed

- Resolve prototype batch IDs and scale/color styles once at
initialization. Render gathers those tables and masks by batch ID; no
pairwise batch search, per-render Python-list uploads, `torch.isin`, or
int64 index copy.
- Keep unsupported prototypes in the lookup as non-rendering entries,
without reading unsupported material fields. Negative and out-of-range
indices remain invisible.
- Rerun draws each supported prototype separately because its mesh
appearance is batch-wide. It shares registered primitive geometry
between those draw batches. Other Newton viewers retain geometry
batching with per-instance colors.
- Keep viewer-local mesh registration in the existing backend helper.
Construct mesh transforms lazily, once per render, and skip that work
for frame-only groups.
- Fix frame line width from the prototype scale at initialization,
removing the per-frame scalar readback. Per-instance scale updates still
change axis lengths, while line width stays fixed.
- Update the older marker render fixtures to use the real constructor
and consume actual Warp arrays; remove obsolete internal state setup
instead of adding compatibility aliases.

Production changes for the complete PR: **101 additions, 136 deletions
(net −35)** in the existing marker module. No new production modules or
dependency changes. Batch layouts remain owned by this backend; Rerun's
separate layout represents its actual appearance limitation.

Newton viewer cleanup remains in the independent [Newton
#5380](newton-physics/newton#5380). No Viser
patch is required. Direct Torch-to-Warp handoff removes per-instance
CPU/NumPy copies; `sync_exit=True` still provides stream
synchronization.

## Validation

- `uv run python -m pytest
source/isaaclab_visualizers/test/test_newton_adapter.py -k marker -q`:
**7 passed**, including CPU and CUDA/non-default-stream coverage.
- `uv run python -m pytest
source/isaaclab/test/markers/test_visualization_markers.py -k
newton_marker -q`: **12 passed**.
- The consolidated regression covers geometry batching, colors/scales,
unsupported `GroundPlaneCfg`, invalid indices, selected environments,
in-place updates, visibility, viewer-local registration, and Rerun's
separate color batches. It forbids per-render `torch.isin`.
- Regression evidence: the previous PR head crashes on `GroundPlaneCfg`;
disabling Rerun's separate layout or invalid-index masking independently
makes the updated test fail.
- Full adapter file: **48 passed, 1 failed**. The camera test fails with
`ModelBuilder.add_usd() got an unexpected keyword argument
'allow_unsafe_torch_checkpoints'` in the installed Newton runtime. The
same isolated camera test fails at the previous PR head with that error.
- Full `uv run isaaclab --format`, changelog gate against the PR base,
and `git diff --check` pass.

## Type of change

- Performance improvement

## Checklist

- [x] Read the contribution guidelines
- [x] Ran formatting and lint checks
- [x] Consolidated regression coverage using the test-audit criteria
- [x] Added a package changelog fragment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working enhancement New feature or request isaac-lab Related to Isaac Lab team isaac-sim Related to Isaac Sim team

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants