Skip to content

Replace cubric ctypes shim with IFabricHierarchy GPU API - #6834

Open
pbarejko wants to merge 3 commits into
isaac-sim:developfrom
pbarejko:pbarejko/fabric-hierarchy-gpu-update-options
Open

Replace cubric ctypes shim with IFabricHierarchy GPU API#6834
pbarejko wants to merge 3 commits into
isaac-sim:developfrom
pbarejko:pbarejko/fabric-hierarchy-gpu-update-options

Conversation

@pbarejko

Copy link
Copy Markdown
Collaborator

Description

Kit now exposes update_world_xforms_gpu_with_options with FabricHierarchyGpuUpdateOptions, so Newton can drive the same RIGID_BODY | FORCE_UPDATE hierarchy update through Python and drop the fragile IAdapter ctypes bindings.

Fixes # (issue)

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (existing functionality will not work without user modification)
  • Documentation update

Screenshots

Please attach before and after screenshots of the change if applicable.

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 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)
  • I have added my name to the CONTRIBUTORS.md or my name already exists there

@pbarejko
pbarejko requested a review from a team July 31, 2026 21:20
@github-actions github-actions Bot added the isaac-lab Related to Isaac Lab team label Jul 31, 2026
@greptile-apps

greptile-apps Bot commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR replaces Newton's private cubric ctypes adapter with the public Fabric hierarchy GPU update API.

  • Probes and caches availability of the new GPU hierarchy API while retaining the CPU update path for older Kit builds.
  • Uses RIGID_BODY and FORCE_UPDATE options during Newton-to-Fabric transform synchronization.
  • Removes the cubric binding implementation and its version-validation tests.
  • Updates changelog entries and related documentation comments.

Confidence Score: 4/5

The GPU hierarchy error path should be fixed before merging because a failed update can leave rendering stale while synchronization is reported complete.

The new path clears its retry state before the fallible hierarchy operation and never falls back after invocation errors; it also overwrites pre-existing shared tracking settings on exit.

Files Needing Attention: source/isaaclab_newton/isaaclab_newton/physics/newton_manager.py

Important Files Changed

Filename Overview
source/isaaclab_newton/isaaclab_newton/physics/newton_manager.py Replaces cubric lifecycle management with the Fabric GPU hierarchy path, but completion state is committed before propagation succeeds and shared tracking state is not preserved.
source/isaaclab_newton/isaaclab_newton/physics/_cubric.py Removes the obsolete private ctypes binding and its adapter lifecycle implementation.
source/isaaclab_newton/test/physics/test_cubric.py Removes tests specific to the deleted cubric ABI and version checks without adding coverage for the new GPU update failure path.
source/isaaclab_newton/changelog.d/pbarejko-fabric-hierarchy-gpu-update.rst Documents the new Fabric hierarchy API, option flags, legacy fallback, and cubric removal.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[Newton state becomes dirty] --> B[Write body transforms to Fabric]
    B --> C{GPU hierarchy API available?}
    C -->|Yes| D[Pause transform tracking]
    D --> E[GPU update with RIGID_BODY and FORCE_UPDATE]
    E --> F[Resume transform tracking]
    C -->|No| G[CPU update_world_xforms]
    F --> H[Viewport and RTX consume propagated transforms]
    G --> H
Loading

Reviews (1): Last reviewed commit: "Replace cubric ctypes shim with IFabricH..." | Re-trigger Greptile

Comment on lines 616 to +624
NewtonManager._newton_fabric_ready = True
NewtonManager._transforms_dirty = False

if use_cubric and fabric_hierarchy is not None:
fabric_id = cls._usdrt_stage.GetFabricId().id
if fabric_id != cls._cubric_bound_fabric_id:
cls._cubric.bind_to_stage(cls._cubric_adapter, fabric_id)
NewtonManager._cubric_bound_fabric_id = fabric_id
cls._cubric.compute(cls._cubric_adapter)
if use_gpu_hierarchy:
# RIGID_BODY: inverse-propagate on PhysicsRigidBodyAPI buckets
# (keep Newton world matrices, derive local). FORCE_UPDATE:
# bypass the change-listener dirty check after tracking pause.
fabric_hierarchy.update_world_xforms_gpu_with_options(
gpu_opts_cls.RIGID_BODY | gpu_opts_cls.FORCE_UPDATE

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.

P1 Failed updates clear synchronization state

When update_world_xforms_gpu_with_options raises, the code has already cleared _transforms_dirty and set _newton_fabric_ready, and the exception handler does not run update_world_xforms. Subsequent renders therefore report readiness while displaying stale transforms, and later physics steps retry the same failing GPU path instead of falling back to the CPU update.

Comment on lines 628 to 631
finally:
if use_cubric and fabric_hierarchy is not None:
if use_gpu_hierarchy:
fabric_hierarchy.track_world_xform_changes(True)
fabric_hierarchy.track_local_xform_changes(True)

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.

P2 Tracking state is not preserved

The GPU synchronization scope unconditionally enables both shared Fabric tracking modes on exit. When either mode was already disabled, this overwrites the owning scope's state and causes later Fabric writes to be tracked even though tracking was intended to remain suspended; preserve and restore each prior value as the sibling Fabric writer does.

@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

The patch replaces the private cubric ctypes bridge with Kit’s IFabricHierarchy.update_world_xforms_gpu_with_options API while retaining the CPU fallback. The implementation paths are coherent, but the Newton changelog should not document removal of a private implementation module or reference a deleted module target.

  • Design and architecture: Using Kit’s supported Fabric hierarchy API instead of a hand-maintained Carbonite vtable binding simplifies lifecycle management and removes ABI-sensitive code. The existing hierarchy tracking controls, rigid-body tagging, fallback path, and session cache reset remain aligned with the prior design.
  • API: The removed Python symbols are private and their in-tree consumers were updated. However, the Removed changelog entry exposes the private isaaclab_newton.physics._cubric module and creates a Sphinx module reference to a deleted target, contrary to the repository guidance to omit internal implementation details. Keep the changelog focused on the user-visible transform-sync change.
  • Implementation: The transform synchronization path was traced through capability detection, hierarchy acquisition, tracking suspension and restoration, GPU option selection, CPU fallback, and lifecycle reset. No concrete implementation defect is established by the supplied patch.

Minor fixes needed. Posted 1 actionable finding inline.

Automated review; human maintainers own approval decisions.

Removed
^^^^^^^

* Removed :mod:`isaaclab_newton.physics._cubric` ctypes bindings for

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.

🔵 Suggestion · Api — Changelog exposes private module removal

The Removed entry announces :mod:isaaclab_newton.physics._cubric``, a private module that was never user-facing, and the :mod: role now points at a deleted target. Repository changelog guidance asks to avoid internal implementation details users would not understand; fold the user-visible behavior into the existing `Changed` entry and drop the private-module removal.

@pbarejko
pbarejko force-pushed the pbarejko/fabric-hierarchy-gpu-update-options branch from 53242c3 to 82e6474 Compare August 1, 2026 19:13
Kit now exposes update_world_xforms_gpu_with_options with
FabricHierarchyGpuUpdateOptions, so Newton can drive the same
RIGID_BODY | FORCE_UPDATE hierarchy update through Python and drop
the fragile IAdapter ctypes bindings.
@pbarejko
pbarejko force-pushed the pbarejko/fabric-hierarchy-gpu-update-options branch from 82e6474 to 8e42186 Compare August 2, 2026 16:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

isaac-lab Related to Isaac Lab team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants