Skip to content

Publish clone plans before scene construction - #7570

Merged
ooctipus merged 10 commits into
isaac-sim:developfrom
ooctipus:codex/cfg-first-clone-lifecycle
Sep 6, 2026
Merged

ooctipus merged 10 commits into
isaac-sim:developfrom
ooctipus:codex/cfg-first-clone-lifecycle

Conversation

@ooctipus

@ooctipus ooctipus commented Sep 4, 2026 •

Copy link
Copy Markdown
Collaborator

Description

This follows #7462 by making the simulation's ClonePlan available before cfg-owned scene construction.

ReplicateSession now builds and publishes the plan on entry, constructs every participant at its planned source path, and dispatches that same object on exit. SimulationContext remains the canonical owner of the plan pointer; no secondary lifecycle state, constructor ownership heuristic, stage discovery, fallback context, or second clone mapping is introduced.

InteractiveScene owns this lifecycle for cfg-declared scenes. An empty InteractiveScene authors only the env-0 prototype and leaves replication to direct task setup. That removes redundant environment-root authoring while preserving direct workflows with custom clone positions. Plan positions remain NumPy during scene construction and become a cached device tensor only when the public env_origins property is read.

Kitless shadow visualization now takes its environment count and world positions from the same plan instead of rediscovering destination env transforms on USD. This lets OVPhysX feed Newton Renderer or OVRTX without requiring redundant destination prims.

Migration

Custom cfg-owned composition roots should use the session around cfg construction:

with cloner.ReplicateSession(asset_cfgs, num_clones=num_envs, env_spacing=env_spacing):
    for cfg in asset_cfgs:
        cfg.class_type(cfg)

Homogeneous direct workflows construct env 0 first, then finish their one clone lifecycle explicitly:

plan = cloner.clone_plan_from_env_0(src, dest, num_envs, positions, global_paths=global_paths)
cloner.replicate(plan)

Size

Scope Added Deleted Net
This PR 180 143 +37
Production 79 79 0
#7462 + this PR 1,413 1,813 -400

Performance

The earlier functional 3B head was performance-neutral in one matched warm sample on physical GPU 0 using Isaac-Lift-KukaAllegro, 4,096 environments, Newton MJWarp physics, and no visualizer:

Metric This PR merged develop
Total startup 42.58 s 43.11 s
Environment creation 39.76 s 39.24 s
First step 0.658 s 0.637 s

The cleanup commits remove redundant empty-scene root authoring and eager environment-origin tensor creation. A current-head Kuka sample will replace this table when the shared physical GPU 0 is idle.

Type of change

  • Breaking change
  • Bug fix
  • Documentation update

Release backport

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

Screenshots

Not applicable.

Validation

  • 92 clone-plan and ReplicateSession tests passed
  • 3 focused InteractiveScene origin/lifecycle tests passed on CPU and CUDA
  • 16 Newton clone/visualization-builder tests passed
  • 22 Newton shadow-model lifecycle tests passed
  • The missing-destination regression test fails with KeyError before the fix and passes after it
  • OVPhysX → Newton Renderer completed creation, reset, and first rendered step with only the env-0 USD prototype
  • Former CI failures passed: visual-material scene (1), multi-mesh ray-caster camera (21), ray-caster integration (7), and Newton duplicate-body frame transforms (4)
  • PhysX and Newton visual-color-randomization demos reached setup and continued through repeated resets
  • Warning-free current documentation build passed
  • Repository formatting, lint, changelog, and LFS checks passed
  • git diff --check passed

The prior isaaclab_rl failure is the independent LEAPP 0.7 regression fixed by #7592; this PR does not duplicate that dependency pin.

Checklist

  • I have read and understood the contribution guidelines
  • I have run the pre-commit checks
  • I have made corresponding documentation changes
  • My changes generate no new warnings
  • I have added focused lifecycle and regression tests
  • I have added the required changelog fragments
  • My name already exists in CONTRIBUTORS.md

@ooctipus
ooctipus requested a review from a team September 4, 2026 11:58
@github-actions github-actions Bot added documentation Improvements or additions to documentation isaac-lab Related to Isaac Lab team labels Sep 4, 2026
@ooctipus

ooctipus commented Sep 4, 2026

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 Sep 4, 2026
@greptile-apps

greptile-apps Bot commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

The PR publishes clone plans before cfg-owned scene construction and enforces a single plan and backend dispatch per simulation.

  • Moves plan publication into ReplicateSession entry and validates constructor registrations against the active plan.
  • Makes InteractiveScene own the lifecycle only for cfg-declared scenes while leaving empty scenes available to direct workflows.
  • Adds lifecycle, ownership, cleanup, and scene behavior tests and updates cloning documentation.

Confidence Score: 4/5

The PR should not merge until failed backend dispatch leaves the clone lifecycle recoverable rather than permanently consumed.

Backend replication remains fallible, but the new ordering marks the plan consumed before invoking any backend, leaving the simulation unable to clear or retry after a failure or partial dispatch.

Files Needing Attention: source/isaaclab/isaaclab/cloner/replicate_session.py and source/isaaclab/isaaclab/sim/simulation_context.py

Important Files Changed

Filename Overview
source/isaaclab/isaaclab/cloner/replicate_session.py Publishes plans on session entry and validates planned constructors, but consumes the lifecycle before fallible backend dispatch completes.
source/isaaclab/isaaclab/sim/simulation_context.py Adds single-plan and single-dispatch enforcement whose consumed state cannot currently be rolled back after dispatch failure.
source/isaaclab/isaaclab/scene/interactive_scene.py Moves cfg-owned construction into the published-plan lifecycle and leaves empty scenes to explicit direct-task cloning.
source/isaaclab/isaaclab/cloner/clone_plan.py Routes global-only paths through the active physics clone context, including plans without populated cfg rows.

Sequence Diagram

sequenceDiagram
    participant Scene as InteractiveScene
    participant Session as ReplicateSession
    participant Sim as SimulationContext
    participant Backend as Clone backends
    Scene->>Session: enter with cfgs
    Session->>Session: make_clone_plan()
    Session->>Sim: set_clone_plan(plan)
    Scene->>Scene: construct planned entities
    Scene->>Session: exit
    Session->>Sim: consume plan
    loop Registered backends
        Session->>Backend: replicate(plan)
    end
Loading

Reviews (1): Last reviewed commit: "Clarify clone plan inspection" | Re-trigger Greptile

Comment on lines 82 to 84
sim._consume_clone_plan(plan)
for context in sorted(contexts, key=lambda item: item.replicate_priority):
context.replicate(plan)

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 Dispatch failure locks clone lifecycle

When a registered backend raises during context.replicate(plan), _consume_clone_plan() has already marked the lifecycle consumed, so cleanup and subsequent replication attempts raise instead of recovering the active SimulationContext.

Knowledge Base Used: Scene and asset composition

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.

Addressed in eca3cd2. The consumed flag and cross-module lifecycle mutation were removed entirely. A partial multi-backend dispatch is not safely retryable without transactional rollback, so retry state is no longer modeled here; ReplicateSession owns publication before construction and dispatches the same plan on exit.

@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 review traced the new cfg-first lifecycle from ReplicateSession.__enter__ through constructor ownership validation and single backend dispatch, including the separate empty-scene/direct-task path. The proposed documentation finding is not accepted because the changelog and cloning guide already instruct custom composition roots to include participants in a plan published before construction and dispatch that same plan once.

  • Design and architecture: Plan publication before cfg-owned construction, single-plan ownership in SimulationContext, and caller-owned cloning for empty InteractiveScene instances form a coherent lifecycle split. The replacement scene_from_cfg gate preserves the prior distinction used for collision filtering.
  • API: The changed compatibility surface is explicitly marked as breaking. The documentation and changelog provide migration guidance for custom composition roots: build and publish one plan covering participants before construction, then dispatch that plan once. Although they do not repeat the exact runtime error wording, they cover the ownership rule underlying it.
  • Implementation: The reviewed paths validate backend registration before consuming the plan, route global-path-only plans to the physics context, clear failed sessions, and keep environment origins synchronized with a subsequently published direct-workflow plan. Focused tests cover pre-construction publication, ownership rejection, single dispatch, failure cleanup, and empty-scene behavior.

No blocking issues. No inline issue met the actionable-evidence threshold; the assessment above records the review feedback.

Automated review; human maintainers own approval decisions.

@ooctipus

ooctipus commented Sep 4, 2026

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 Sep 4, 2026
else:
self.stage.DefinePrim(self.env_prim_paths[0], "Xform")
positions = cloner.grid_transforms(self.num_envs, self.cfg.env_spacing)[0]
self._env_origins = torch.as_tensor(positions, device=self.device)

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.

Do we need _env_origins to be torch tensor? Ideally we want to keep initialization python or numpy array only

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.

Addressed in 579bd62. InteractiveScene now keeps the plan positions as NumPy during construction and materializes/caches the device tensor only when the public env_origins property is first read. Publishing a later direct-workflow plan replaces that cache with the new NumPy positions, so there is still exactly one conversion per plan.

@ooctipus
ooctipus requested a review from hujc7 as a code owner September 5, 2026 03:58
@ooctipus

ooctipus commented Sep 5, 2026

Copy link
Copy Markdown
Collaborator Author

run-ci

@isaaclab-bot isaaclab-bot Bot added the ci:run-docker Trigger the on-demand Docker and GPU CI workflow label Sep 5, 2026
@isaaclab-bot isaaclab-bot Bot removed the ci:run-docker Trigger the on-demand Docker and GPU CI workflow label Sep 5, 2026
@ooctipus

ooctipus commented Sep 5, 2026

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 Sep 5, 2026
@ooctipus

ooctipus commented Sep 6, 2026

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 Sep 6, 2026
@ooctipus ooctipus added the ci:run-docker Trigger the on-demand Docker and GPU CI workflow label Sep 6, 2026
@ooctipus
ooctipus merged commit ad83008 into isaac-sim:develop Sep 6, 2026
83 of 84 checks passed
@ooctipus
ooctipus deleted the codex/cfg-first-clone-lifecycle branch September 6, 2026 10:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci:run-docker Trigger the on-demand Docker and GPU CI workflow 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.

2 participants