Skip to content

Refactor and simplify OV cloning and stage ownership - #8232

Merged
ooctipus merged 6 commits into
isaac-sim:developfrom
ooctipus:extract-ovrtx-ovstage-cloners
Oct 16, 2026
Merged

ooctipus merged 6 commits into
isaac-sim:developfrom
ooctipus:extract-ovrtx-ovstage-cloners

Conversation

@ooctipus

@ooctipus ooctipus commented Oct 1, 2026 •

Copy link
Copy Markdown
Collaborator

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.

Startup reproduction harness

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

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.

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()

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

  • 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 (native runs include existing SDK and Torch warnings)
  • I have validated the changed behavior with focused coverage
  • I have added changelog fragments for the changed packages
  • My name already exists in CONTRIBUTORS.md

@github-actions github-actions Bot added the isaac-lab Related to Isaac Lab team label Oct 1, 2026
@ooctipus ooctipus changed the title Extract the OVRTX and OVStage cloning into the OV cloner Prepare OVRTX and OVStage cloning through one clone context Oct 1, 2026
@ooctipus
ooctipus marked this pull request as ready for review October 1, 2026 06:03
@ooctipus
ooctipus requested a review from a team October 1, 2026 06:04
@greptile-apps

greptile-apps Bot commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 4/5

[High impact] Refactors clone-context lifecycle and stage ownership across physics and rendering.

Prepare the active scene's copies for late-created renderers before merging.

Findings

  1. P1 Late cameras lose scene contents ▶

Summary

Moves clone routing ahead of native resource creation and gives the simulation ownership of rendering stages.

  • Clone contexts prepare their routes before native backends are created.
  • OVRTX rendering selects native cloning or a simulation-owned OVStage.
  • Backends place environment copies instead of the authored scene.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart LR
    A[Consumer configurations] --> B[Prepare clone routes]
    B --> C[Simulation-owned resources]
    B --> D[Dispatch clone plan]
    D --> E[Store copies and placement]
    E --> F[Export and populate scene]
    F --> G[Camera bindings and rendering]
    H[Late renderer] --> B
Loading

Reviews (3) · Last reviewed commit: "Extract OVRTX and OVStage cloning into t..." · Reviewed by 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

The clone-preparation move into OvrtxReplicateContext is consistent with the existing backend dispatch boundary, and no compatibility break was identified. Before merge, remove two implementation/configuration-shape assertions that do not protect observable behavior and complete the public context method’s argument documentation.

  • Design and architecture: The new priority-100 clone context gives plan interpretation and routed-copy preparation a single owner, while OVRTXBackend stores the prepared copies, environment paths, and positions for either native scene implementation. The grouping, covered-child suppression, self-copy filtering, and parent-before-child ordering follow the adjacent clone-context architecture.
  • API: The exported ovrtx_replicate, ovstage_replicate, and OvrtxReplicateContext are additive, and the removed renderer helper was private. The native operations document their copy and placement contracts, but the public OvrtxReplicateContext.replicate method should add Google-style documentation for plan and asset_prototype_ids and clearly describe the backend state it publishes.
  • Compatibility and deprecation: Breaking changes: none identified. The deleted _clone_sources helper was private, the new cloning_contexts default preserves automatic clone preparation, and both native operations retain clone-before-placement ordering for legacy OVRTX and OVStage.
  • Implementation: The prepared-copy path was traced through world grouping, routed asset filtering, ancestor coverage suppression, depth ordering, backend publication, stage export, and final native execution. The implementation keeps clone-plan interpretation out of the two native execution functions and preserves the renderer’s clone-then-partition flow.
  • Style consistency: Naming, placement, type annotations, and deferred optional-runtime imports match the adjacent OvPhysxReplicateContext and ovphysx_replicate patterns. The public replicate docstring is incomplete relative to the repository’s Google-style public API requirements and its documented sibling.
  • Test quality: The routing matrix, export exclusion case, native OVRTX/OVStage execution coverage, and GPU integration hookup exercise distinct behavior. Remove test_native_cloners_keep_plan_interpretation_in_the_context, which AST-greps names and private code shape rather than behavior, and remove the cloning_contexts prefix assertion from the geometry-binding test, which merely restates configuration and is vacuous for an empty tuple.

Minor fixes needed. Posted 3 actionable findings inline.

Automated review; human maintainers own approval decisions.

assert not exported.GetPrimAtPath(f"{root}/Object_env{env_id}_only")


def test_native_cloners_keep_plan_interpretation_in_the_context():

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.

🟡 Warning · Test Quality — Structural source-grep test asserts code shape

This case asserts the absence of symbol names that never existed, checks OVRTXRenderer lacks a private method, and AST-greps the two native functions for identifiers named plan/cloner. It protects no observable behavior: a behavior-preserving rename turns it red, while a plan-interpreting implementation under other names passes. The clone-context routing and native-replication cases already own this contract; remove it.

def __init__(self, sim_context: SimulationContext):
self._sim = sim_context

def replicate(self, plan: ClonePlan, asset_prototype_ids: tuple[int, ...]) -> None:

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 · Style Consistency — New public replicate omits Args documentation

OvPhysxReplicateContext directly above documents sim_context in __init__ and both plan and asset_prototype_ids under Args:. This new public context documents neither, and its docstring states a refactoring rule for renderers rather than the method contract or the backend fields it populates. Add the Args: section and describe the published state, leaving design history in the changelog fragment.

use_ovstage = mode == "ovstage"
assert not renderer.cfg.cloning_contexts
# Geometry reaches OVRTX through SDP, so no Newton clone context may be declared for it.
assert all(str(context).startswith("isaaclab_ov.cloner:") for context in renderer.cfg.cloning_contexts)

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 · Test Quality — Config restatement inside geometry-binding test

The assertion only restates the new cloning_contexts default via a string prefix, inside a test that owns mixed SDP point publication. It passes vacuously for an empty tuple, fails if a context is declared as a class object rather than a string, and never checks the Newton claim in the adjacent comment. Drop the assertion and comment; clone-context coverage belongs in the clone-plan tests.

@ooctipus ooctipus changed the title Prepare OVRTX and OVStage cloning through one clone context Unify OV rendering scene ownership and cloning Oct 1, 2026
@github-actions github-actions Bot added the documentation Improvements or additions to documentation label Oct 1, 2026
@ooctipus ooctipus changed the title Unify OV rendering scene ownership and cloning Refactor OVStage and OVRTX scene ownership and cloning Oct 1, 2026
@ooctipus
ooctipus requested a review from fatimaanes as a code owner October 1, 2026 19:15
@ooctipus
ooctipus marked this pull request as draft October 1, 2026 19:16
@ooctipus ooctipus changed the title Refactor OVStage and OVRTX scene ownership and cloning Share OVStage ownership and cloning between OVPhysX and OVRTX Oct 1, 2026
@ooctipus ooctipus changed the title Share OVStage ownership and cloning between OVPhysX and OVRTX Refactor OVRTX and OVStage cloning with opt-in shared physics Oct 1, 2026
@ooctipus
ooctipus marked this pull request as ready for review October 1, 2026 20:23
Comment on lines +167 to +168
if self.ordinal:
return

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 Shared stage retains stale geometry

On a forced OVPhysX re-warm after the authored USD changes, the shared stage already has a nonzero ordinal. populate(stage_usda) therefore returns without importing the newly serialized scene, and physics reattaches the old bodies and geometry. The simulation then runs against a scene that no longer matches the current USD.

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.

the bot here is actually right

raise RuntimeError("Scene not initialized. Call initialize() first.")
if self.backend.renderer is None or not self._camera_render_data:
return
products = {camera.render_product_path for camera in self._camera_render_data}

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 Shared engine omits camera products

When cameras with different OVRTX product configurations share one native engine, each renderer instance submits only its own products. A product that leaves and later re-enters the submission set can incur the expensive restart that all-products-per-step batching is meant to avoid.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

@ooctipus
ooctipus requested a review from hujc7 as a code owner October 1, 2026 21:11
Comment on lines +126 to +127
from ..cloner.replicate_session import _prepare_clone_contexts # noqa: PLC0415
from ..sim import SimulationContext # noqa: PLC0415

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.

Is it necessary to defer these imports?

self._sim.physics_manager._clone_recipes.extend(recipes)


class OvrtxReplicateContext:

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.

Hey @ooctipus more of a high level question. I see "replicate" and "clone" used interchangeably throughout the code base. Do they mean the same thing? Would it make sense to converge on one term?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

yes they mean the same thing

@rilei-nvidia

Copy link
Copy Markdown
Collaborator

@r-schmitt were you working on something similar? sharing of ovstage.Stage between ovphysx and ovrtx

plan: Replication layout shared by every clone backend.
asset_prototype_ids: Asset definitions routed to native OVRTX scenes.
"""
from isaaclab_ov.renderers.ovrtx_renderer_cfg import OVRTXBackendCfg # noqa: PLC0415

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.

Does this import need to be inline here?

Comment thread source/isaaclab_ov/isaaclab_ov/stage.py Outdated
Args:
usda: USD scene containing the routed prototypes and their materials.
"""
from isaaclab_ov.cloner import ovstage_replicate # noqa: PLC0415

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.

import at top of file?

Comment on lines +167 to +168
if self.ordinal:
return

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.

the bot here is actually right

raise RuntimeError("Scene not initialized. Call initialize() first.")
if self.backend.renderer is None or not self._camera_render_data:
return
products = {camera.render_product_path for camera in self._camera_render_data}

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.

After thinking about this, maybe the products should be added to OVRTXBackend rather than here.

}
# Backend packages own selection rules; core preparation has no optional SDK dependencies.
for context in tuple(routing):
if context in routing and (prepare := getattr(context, "prepare", None)) is not None:

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.

can we get rid of getattr?

from isaaclab_ov.renderers.ovrtx_renderer_cfg import OVRTXBackendCfg, OVRTXRendererCfg # noqa: PLC0415
from isaaclab_ov.stage import OvstageBackendCfg # noqa: PLC0415

renderers = [(cfg, renderer) for cfg, renderer in sim._backend_registry if isinstance(cfg, OVRTXRendererCfg)]

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.

I think in sim you added close_backend and get_or_create_backend, instead of accessing directly the backend registry, maybe you can just add a third get_backend to help you here instead of accessing _backend_registry?

import ovstage # noqa: PLC0415

from isaaclab_ov.renderers.ovrtx_renderer import ( # noqa: PLC0415
_read_gpu_transforms_enabled,

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.

_ method is being imported. I saw this pattern in a few places, if something is meant to be public, drop the _

replicate_priority = 100

@staticmethod
def prepare(sim: SimulationContext, routing: dict[type, set[int]]) -> None:

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.

Side thought: I wonder if we should have prepare not be static and have core call prepare, and the replication context can then keep a reference to the backend it creates. (might be worth investigating)

@ooctipus
ooctipus deleted the extract-ovrtx-ovstage-cloners branch October 14, 2026 14:28
@ooctipus
ooctipus restored the extract-ovrtx-ovstage-cloners branch October 14, 2026 15:04
@ooctipus ooctipus reopened this Oct 14, 2026
Comment on lines +203 to +206
scene = sim.get_or_create_backend(OvstageBackendCfg(scene_key=backend_cfg)) if use_ovstage else None
renderer.backend = sim.get_or_create_backend(backend_cfg)
renderer.scene = scene if use_ovstage else renderer.backend
renderer._use_ovstage = use_ovstage

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 Late cameras lose scene contents

A renderer registered after clone dispatch gets a new backend without the active plan's copies. This affects standalone cameras added after scene construction and cameras using a new OVRTXRendererCfg after physics starts. prepare_clone_contexts() allocates resources but never calls _prepare_scene_copies(), leaving clone_copies and the environment paths empty.

For multiple environments, prepare_stage() then exports with no sources and removes the scene's environment contents. The camera cannot render the cloned scene. Prepare the active plan's rendering routes for each new backend before exporting it, without replaying physics cloning.

@ooctipus
ooctipus force-pushed the extract-ovrtx-ovstage-cloners branch from c514f89 to f23aecd Compare October 16, 2026 03:53
@ooctipus

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
@ooctipus
ooctipus force-pushed the extract-ovrtx-ovstage-cloners branch from f23aecd to 2fd269c Compare October 16, 2026 21:30
@ooctipus

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
@ooctipus

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
@ooctipus

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
@ooctipus
ooctipus merged commit 09c36f5 into isaac-sim:develop Oct 16, 2026
59 checks passed
ooctipus added a commit that referenced this pull request Oct 17, 2026
# Description

Adds opt-in sharing of one simulation-owned OVStage between OVPhysX and
OVRTX. Clone preparation combines their asset routes, populates both USD
domains, and clones once. The default paths remain separate.

Enable sharing with `ISAAC_LAB_SHARE_OVSTAGE=1`. This requires OVPhysX
and selects OVStage rendering regardless of
`ISAAC_LAB_OVRTX_USE_OVSTAGE`. Configure cameras and flags before the
first reset.

Without flags, OVPhysX keeps separate physics and rendering stages;
Newton uses native OVRTX cloning. The RTX flag alone selects independent
OVStage rendering.

- Camera construction resolves PPISP and authors RTX exposure settings
before cloning or importing the scene, including existing cameras
(`spawn=None`). Renderers consume the prepared configuration during
normal initialization. The redundant `prepare_cameras()` phase is
removed: custom renderer runtime setup belongs in
`create_render_data()`, with the stage available through
`self._sim.stage`. Author PPISP attributes before constructing the
sensor.
- Shared-stage cameras borrow one OVRTX engine; native logging and
transform-cache settings must agree. Rendering reuses the populated
scene without another USD export unless a debug dump was requested.
- Private and shared physics stages use `OvstageBackend` for population,
queries, write ordinals and cleanup. `OvPhysxBackend.load()` owns
detach, rebuild and attach; the manager no longer implements separate
stage setup or an ordinal counter. Physics owns private stages and
borrows shared ones.
- Full-stage physics imports are rejected before population because
prototype-only cloning would discard authored environment overrides.
Disable sharing for those scenes.
- Native setup imports its dependencies directly and registers the
schema paths selected by the existing SDK compatibility layer. Binding
cleanup uses the renderer’s resource stack and propagates failures after
releasing resources.

Includes the merged #8232 foundation through the base branch; this diff
contains only the sharing feature.

## Performance: sharing remains opt-in

Kuka Allegro Lift camera, OVPhysX 0.6.3, OVRTX 0.5.0.377615, OVStage
0.2.0.377349, RTX 5090, `single_camera,rgb64`:

| Measured revision / cloning | Startup, 128 envs | Startup, 1,024 envs
| Step, 1,024 envs |
|---|---:|---:|---:|
| Develop `c9a40a1de`, separate OVPhysX + OVStage rendering | 24.1 s |
70.1 s | 80.4 ms |
| Foundation `0018ae99d`, separate OVPhysX + OVStage rendering | 22.0 s
| 70.8 s | 81.3 ms |
| Shared feature `eee513324`, shared OVStage | 51.7 s | Stopped at a 180
s process limit before the first image | Unavailable |

Historical diagnostic runs, one process per configuration. Step time is
the median of 60 synchronized steps after 15 warmups. Startup covers
environment construction, reset and first image, excluding imports; the
process limit includes imports. These runs predate flag separation and
were not repeated for this cleanup.

At 128 environments, the physics pose binding used by rendering took
31.14 s with sharing versus 0.63 s without it. The 1,024-environment
shared run was still creating physics tensor bindings when stopped.
Sharing remains opt-in until upstream cold-binding and shared-stage
update performance are fixed and validated; no SDK fix or speedup is
assumed.

## Validation

**48 focused cases passed** for `2a9784981`: camera construction/output
contracts, PPISP configuration, exposure and GPU kernels, Newton lens
distortion, Newton and Kit RTX PPISP rendering, and shared OVStage
rendering/reset. Existing tests now cover pipeline reuse across image
resolutions and preservation of USD schema list edits. The schema-edit
regression fails against the old manual metadata merger and passes with
`AddAppliedSchema()`. The earlier construction regression also fails
with the pre-fix constructor.

The follow-up removed another 117 production lines net (98 net including
tests and changelogs): the extra camera preparation phase, cached stage
alias, two controller helpers, repeated normalization after USD
discovery, and generic exposure conversion/schema merging. Standalone
pipeline normalization is retained for callers passing partial
configurations.

The preceding `373c7c4e1` passed 196 focused lifecycle, SDP, renderer,
native-view, SDK compatibility, material and shared-stage cases. Test
files ran in separate processes; native GPU checks used **GPU0** with
OVPhysX 0.6.4, OVRTX 0.5.1, and OVStage 0.2.1.

The integration tests cover contact isolation, calibration,
shared-engine submission, gravity changes, soft reset, forced reload and
USD debug dumps. Schema tests retain host-plugin conflict coverage;
version selection is covered at its existing compatibility boundary. The
existing renderer lifetime test now verifies failure propagation and
complete cleanup, and fails for the intended reason when the previous
shutdown implementation is restored.

`uv run isaaclab -f`, changelog validation and `git diff --check`
passed. Documentation builds are left to CI. These correctness checks do
not establish that the historical sharing performance issues are
resolved.

## 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`
@r-schmitt r-schmitt mentioned this pull request Oct 17, 2026
7 of 8 tasks
ooctipus pushed a commit that referenced this pull request Oct 19, 2026
# Description

Restore native OVRTX cloning when `ISAAC_LAB_OVRTX_USE_OVSTAGE` is
unset. #8232 changed the default to independent OVStage rendering for
OVPhysX, so existing nightly camera benchmarks silently switched
rendering paths and lost throughput. Explicit
`ISAAC_LAB_OVRTX_USE_OVSTAGE=1` and `ISAAC_LAB_SHARE_OVSTAGE=1` remain
supported.

Update the existing default-routing regression case, the clone-routing
documentation, and the package changelog. No backport is needed:
`release/3.0.0` still has the legacy default.

The investigation compared `cff854ab` with develop `0ab97e9c811` on an
RTX PRO 6000 Blackwell, with fixed dependencies, 256 environments, 50
warmup steps, 300 measured steps, and seed 42. Throughput is in
environment steps/s:

| Task | Last good, legacy | Develop, explicit legacy | Develop, unset
(OVStage) |
| --- | ---: | ---: | ---: |
| Isaac-Reorient-Cube-Shadow-Camera-Direct (RGB 120×120) | 7,019 | 7,028
| 6,057 |
| Isaac-Lift-KukaAllegro-Camera (single RGB 64×64) | 2,999 | 2,993 |
2,875 |

The fix restores the selection used by the explicit-legacy column; these
performance measurements were taken during the investigation before this
patch.

## Validation

- The updated `ovphysx-default` case fails on the original production
code because it selects `OvstageReplicateContext` instead of
`OvrtxReplicateContext`.
- `uv run --no-sync python -m pytest
source/isaaclab_ov/test/test_ovrtx_renderer_contract.py -q`: **53
passed**. Existing TorchScript deprecation warnings remain.
- `ISAACLAB_CHANGELOG_BASE_REF=origin/develop uv run --no-sync isaaclab
--format`: passed across the repository.
- `uv run --no-sync python tools/changelog/cli.py check origin/develop
--include-worktree`: passed.

- Clean Sphinx HTML build with warnings treated as errors (`-W
--keep-going -j 4`): passed. Documentation dependencies ran in an
isolated uv overlay; the simulation environment was not synchronized.

## Type of change

- Bug fix
- Documentation update

## Release backport

- [ ] <!-- backport-active-release --> Backport this pull request to the
active release branch after it merges into `develop`

## Checklist

- [x] Read the contribution guidelines.
- [x] Ran the repository formatting and lint checks.
- [x] Updated the documentation.
- [x] No new warnings introduced by this change.
- [x] Validated the changed behavior and applied the test-audit criteria
to the existing regression case.
- [x] Added a changelog fragment for the changed package.
- [x] Contributor is already listed in `CONTRIBUTORS.md`.
@ooctipus
ooctipus deleted the extract-ovrtx-ovstage-cloners branch November 14, 2026 09:43
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 isaac-lab Related to Isaac Lab team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants