Skip to content

Remove obsolete OVPhysX bootstrap hacks - #6074

Merged
kellyguo11 merged 12 commits into
isaac-sim:developfrom
marcodiiga:task/remove-carbonite-and-usd-namespaced-hacks-c952c4
Aug 8, 2026
Merged

kellyguo11 merged 12 commits into
isaac-sim:developfrom
marcodiiga:task/remove-carbonite-and-usd-namespaced-hacks-c952c4

Conversation

@marcodiiga

@marcodiiga marcodiiga commented Jun 9, 2026 •

Copy link
Copy Markdown
Collaborator

Description

Removes obsolete OVPhysX bootstrap compatibility code for the pinned
ovphysx==0.5.9 runtime and hardens normal lifecycle cleanup:

  • uses the public bootstrap and schema APIs without hiding loaded pxr modules
    or probing private wheel layout;
  • registers only missing public schema providers;
  • replaces forced-success process exit with guarded atexit cleanup and
    explicit runtime/view release;
  • completes STOP and context cleanup even when a listener fails;
  • preserves the one required STOP on same-context re-warm and the public,
    idempotent bootstrap call;
  • isolates view cleanup between tests.

Dependency: ovphysx==0.5.9.

Fixes N/A

Type of change

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

Screenshots

N/A

Test Plan

  • uv run --frozen isaaclab -f
  • uv run --frozen python tools/changelog/cli.py check develop
  • focused lifecycle and view tests: 122 passed
  • Sphinx warning-as-error documentation build
  • full 22-file OVPhysX backend sweep: 21 files passed; the unchanged CUDA
    articulation file hit intermittent assertions. An identical property-binding
    failure reproduced on exact develop merge-base 5322a1bdcff (1/5 control
    runs and 1/4 PR runs).

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

The OVPhysX backend tests still emit existing deprecation and runtime warnings
from surrounding test coverage.

@github-actions github-actions Bot added the isaac-lab Related to Isaac Lab team label Jun 9, 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.

Summary

This PR removes obsolete compatibility hacks from the OVPhysX integration that were necessary for ovphysx 0.4.x but are no longer needed with ovphysx 0.5's namespaced USD and static Carbonite lifecycle. The changes are well-structured and the test coverage for preventing regression of the removed behavior is thorough.

Positive Observations

  1. Clean removal of workarounds: The pxr module hiding during bootstrap, the atexit -> os._exit(0) process-exit workaround, and the physx.reset() keeping-instance-alive pattern are all cleanly removed.

  2. Proper lifecycle management: The new physx.release() call in _release_physx() is cleaner than the previous reset-and-hold pattern.

  3. Excellent guardrail tests: The new test_ovphysx_manager_lifecycle.py explicitly tests that the old behaviors stay removed, which is great defensive programming.

  4. Consistent test file updates: All test files consistently update the kitless detection logic and documentation references from ./scripts/run_ovphysx.sh to ./isaaclab.sh -p -m pytest.

  5. Clear changelog entries: Both the .skip and .minor.rst changelog fragments clearly communicate what changed.

Questions and Suggestions

ovphysx_manager.py

  1. Line ~609: The _construct_physx method now unconditionally passes num_threads=8 in PhysXConfig. Was this value validated against ovphysx 0.5's recommended defaults? The old code set this via set_config_int32 or set_setting dynamically.

  2. Lines ~595-607: The carbonite_overrides dictionary now includes /physics/physxDispatcher, /physics/updateToUsd, etc. unconditionally. Previously these were set conditionally via set_setting(). Is there a reason these are now always set even for CPU mode, or is this intentional?

  3. Potential race condition consideration: With the removal of the _atexit_registered guard, if _construct_physx were somehow called twice (shouldn't happen given the design, but defensively), there's no longer a sentinel preventing duplicate work. The existing _physx is None check in _warmup_and_load guards this, but it might be worth adding a comment noting the single-construction guarantee.

test_ovphysx_manager_lifecycle.py

  1. Line 82: The _FakePhysX.release() method sets self.released = True, which is good. Consider adding an assertion that release() wasn't called before (to catch double-release bugs), though this may be out of scope for this PR.

  2. The fake module fixture restores _physx and _locked_device but not _warmup_done, _stage_path, or other class variables. If any future test accidentally modifies these, it could leak between tests. This is minor since the current tests don't touch them.

pyproject.toml

  1. Line 26: The version constraint ovphysx>=0.5,<0.6 is good practice. However, consider whether ~=0.5 (compatible release) would be more appropriate if ovphysx follows semver strictly, though the explicit range is clearer.

Test Interface Files

  1. The simplification of _kitless detection from the complex LD_PRELOAD-based check to just "EXP_PATH" not in os.environ is clean. Just confirming: are there any edge cases where EXP_PATH might be set but Kit is still not available? The original check seemed to guard against that.

Minor Nits

  • In contact_sensor.py, the updated error message now reads "The IsaacLab OVPhysX adapter has not wired detailed contact/friction reads" — this is clear but slightly verbose. Consider shortening to "The OVPhysX adapter does not yet support" for consistency with similar messages.

Overall this is a clean, well-tested PR that removes technical debt. The test plan is comprehensive and the changes align well with the ovphysx 0.5 API surface.

@greptile-apps

greptile-apps Bot commented Jun 9, 2026 •

Copy link
Copy Markdown
Contributor

Greptile Summary

The PR updates IsaacLab’s OVPhysX integration for the pinned 0.5 runtime.

  • Replaces compatibility bootstrap and construction paths with the public OVPhysX 0.5 APIs.
  • Explicitly destroys tensor bindings, resets the stage, and releases the runtime in lifecycle order.
  • Adds lifecycle, schema-registration, shutdown, and view-cleanup regression coverage.

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains.

Important Files Changed

Filename Overview
source/isaaclab_ovphysx/isaaclab_ovphysx/physics/ovphysx_manager.py Migrates bootstrap, configuration, stage reuse, and shutdown to the pinned OVPhysX 0.5 lifecycle.
source/isaaclab_ovphysx/isaaclab_ovphysx/sim/views/ovphysx_view.py Adds explicit, idempotent destruction and manager-driven tracking of live tensor-binding views.
source/isaaclab_ovphysx/test/physics/test_ovphysx_manager_lifecycle.py Adds focused lifecycle regression tests and now isolates the relevant manager class state.
source/isaaclab_ovphysx/test/physics/test_ovphysx_scene_data_backend.py Updates shared backend tests for the pinned runtime API and explicit resource release.
source/isaaclab_ovphysx/test/sim/test_ovphysx_view.py Adds coverage for binding destruction, runtime-specific view cleanup, and retained-view lifetime.

Sequence Diagram

sequenceDiagram
    participant Sim as SimulationContext
    participant Manager as OvPhysxManager
    participant Views as OvPhysxView registry
    participant Runtime as OVPhysX runtime
    participant Stage as OVStage
    Sim->>Manager: close()
    Manager->>Manager: dispatch STOP callbacks
    Manager->>Views: close all runtime-backed views
    Views->>Views: destroy cached bindings
    Manager->>Runtime: reset_stage() and wait_op()
    Manager->>Runtime: release()
    Manager->>Stage: destroy()
Loading

Reviews (2): Last reviewed commit: "Remove obsolete OVPhysX bootstrap hacks" | Re-trigger Greptile

@marcodiiga
marcodiiga force-pushed the task/remove-carbonite-and-usd-namespaced-hacks-c952c4 branch from 3ff747a to d9056d5 Compare June 9, 2026 15:19

@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 — PR #6074

Verdict: Clean removal of technical debt with good guardrail coverage.

Summary

This PR removes OVPhysX 0.4.x compatibility workarounds (pxr-hiding during bootstrap, atexit → os._exit(0) shutdown hack, reset-and-hold instance pattern) and migrates to ovphysx 0.5's PhysXConfig/carbonite_overrides construction API. The changes are well-scoped, the new lifecycle test file prevents regression of the removed workarounds, and test documentation consistently updates references from the deprecated run_ovphysx.sh wrapper to ./isaaclab.sh -p -m pytest.


Findings

🟡 Warning: CI license-check and pre-commit are currently failing

The license-check and pre-commit jobs are failing on this SHA. These may be infrastructure issues, but worth verifying — in particular the new test_ovphysx_manager_lifecycle.py file should pass the license header check and any formatting lints.

🟡 Warning: No error handling around physx.release() in _release_physx

File: source/isaaclab_ovphysx/isaaclab_ovphysx/physics/ovphysx_manager.py

physx = cls._physx
cls._physx = None
physx.release()

If physx.release() raises (e.g., the C++ layer encounters an error during teardown), the exception will propagate up through close(). The reference-clearing before release is good defensive practice, but a try/finally or logging around release() would make the failure mode more graceful — especially since this runs during cleanup paths where swallowing or logging errors is often preferable to propagating them.

🟡 Note: _warmup_and_load reuse path narrowed to within-session only

File: ovphysx_manager.py

The reuse path (else branch when cls._physx is not None) in _warmup_and_load calls cls._physx.reset(). Previously this was always reachable because _release_physx kept the instance alive. Now that close() → _release_physx() calls physx.release() and sets _physx = None, the reuse path is only exercised within a single SimulationContext lifetime (i.e., multiple reset() calls before close()). The docstring correctly states "On subsequent calls before close" — just flagging this behavioral narrowing for visibility.

🔵 Suggestion: Document why num_threads=8 is hardcoded

File: ovphysx_manager.py → _construct_physx

num_threads=8 is now a construction-time constant in PhysXConfig. Previously it was set via set_config_int32 or set_setting. If this value is an ovphysx 0.5 API constraint, a brief comment or exposing it as an OvPhysxCfg field would help future maintainers understand the choice and know whether it can be tuned.

🔵 Suggestion: Consider a lifecycle re-construction test

File: test_ovphysx_manager_lifecycle.py

A fourth test verifying _construct_physx succeeds after _release_physx (the close → reinitialize → construct flow) would confirm the new lifecycle's re-entrancy. Optional since real-backend tests cover it, but cheap to add as a guardrail test.


Positive Observations

  • ✅ Guardrail tests explicitly verify the old hacks stay removed — excellent defensive testing pattern
  • ✅ _kitless detection simplification ("EXP_PATH" not in os.environ) is correct and backwards-compatible
  • ✅ Moving PhysxManager mock patching inside the try/except ImportError block in interface tests prevents mock leaks when the backend is not installed
  • ✅ Clear changelog fragments for both packages (.skip for isaaclab, .minor.rst for isaaclab_ovphysx)
  • ✅ Version constraint ovphysx>=0.5,<0.6 is appropriately bounded
  • ✅ The _release_physx clearing pattern (save ref → null field → release) prevents concurrent access during teardown

Reviewed at SHA: d9056d57


Update (48307eab): Incremental changes reviewed. ✅ Fixed: Test fixture in test_ovphysx_manager_lifecycle.py now properly saves/restores all class-level state fields via _MANAGER_STATE_FIELDS tuple (addressing the earlier inline comment about incomplete fixture state). No new issues introduced in this push — changes are docstring/comment refinements and the fixture improvement. LGTM.

@marcodiiga
marcodiiga force-pushed the task/remove-carbonite-and-usd-namespaced-hacks-c952c4 branch from d9056d5 to 48307ea Compare June 9, 2026 15:33
@marcodiiga

marcodiiga commented Jun 9, 2026 •

Copy link
Copy Markdown
Collaborator Author

Stalling this PR for now and marking it as draft. The cleanup intentionally targets the next ovphysx line via ovphysx>=0.5,<0.6, but the public package indexes currently only resolve ovphysx<=0.4.13. That makes dependency-resolution CI fail before this can be mergeable.

We should mark this ready again only after a public Python ovphysx wheel satisfying >=0.5,<0.6 is available on the configured indexes, then rerun CI and the existing smoke matrix.

@marcodiiga
marcodiiga marked this pull request as draft June 9, 2026 15:33
@marcodiiga
marcodiiga force-pushed the task/remove-carbonite-and-usd-namespaced-hacks-c952c4 branch from 48307ea to a7a289d Compare July 28, 2026 16:27
@github-actions github-actions Bot added documentation Improvements or additions to documentation infrastructure labels Jul 28, 2026
Use the public OVPhysX 0.5.9 bootstrap and schema APIs.

Replace forced process exit with deterministic binding and runtime
cleanup so normal shutdown preserves real failures.
@marcodiiga
marcodiiga force-pushed the task/remove-carbonite-and-usd-namespaced-hacks-c952c4 branch from a7a289d to 89ee543 Compare July 28, 2026 17:18
@marcodiiga
marcodiiga marked this pull request as ready for review July 28, 2026 17:19
@marcodiiga
marcodiiga requested a review from a team July 28, 2026 17:19

@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 strips the OVPhysX 0.5-era compatibility shims (pxr module hiding around bootstrap(), the os._exit(0) atexit workaround, runtime-API branching in _create_physx_instance/_step_physx/_reset_physx_stage) and replaces the "never release the runtime" policy with an explicit teardown chain: STOP dispatch -> destroy cached TensorBinding handles -> reset_stage() -> physx.release() -> destroy OVStage. OvPhysxView gains an idempotent close(), a closed-state guard, and a process-wide _live_views registry so raw bindings handed out via binding_for() can still be destroyed before the runtime goes away. The ordering itself is well reasoned and the new guardrail tests pin the happy path. The remaining concerns are all about guarantees the removed code used to provide implicitly: bootstrap() is no longer structurally once-per-process now that _physx is actually released, the deleted Kit physxSchema provider guard is not replaced, the new atexit handler runs arbitrary Python callbacks during interpreter shutdown, and error paths through close() can release the runtime while listeners still believe they hold live handles.

Architecture impact

Scoped to the optional isaaclab_ovphysx package plus a docstring-only change to PhysicsManager.close() that inverts the documented super()-call ordering for subclasses whose STOP listeners own backend handles. That contract flip is the only cross-package effect; no public API is removed. The new OvPhysxView._live_views class-level registry introduces process-global mutable state shared between the view module, the manager, and the test suites, which is the main new coupling worth watching.

Test coverage

Good breadth for the removed hacks: bootstrap no longer hides pxr, atexit receives close rather than os._exit, release ordering (views -> reset -> release -> stage destroy), view close() idempotency, and cross-runtime _close_all_for isolation are all covered, and the obsolete legacy-runtime/Kit-schema tests were removed in step. Gaps: the reuse branch of _warmup_and_load() is never exercised (only the _prepare_physx_for_stage_reuse helper is called directly), failure paths through close()/_release_physx are untested, the subprocess exit test cannot distinguish a raising atexit handler from a clean one, and the new _live_views teardown fixture in test_ovphysx_view.py is not scoped to views created by the test.

Implementation verdict

Significant concerns. Posted 8 actionable findings inline.

The PR exceeded the automated context budget, so some file content was truncated.

Automated comment-only review; human maintainers own approval decisions.

@AntoineRichard AntoineRichard left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Requesting changes for three functional lifecycle/test issues and several targeted hygiene problems. The inline comments include concrete failure paths and focused remediations.

Verification at fda86746:

  • ./isaaclab.sh -f: passed all hooks.
  • Focused 122-test lifecycle/view suite: 118 passed, 2 skipped, 2 failed. Both failures are the new process-exit tests, which reach a CUDA-dependent pinned allocation despite configuring CPU physics.
  • Direct reproduction confirmed that a STOP callback routed through safe_callback_invoke(..., physics_manager=<manager with store_callback_exception>) returns from close() normally with the exception merely stored.

The main code paths are close, but teardown must preserve failures consistently across backends and the regression coverage should be smaller, portable, and non-duplicative.

@AntoineRichard AntoineRichard left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Follow-up on test scope: this new 414-line file mixes unrelated concerns and carries more fixture/process scaffolding than the lifecycle contract needs. Please compact it using these inline suggestions together with the previously requested redundant-test removals and minimal process fixture. The goal is focused coverage and less maintenance surface, not an arbitrary line limit.

Propagate backend-stored STOP callback failures while allowing every listener and context cleanup phase to run.

Make OVPhysX exit coverage CPU-portable and consolidate lifecycle tests around their owning modules.
Drop both singleton and local context references before collecting garbage so native owners are destroyed inside the teardown boundary.

Cover the ordering with a weak-reference regression test.
@kellyguo11

Copy link
Copy Markdown
Contributor

let's look into why the rendering correctness tests are failing on this one

@kellyguo11 kellyguo11 moved this to In review in Isaac Lab Aug 3, 2026
Preserve current lazy-manager and renderer teardown behavior while
keeping the cleanup on the public OVPhysX 0.5.9 API.
@marcodiiga
marcodiiga requested a review from fatimaanes as a code owner August 8, 2026 15:33
@kellyguo11
kellyguo11 merged commit 2404010 into isaac-sim:develop Aug 8, 2026
46 of 47 checks passed
@github-project-automation github-project-automation Bot moved this from In review to Done in Isaac Lab Aug 8, 2026
@marcodiiga
marcodiiga deleted the task/remove-carbonite-and-usd-namespaced-hacks-c952c4 branch August 8, 2026 21:27
hujc7 added a commit to hujc7/IsaacLab that referenced this pull request Aug 11, 2026
Develop removed the pre-0.5.9 OvPhysX compatibility code in 2404010
(Remove obsolete OVPhysX bootstrap hacks, isaac-sim#6074), so the legacy half of
this branch no longer has a runtime to configure. Resolve in develop's
favour and keep only the cooked-collider cache setting:

- drop the legacy PhysX branch and its /UJITSO/datastore/localCachePath
  override; the pinned runtime takes the typed cooked_collider_cache_dir
- restore the "import os" that the auto-merge dropped along with develop's
  removal of os._exit, since _derived_data_cache_dir still needs it
- fold the cache assertion and a strict PhysXConfig fake into develop's
  parametrized test_manager_supports_pinned_runtime_api and delete the
  standalone runtime matrix, whose legacy stubs no longer match any code
hujc7 added a commit that referenced this pull request Aug 27, 2026
…eter directory (#6889)

## 1. Summary

- Kitless `physics=ovphysx` runs wrote their UJITSO derived-data cache
into the **directory holding the Python interpreter**. The location is
now a config field defaulting to a per-user directory under the system
temp directory, created owner-only.
- Fixes nvbug 6537980: where that directory is not writable (uv reusing
a system `/usr/bin/python3.12`), every run logged two `[Error]
[omni.datastore]` lines.
- Where it *was* writable there was no error at all, and the cache was
silently written inside the Python installation — shared by every
project using that interpreter, and discarded on an interpreter upgrade.

## 2. Root cause

The `ovphysx` wheel bundles its own Carbonite, which resolves the UJITSO
cache from `realpath("/proc/self/exe")` + `/cache/DerivedDataCache` when
no path is configured.

That assumption — *the executable's directory belongs to me* — holds for
Kit, whose `kit` binary lives in its own application package next to a
`cache/` sibling. It breaks for every embedder, where the "executable"
is a shared Python interpreter whose directory the program does not own.

## 3. Fix

`OvPhysxCfg.cooked_collider_cache_dir` selects the directory and
`_create_physx_instance` passes it to
`ovphysx.PhysXConfig(cooked_collider_cache_dir=...)`, mirroring how the
sibling kitless renderer threads `OVRTXRendererCfg.log_file_path` into
`RendererConfig`.

The field is `str | None`: `None` is forwarded unchanged so OVPhysX
applies its own resolution, which `PhysXConfig` has accepted since the
pinned 0.5.9.

The default is `<temp>/ovphysx_derived_data_cache_<uid>`. Because that
lives in a world-writable root, `_prepare_default_cache_dir` creates it
with `os.makedirs(..., mode=0o700)` and, when the path already exists,
`os.lstat`-rejects a symlink, a non-directory, or a directory owned by
another user — a symlink planted there is otherwise followed and written
through. A *configured* directory is passed through untouched, so a site
can still point the field at a provisioned shared cache.

## 4. Validation

```
uv run isaaclab train --rl_library rsl_rl --task Isaac-Cartpole-Camera-Direct \
    physics=ovphysx renderer=ovrtx presets=rgb --num_envs 32 --max_iterations 2
```

Run three ways, varying only the fix and whether the interpreter
directory is writable:

| Arm | Fix | Interpreter dir | `omni.datastore` errors | Cache written
to |
|---|---|---|---|---|
| A0 | reverted | writable | 0 | **interpreter's
`bin/cache/DerivedDataCache`** |
| A1 | reverted | read-only | **2** | not created |
| B | applied | read-only | **0** | the configured directory |

Arm A1 reproduces both reported lines verbatim. Arm A0 shows this is a
wrong-location bug rather than a permissions bug: no error, cache still
in the wrong place. All three arms exit 0 with training completing.

## 5. Test

- `test_manager_supports_pinned_runtime_api` — the cache assertion and a
strict `PhysXConfig` fake fold into the existing CPU/GPU
parametrization; both fail when the keyword is removed.
- `test_construct_physx_passes_the_configured_cooked_collider_cache_dir`
— pins the config-to-runtime seam, with a no-config fallback case.
Verified to fail when `_construct_physx` stops reading the config.
- `test_construct_physx_forwards_an_unset_cooked_collider_cache_dir` —
`None` reaches `PhysXConfig` unchanged.
- `test_default_cache_dir_is_created_owner_only`,
`..._rejects_a_planted_symlink`,
`..._rejects_a_directory_owned_by_another_user`.

## 6. Notes

- Earlier revisions also configured a pre-0.5.9 legacy runtime. Develop
removed that code in #6074, so this branch targets the pinned runtime
only.
- The default path is per-user but predictable, so a TOCTOU window
remains between the ownership check and OVPhysX opening the path. A
home-rooted parent would close it structurally at the cost of the
temp-rooted convention the ov packages already use.
- The datastore is created once per process, so the first OVPhysX
construction fixes the cache location.
The runtime garbage collects the cache against a disk budget; deleting
the directory reclaims it immediately.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation infrastructure isaac-lab Related to Isaac Lab team

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants