Skip to content

keep environment roots for asset-level cloning - #8686

Merged
r-schmitt merged 2 commits into
isaac-sim:developfrom
r-schmitt:dev/rschmitt/ovstage_cloning
Oct 16, 2026
Merged

r-schmitt merged 2 commits into
isaac-sim:developfrom
r-schmitt:dev/rschmitt/ovstage_cloning

Conversation

@r-schmitt

@r-schmitt r-schmitt commented Oct 16, 2026 •

Copy link
Copy Markdown
Collaborator

Description

Fix geometry leaking between environment camera views and misplaced static geometry when using OVStage with asset-level cloning.

The OVStage export previously removed destination environment roots regardless of what was being cloned. Asset-level cloning recreated the children without preserving the roots’ authored USD type, transforms, and scene partition metadata.

Environment roots are now retained for asset-level cloning and removed only when the roots themselves are clone targets. This also preserves the shared scene used by the duo-camera preset’s scene and robot-mounted cameras.

The issue affects repeated asset clones, including heterogeneous environments with repeated variants; it is not limited to homogeneous environments.

Fixes # (issue)

Fix geometry leaking between environment camera views and misplaced static geometry when using OVStage with asset-level cloning.

Type of change

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

Release backport

  • Backport this pull request to the active release branch after it merges into develop

Screenshots

Before After
kuka-lift-before kuka-lift-after
cloth-before cloth-after

Checklist

Docker and GPU tests run on demand. Push the commits you want tested, then
comment run-ci on the pull request.

  • I have read and understood the contribution guidelines
  • I have run the pre-commit checks with uv run isaaclab --format
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have validated the changed behavior with focused coverage and applied the test-audit criteria to any test changes
  • I have added a changelog fragment under source/<pkg>/changelog.d/ for every touched package (do not edit CHANGELOG.rst or bump package versions — CI handles that)
  • I have added my name to the CONTRIBUTORS.md or my name already exists there

@r-schmitt

Copy link
Copy Markdown
Collaborator Author

run-ci

@github-actions github-actions Bot added the isaac-lab Related to Isaac Lab team label Oct 16, 2026
@isaaclab-bot isaaclab-bot Bot added ci:run-docker Trigger the on-demand Docker and GPU CI workflow and removed ci:run-docker Trigger the on-demand Docker and GPU CI workflow labels Oct 16, 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

Needs attention: Test quality (1). Other reviewed categories look good.

  • PR description: The body repeats the opening fix sentence and leaves Fixes # (issue) unresolved; remove both, and cite validation for the duo-camera and heterogeneous-variant claims or narrow them.
  • Design and architecture: Architecture looks good.
  • Scope and over-engineering: No over-engineering issues.
  • API: API changes look good.
  • Compatibility and deprecation: No breaking changes identified.
  • Implementation: Implementation looks good.
  • Style consistency: Style consistency looks good.
  • Test quality: The transform and partition assertions cover the regression, but use_ovstage now selects no production branch and duplicates the same scene build; remove that parameter and assignment.

Minor fixes needed. Posted 1 inline finding.

Automated review; human maintainers own approval decisions.

@greptile-apps

greptile-apps Bot commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; no actionable issues were found.

Summary

Keeps destination environment roots when OVRTXRenderer clones assets beneath them, including when using OVStage.

  • Asset-level OVRTX clones keep their environment roots.

Review was based on source inspection; tests were not run.

Reviews (1) · Last reviewed commit: "keep environment roots when cloning with..." · Reviewed by Greptile

@r-schmitt

Copy link
Copy Markdown
Collaborator Author

run-ci

@isaaclab-bot isaaclab-bot Bot added ci:run-docker Trigger the on-demand Docker and GPU CI workflow and removed ci:run-docker Trigger the on-demand Docker and GPU CI workflow labels Oct 16, 2026
@r-schmitt
r-schmitt merged commit 13c5c49 into isaac-sim:develop Oct 16, 2026
59 checks passed
@r-schmitt
r-schmitt deleted the dev/rschmitt/ovstage_cloning branch October 16, 2026 20:06
ooctipus added a commit that referenced this pull request Oct 16, 2026
# Description

Clone preparation now resolves native representations before
initialization, and the simulation registry owns OVStage resources. This
PR contains the cloning foundation and its simplification. Shared
OVPhysX/OVRTX stages remain isolated in #8279.

Without flags, OVPhysX keeps native physics cloning and OVRTX uses an
**independent rendering OVStage**; Newton uses native OVRTX cloning.
`ISAAC_LAB_OVRTX_USE_OVSTAGE=0` or `1` overrides the rendering path
without changing physics ownership. This policy is resolved in
`OvrtxReplicateContext.prepare`, in `isaaclab_ov/cloner/replicate.py`,
before backend initialization. The renderer-side switch helper was
removed. #8279 adds separate opt-in flags for sharing.

- `ReplicateContext` gives USD, PhysX, Newton, OVPhysX, OVRTX and
OVStage one explicit preparation/dispatch contract. Removed optional
method discovery and duplicate constructors. Preparation is inline
before context construction, standalone reset and late renderer
initialization. Custom contexts must inherit the base and implement
`replicate`; no compatibility shim was added.
- `OvstageBackend` owns population, prepared copies, queries/path lists
and write ordinals. Contexts use `SimulationContext.get_backends()`;
renderers own bindings and borrow resources. OVRTX constructors declare
requirements without allocating native engines.
- `InteractiveScene` authors prototypes only. SDP reads the environment
count from `ClonePlan`, including native copies absent from USD.
Backends apply planned placement and create required frames in private
exports. Removed recursive deactivation and environment-frame
capture/restore. Routed prototypes are still selected correctly after
USD replication. Deformable discovery and Newton import use authored
source frames rather than infer them from planned destination poses.
- Consolidated camera registration, binding setup, pose conversion,
submission and segmentation decoding. Shared unscaled SDP conversions
and retained asynchronous buffers replace duplicate work. Native
partition writes create missing attributes so sensor cameras exclude
neighboring environments.
- Removed OVStage 0.1 / OVRTX 0.4 compatibility modules and fallbacks.
The pinned OVStage 0.2 and OVRTX 0.5 APIs are used directly, with
concrete stage, binding, frame and buffer types. Preserved current
upstream CUDA stream encoding and stream-ordered mapped-buffer release.

Based on `develop` at `c1e69cc45`, including #8585 and #8686.
Scene-owned cameras and the RTX viewer use the same rendering stage; the
reusable `OvstageBackend` owns its resources. The rebase preserves
renderer-owned markers and runtime geometry, explicit simulation
ownership, scene lighting, and authored environment-root transforms and
metadata. Physics/rendering stage sharing remains in #8279, which needs
to be restacked on this revision.

## Size

Against `develop`: **491 fewer production lines**, 117 additional test
lines and 103 documentation/metadata lines: **271 fewer lines overall**,
across 61 files (+1,932/-2,203). The OVPhysX physics manager, camera
implementation and Newton visualizer match `develop`; shared-stage
coordination stays in #8279.

The benchmark results below are historical measurements at the named
revisions, not new measurements of this rebase.

## Rendering defaults and Kuka measurements

Matched Kuka Allegro Lift camera runs (`single_camera,rgb64`), 1,024
environments, median full environment-step time:

| Physics / measured revision | Native OVRTX cloning | Independent
OVStage rendering |
|---|---:|---:|
| OVPhysX / develop `c9a40a1de` | 113.5 ms | 80.4 ms |
| Newton MJWarp / foundation `0018ae99d` | 18.0–18.3 ms | 30.7–30.8 ms |

OVPhysX used one diagnostic process per path. Newton used two per path
in reversed order. Each measured 60 synchronized steps after 15 warmup
steps. At 128 environments, Newton measured 12.2 ms with OVRTX cloning
versus 14.1 ms with OVStage rendering. Newton was 1.6.1rc1
(`dff296359`), MuJoCo/MuJoCo Warp 3.12.0, using the same OV library
versions and GPU below; both Newton paths used an isolated kernel cache
with fresh LTO artifacts after resolving a pre-existing compiler-cache
mismatch.

With independent OVStage rendering, OVPhysX Kuka startup and stepping
were essentially unchanged by the foundation: develop 70.1 s / 80.4 ms
versus #8232 70.8 s / 81.3 ms at 1,024 environments. These measurements
justify backend-specific rendering defaults; they do not justify
enabling physics/rendering sharing. Shared-stage measurements are in
#8279.

## Native-cloning startup

| Environments | Base median [range], s | PR median [range], s | Change
|
|---:|---:|---:|---:|
| 128 | 4.000 [3.984–4.038] | 4.067 [3.986–4.121] | +1.7% |
| 1,024 | 7.593 [7.492–7.646] | 7.000 [6.985–7.054] | -7.8% |
| 4,096 | 31.715 [31.347–31.799] | 28.851 [28.734–29.019] | -9.0% |

Compared `develop` at `c9a40a1de` with this foundation at `0018ae99d`.
Three measured fresh processes per revision and environment count,
alternating revision order, after one excluded warmup pair per count.
Both use native cloning (`ISAAC_LAB_OVRTX_USE_OVSTAGE=0`). The
128-environment timings overlap; the larger counts show improvement.
These are startup measurements, not shared-stage or steady-state
throughput claims.

Eight rigid cubes per environment, dome lighting, and a tiled 64×64
diffuse/depth camera. Timing covers simulation/scene construction, reset
and the first synchronized image; imports are excluded. **All 24 runs**,
including warmups, checked 4.5 m center depth in every environment.

Threadripper PRO 7965WX; RTX 5090 GPU 1; driver 580.173.02; Python
3.12.12; OVPhysX 0.6.3, OVRTX 0.5.0.377615, OVStage 0.2.0.377349, Warp
1.17.0, Torch 2.12.0+cu130. Both revisions used the same environment and
GPU. No tests or other work used that GPU during timing. The SDK reports
existing CPU powersave/device-masking warnings.

<details>
<summary>Startup reproduction harness</summary>

Save as `benchmark_startup.py`. Use one environment with the dependency
versions above for both checkouts:

```bash
CUDA_VISIBLE_DEVICES=1 /path/to/shared-venv/bin/python benchmark_startup.py --root /path/to/checkout --num-envs 1024 --ovstage 0
```

Repeat at 128, 1024 and 4096 environments: one warmup pair, then three
measured pairs; alternate the order of base and PR runs. Compare
`scene_to_image_s`.

```python
import argparse
import json
import os
import time
from pathlib import Path

started = time.perf_counter()
parser = argparse.ArgumentParser()
parser.add_argument('--root', required=True)
parser.add_argument('--num-envs', type=int, default=128)
parser.add_argument('--ovstage', type=int, choices=(0, 1), default=0)
args = parser.parse_args()
os.environ['ISAAC_LAB_OVRTX_USE_OVSTAGE'] = str(args.ovstage)
# Dependencies are identical; only the selected checkout changes.
import sys
root = Path(args.root)
sys.path[:0] = [str(path) for path in (root / 'source').iterdir() if path.is_dir()]

import numpy as np
import torch
import warp as wp
from isaaclab.app import launch_simulation
from isaaclab.assets import AssetBaseCfg, RigidObjectCfg
from isaaclab.envs import ManagerBasedEnv, ManagerBasedEnvCfg
from isaaclab.scene import InteractiveScene, InteractiveSceneCfg
from isaaclab.sensors import CameraCfg
from isaaclab.sim import CuboidCfg, DomeLightCfg, MassCfg, PinholeCameraCfg, PreviewSurfaceCfg, SimulationCfg, UsdPhysicsCollisionCfg, UsdPhysicsRigidBodyCfg
from isaaclab.utils import configclass
from isaaclab_ov.physics import OvPhysxCfg
from isaaclab_ov.renderers import OVRTXRendererCfg

@configclass
class SceneCfg(InteractiveSceneCfg):
    light = AssetBaseCfg(prim_path='/World/Light', spawn=DomeLightCfg(intensity=1000))
    camera = CameraCfg(
        prim_path='{ENV_REGEX_NS}/Camera', height=64, width=64,
        data_types=['simple_shading_constant_diffuse', 'distance_to_image_plane'],
        spawn=PinholeCameraCfg(focal_length=24.0, horizontal_aperture=20.955, clipping_range=(0.1, 100.0)),
        offset=CameraCfg.OffsetCfg(pos=(0, 0, 5), rot=(0, 0, 0, 1), convention='opengl'),
        renderer_cfg=OVRTXRendererCfg(log_level='error'),
    )

scene_cfg = SceneCfg(num_envs=args.num_envs, env_spacing=10)
for i in range(8):
    setattr(scene_cfg, f'object_{i}', RigidObjectCfg(
        prim_path=f'{{ENV_REGEX_NS}}/Object_{i}',
        spawn=CuboidCfg(size=(1, 1, 1), rigid_props=UsdPhysicsRigidBodyCfg(), mass_props=MassCfg(mass=1),
                       collision_props=UsdPhysicsCollisionCfg(), visual_material=PreviewSurfaceCfg(diffuse_color=(0.8, 0.2, 0.1))),
        init_state=RigidObjectCfg.InitialStateCfg(pos=(float(i % 4) * 1.5, float(i // 4) * 1.5, 0)),
    ))
cfg = ManagerBasedEnvCfg(scene=scene_cfg, sim=SimulationCfg(physics=OvPhysxCfg(), device='cuda:0', gravity=(0.0, 0.0, 0.0)),
                         decimation=1, observations={}, actions={}, events={}, seed=42)
imports_done = time.perf_counter()
with launch_simulation(cfg, {'visualizer': [], 'device': 'cuda:0'}) as _:
    launched = time.perf_counter()
    from isaaclab.sim import SimulationContext
    sim = SimulationContext(cfg.sim)
    try:
        scene = InteractiveScene(cfg.scene)
        constructed = time.perf_counter()
        sim.reset()
        reset_done = time.perf_counter()
        scene.reset()
        scene.update(sim.get_physics_dt())
        data = scene['camera'].data.output
        depth = data['distance_to_image_plane'].torch
        wp.synchronize_device('cuda:0')
        image_ready = time.perf_counter()
        assert tuple(depth.shape) == (args.num_envs, 64, 64, 1), depth.shape
        centers = depth[:, 32, 32, 0].cpu().numpy()
        np.testing.assert_allclose(centers, 4.5, atol=0.02)
        result = dict(ovstage=args.ovstage, num_envs=args.num_envs, imports_s=imports_done-started,
                      launch_s=launched-imports_done, scene_create_s=constructed-launched,
                      sim_reset_s=reset_done-constructed,
                      reset_first_image_s=image_ready-constructed,
                      scene_to_image_s=image_ready-launched, script_to_image_s=image_ready-started,
                      depth_min=float(centers.min()), depth_max=float(centers.max()))
        print('STARTUP_RESULT ' + json.dumps(result), flush=True)
    finally:
        sim.clear_instance()
```

</details>

## Validation

The three previously failing Franka soft/cloth/cable native-OVRTX
golden-image cases passed on GPU0, along with 152 focused clone,
renderer, USD-export and scene-data tests. The environment-count
regression failed before the fix and passed afterward. Existing coverage
was extended; no test files or image tolerances were added. The stale
`OvstageBackend.reset` autodoc reference was removed; the full docs
build runs in CI.

Earlier checks passed 110 profiling-target checks, 71
clone/renderer/binding checks, 10 Newton cloning tests (plus four
subtests), and all seven RTX viewer integration cases. The Newton
placement regression failed before the fix and passed afterward.
Existing tests were extended; no new test files were added.

On GPU0, Shadow Hand passed with OVRTX and Newton rendering. Cartpole
passed 15 cases; its OVStage constant-diffuse comparison failed
identically on `develop`. Kuka's remaining image-comparison failures
also reproduced on `develop`; no image tolerances were changed.

Earlier rebase validation passed 217 focused cases, including both RTX
scene paths, native physics/rendering ownership, camera calibration,
lighting, material synchronization and lifecycle checks. The Coffee GPU
capture reproduction also passed: moving particles changed recorded
pixels without drawing a window. Native validation used GPU0, OVPhysX
0.6.4, OVRTX 0.5.1 and OVStage 0.2.1.

Formatting, changelog validation and `git diff --check` passed.
Documentation builds are left to CI.

## Checklist

- [x] I have read and understood the contribution guidelines
- [x] I have run the pre-commit checks with `uv run isaaclab --format`
- [x] I have made corresponding changes to the documentation
- [ ] My changes generate no new warnings (native runs include existing
SDK and Torch warnings)
- [x] I have validated the changed behavior with focused coverage
- [x] I have added changelog fragments for the changed packages
- [x] My name already exists in `CONTRIBUTORS.md`
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