Skip to content

Route clone backends through ClonePlan - #7462

Open
ooctipus wants to merge 2 commits into
isaac-sim:developfrom
ooctipus:codex/flattened-clone-plan
Open

Route clone backends through ClonePlan#7462
ooctipus wants to merge 2 commits into
isaac-sim:developfrom
ooctipus:codex/flattened-clone-plan

Conversation

@ooctipus

@ooctipus ooctipus commented Aug 31, 2026

Copy link
Copy Markdown
Collaborator

Description

This is a narrow follow-up to #7453. That PR removes Newton's full post-replication entity-label pass; this PR preserves that fast path and makes the existing ClonePlan the single mapping consumed by USD, Newton, PhysX, and OvPhysX replication.

Planning records context_rows, which maps each simulation-owned clone-context type to the plan rows it consumes. cloner.replicate(plan) retrieves those already-registered contexts from SimulationContext, orders them by replication priority, and passes each the same plan. The backends no longer rebuild that mapping through local queue(...) or queue_mapping(...) state.

The public structure stays small:

  • ClonePlan.global_paths remains the explicit declaration for shared scene prims; globals are not encoded as artificial zero-mask rows.
  • ClonePlan.env_ids and positions remain optional for query-only plans; execution validates what it needs.
  • Per-asset cloning_contexts, cfg_rows, ReplicateSession, and the current InteractiveScene/direct construction lifecycle remain.
  • Standalone tooling keeps usd_replicate(...), newton_physics_replicate(...), physx_replicate(...), and ovphysx_replicate(...).
  • OVRTX, camera, export, and SDP work is deferred to the renderer cutover. This PR changes OvPhysX cloning only.
  • No plan-owned environment template, stage discovery, fallback context construction, registry-wide duck routing, or second clone mapping is introduced.

Migration

Custom clone contexts now implement replicate(plan) and must be registered with SimulationContext.get_or_create_backend(...) before dispatch. Built-in physics managers expose clone_context_type and register their own context during initialization. Remove context-local queue(...) / queue_mapping(...) calls and the former backend PHYSICS_CONTEXT aliases; raw standalone replication functions remain available.

The high-level stage= argument is removed from cloner.replicate(...) and ReplicateSession; each simulation-owned context already owns its stage.

Size

Both pieces of the stack are net-negative:

Change Added Deleted Net
#7453 195 218 -23
This follow-up after #7453 overlap is removed 688 1,159 -471
Current combined PR view 863 1,354 -491

#7462 currently carries the exact #7453 fast-path files so it can be tested independently. They will disappear from this diff when #7453 merges and this branch is restacked.

Performance

All measurements used physical GPU 0 and the same Newton revision. The targeted benchmark warms with 128 worlds, then times replication and all required label publication for one 48-body/48-shape Newton prototype at 4,096 worlds (two samples):

Revision Targeted median Versus pre-#7453 develop
develop 1.428 s
#7453 1.171 s -18.0%
this PR 1.181 s -17.3%

The follow-up is 0.8% from #7453, within run-to-run noise, and preserves the removed-pass gain. The production Newton path still prefixes entity labels inside ModelBuilder.replicate(...) and does not add a later whole-builder label pass.

One uncontended representative warm verification used 4,096 Kuka Allegro environments, headless Newton MJWarp physics, no renderer, no interactive visualizer, and one step:

CUDA_VISIBLE_DEVICES=0 /usr/bin/time -f 'WALL_TIME_S=%e' \
  uv run --no-sync isaaclab zero_agent \
  --task Isaac-Lift-KukaAllegro --num_envs 4096 --max_steps 1 \
  --device cuda:0 --visualizer none physics=newton_mjwarp
Revision Warm wall InteractiveScene creation
#7453 two-sample median 21.39 s 6.345 s
this PR verification sample 21.10 s 6.268 s

The targeted path and representative whole workload show no startup regression.

Type of change

  • Breaking clone-context interface simplification
  • Documentation update

Validation

  • 98 core plan/session and OvPhysX tests passed
  • 31 Kit-backed core cloner tests passed, including sparse environment IDs
  • 26 PhysX cloner tests passed; 1 skipped, 2 expected failures, and 2 expected passes
  • 10 InteractiveScene lifecycle tests passed
  • Repository formatting, lint, RST, spelling, license, changelog, LFS, and hygiene hooks passed against the stacked branch base
  • git diff --check passed
  • Targeted label-publication and 4,096-environment Kuka comparisons passed the no-regression gate on GPU 0

Release backport

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

Checklist

  • I have read and understood the contribution guidelines
  • I have run the relevant pre-commit checks
  • I have made corresponding documentation changes
  • I have added focused contract, routing, and lifecycle tests
  • I have added a changelog fragment for every touched source package
  • My name already exists in CONTRIBUTORS.md

@ooctipus
ooctipus requested a review from a team August 31, 2026 23:33
@ooctipus ooctipus added the documentation Improvements or additions to documentation label Aug 31, 2026
@ooctipus ooctipus added the isaac-lab Related to Isaac Lab team label Aug 31, 2026
@greptile-apps

greptile-apps Bot commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

Too many files changed for review (295 files, 100 file limit).

Bypass the limit by tagging @greptile-apps to review.

@github-actions github-actions Bot added the asset New asset feature or request label Aug 31, 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

The flattened ClonePlan/ReplicateSession lifecycle is coherent overall, but cfg discovery can incorrectly turn sensor visualizer configs into conflicting plan rows, camera spawning removes established redirect/existence behavior, the RayCasterCfg.spawn default change lacks migration guidance, and startup profiling still targets the removed dispatch name.

  • Design and architecture: Publishing one immutable plan before construction and dispatching it to registered backends provides a single description of clone ownership. However, _plan_cfgs also classifies visualizer marker configs as prim authors; sensors sharing a default marker path can therefore fail planning with duplicate ownership. Visualizer-only configs should be excluded from clone-plan rows.
  • API: The major changelog covers the removed cloner entry points and most cfg/spawner field removals. It does not cover the RayCasterCfg.spawn default changing from SensorFrameCfg() to None. Camera construction also drops the previous physics-body-to-child redirect and existing-prim guard, changing behavior for public CameraCfg usages that target bodies or pre-authored cameras.
  • Implementation: Plan construction, source-path resolution, and backend dispatch were traced. The remaining implementation integration issue is the startup profiler whitelist still matching cloner.*:replicate after dispatch was renamed to _replicate, causing clone-dispatch measurements to be reported as zero placeholders.

Significant concerns. Posted 4 actionable findings inline.

The full PR diff was reviewed; some supplemental surrounding file context was omitted.

Automated review; human maintainers own approval decisions.

declared = set(field_names)
spawn = value.spawn if "spawn" in declared else None
if "prim_path" in declared and (
spawn is not None or "collision_group" in declared or "markers" in declared

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 · Design Architecture — Visualizer marker cfgs become conflicting plan rows

_plan_cfgs treats any cfg with prim_path plus markers as a prim author, so each sensor's visualizer_cfg becomes a plan row when debug_vis=True. Two sensors keeping the shared default visualizer path — pva_LF and pva_RF in scripts/demos/sensors/pva_sensor.py, which this PR migrated to ReplicateSession — then abort planning with the duplicate-destination (or duplicate-binding) error. Exclude visualizer marker cfgs from planning.


spawn_target = spawn.spawn_path or self.cfg.prim_path
if sim_utils.find_first_matching_prim(spawn_target) is None:
source_paths = cloner.query.cfg_source_paths(self._clone_plan, self._source_cfg)

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 · Api — Camera spawn drops redirect and existence guard

The constructor no longer redirects a camera whose prim_path names a rigid body or articulation root to a /camera child, and it now spawns unconditionally instead of skipping when the prim already exists. A CameraCfg with a spawner pointing at an existing body or pre-authored camera prim therefore changes behavior or fails. Restore the physics-body child resolution and the existence guard per planned source path.

continue
if cfg.cloning_contexts is None:
contexts = [backend_physics_ctx]
def _replicate(plan: ClonePlan, *, replicate_physics: bool = True) -> 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 · Implementation — Startup whitelist misses renamed clone dispatch

replicate was renamed to _replicate, but scripts/benchmarks/startup_whitelist.yaml still whitelists cloner.*:replicate. parse_cprofile_stats matches labels by fnmatch, and cloner.replicate_session:_replicate does not end with :replicate, so the entry now emits a zero placeholder and clone-dispatch time silently disappears from the env_creation startup profile used for the performance gate. Update the pattern.


spawn: SensorFrameCfg | None = SensorFrameCfg()
"""Spawn configuration for the sensor Xform prim.
spawn: SensorFrameCfg | None = 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 · Api — RayCaster spawn default flip lacks changelog note

RayCasterCfg.spawn changes from SensorFrameCfg() to None, so a config that previously auto-created its sensor frame at prim_path now requires the prim to exist and be covered by a plan row; in-tree callers had to add spawn=sim_utils.SensorFrameCfg(). The isaaclab changelog fragment documents the other breaking cfg changes but omits this default, leaving external users without migration guidance.

@ooctipus ooctipus changed the title Flatten clone planning into one lifecycle Use one cfg-derived clone plan and lifecycle Sep 1, 2026
@github-actions github-actions Bot added isaac-mimic Related to Isaac Mimic team infrastructure labels Sep 1, 2026
@ooctipus
ooctipus force-pushed the codex/flattened-clone-plan branch from 5c3ba34 to 5f7619e Compare September 2, 2026 04:10
@ooctipus ooctipus changed the title Use one cfg-derived clone plan and lifecycle Route clone backends through ClonePlan Sep 2, 2026
@ooctipus

ooctipus commented Sep 2, 2026

Copy link
Copy Markdown
Collaborator Author

PR 3 has now been split at the execution/lifecycle boundary.

This PR contains only the existing ClonePlan execution contract and backend routing. The declarative cfg inventory, pre-construction lifecycle, queue deletion, camera/raycaster declaration changes, startup-profiler migration, and broad workflow call-site changes are in the follow-up PR 3B branch.

Accordingly, the earlier automated inline findings on _plan_cfgs, camera spawning, RayCasterCfg.spawn, and the renamed startup-profiler target refer to the previous full head and are no longer present in this diff. The preserved full tip is available on ooctipus:codex/flattened-clone-plan-full.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

asset New asset feature or request documentation Improvements or additions to documentation infrastructure isaac-lab Related to Isaac Lab team isaac-mimic Related to Isaac Mimic team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant