Skip to content

Conversation

@ooctipus
Copy link
Collaborator

@ooctipus ooctipus commented Nov 5, 2025

Description

This PR refactors cloner logic into usd_replicate, physx_replicate, (also test to work for newton_replicate but not include in this PR)

At the highest level, This PR decouples cloning responsibility away from spawner, and delegate it to a dedicated lab cloner. The only job for spawner is to spawn prototype, and if any cloning is intended, one needs to use the cloner(either USD cloner, Physx Cloner, or Newton Cloner, whether that be homogeneous cloning or heterogeneous cloning).

In detail this PR

  • Adds heterogeneous cloning to InteractiveScene with per-object replication when envs differ, improving PhysX cloning time for heterogeneous scenes while perserving whole env replication in homogenous setting.

  • Introduces scene-level flag InteractiveSceneCfg.random_heterogenous_cloning (defaults True) to control prototype assignment:
    ---True: randomly assigns a prototype per env.
    ---False: uses round‑robin (env_index % num_prototypes) for determinism (previous behavior).

  • Removes hard dependency on the Isaac Sim Cloner; uses internal replicators usd_replicate and physx_replicate.
    Deprecates random_choice in MultiAssetSpawnerCfg and MultiUsdFileCfg in favor of the scene-level flag for consistent, scalable control.

While this PR tries to preserve as much original behavior as possible,
with new refactors, it makes cloning with explicit constraints and composition, even proportion very easy, and I will be working on that as next goal.

Perf

Runing scripts/demos/multi_asset.py with 8192 envs

Before:

[INFO] Time to create scene: : 29.790888 seconds
[INFO] Time to randomize scene: : 0.161381 seconds
[INFO] to start Simulation: : 27.550733 seconds

After:

[INFO] Time to create scene: : 31.276912 seconds
[INFO] Time to randomize scene: : 0.004585 seconds
[INFO] Time to start Simulation: : 5.232237 seconds <--------------- much quicker

Type of change

  • New feature (non-breaking change which adds functionality)
  • Breaking change (existing functionality will not work without user modification)

Screenshots

Please attach before and after screenshots of the change if applicable.

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 updated the changelog and the corresponding version in the extension's config/extension.toml file
  • I have added my name to the CONTRIBUTORS.md or my name already exists there

@github-actions github-actions bot added enhancement New feature or request isaac-lab Related to Isaac Lab team labels Nov 5, 2025
Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

Greptile Overview

Greptile Summary

Replaces Isaac Sim GridCloner dependency with internal USD and PhysX replication APIs, enabling heterogeneous environment cloning with per-object replication for improved performance.

Key Changes:

  • New cloner.py module with usd_replicate, physx_replicate, filter_collisions, and grid_transforms functions
  • Heterogeneous cloning support via prototype-based replication with configurable assignment (random vs round-robin)
  • Scene-level random_heterogenous_cloning flag replaces spawner-level random_choice
  • Removed hardcoded regex validation allowing spawners to work with regex patterns in prim paths
  • Template path (/World/template) used for prototype staging before environment distribution
  • Significant performance improvement: simulation start time reduced from ~27.5s to ~5.2s (8192 envs)

Architecture:
Assets spawn as prototypes in /World/template, then cloner distributes them across environments based on mapping strategy. For homogeneous scenes (all prototypes → env_0), whole environment cloning is used. For heterogeneous scenes, per-object cloning optimizes PhysX parsing.

Confidence Score: 3/5

  • Safe to merge with one critical fix needed for clone_in_fabric support
  • The PR successfully refactors cloning logic and shows significant performance improvements. However, the clone_in_fabric configuration option from InteractiveSceneCfg is not passed to physx_replicate(), breaking fabric-based cloning functionality. This is a critical issue that will cause the config option to be silently ignored.
  • Pay close attention to source/isaaclab/isaaclab/scene/interactive_scene.py:214 where clone_in_fabric parameter must be added

Important Files Changed

File Analysis

Filename Score Overview
source/isaaclab/isaaclab/scene/cloner.py 4/5 New file with usd_replicate, physx_replicate, filter_collisions, and grid_transforms functions replacing Isaac Sim Cloner
source/isaaclab/isaaclab/scene/interactive_scene.py 3/5 Major refactor replacing GridCloner with internal replicators, adds heterogeneous cloning support, missing clone_in_fabric parameter forwarding
source/isaaclab/isaaclab/scene/interactive_scene_cfg.py 5/5 Added random_heterogenous_cloning config flag to control prototype assignment strategy

Sequence Diagram

sequenceDiagram
    participant User
    participant InteractiveScene
    participant Spawner
    participant USD as usd_replicate
    participant PhysX as physx_replicate
    
    User->>InteractiveScene: Initialize with InteractiveSceneCfg
    InteractiveScene->>InteractiveScene: Create template_path (/World/template)
    InteractiveScene->>InteractiveScene: Create env_0 empty Xform
    InteractiveScene->>USD: Clone env_0 to env_1..N with positions
    InteractiveScene->>InteractiveScene: _add_entities_from_cfg()
    
    loop For each asset in config
        InteractiveScene->>Spawner: Spawn prototypes in /World/template/{proto_name}_*
        Spawner-->>InteractiveScene: Prototypes created
    end
    
    InteractiveScene->>InteractiveScene: clone_environments()
    InteractiveScene->>InteractiveScene: Build clone_plan (src, dest, mapping)
    
    alt random_heterogenous_cloning == True
        InteractiveScene->>InteractiveScene: Randomly assign prototypes to envs
    else
        InteractiveScene->>InteractiveScene: Round-robin assignment (env % num_protos)
    end
    
    InteractiveScene->>USD: Replicate prototypes to environments
    
    alt All prototypes map to env_0
        InteractiveScene->>PhysX: Clone whole env_0 to all envs
    else
        InteractiveScene->>PhysX: Clone per-object from env_{proto_idx}
    end
    
    InteractiveScene->>USD: Final replication with positions
    InteractiveScene->>InteractiveScene: Deactivate template_path
    
    opt filter_collisions enabled
        InteractiveScene->>InteractiveScene: filter_collisions()
    end
Loading

1 file reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

Greptile Overview

Greptile Summary

This PR refactors IsaacLab's environment cloning system to use direct PhysX and USD APIs instead of Isaac Sim's GridCloner, significantly improving heterogeneous scene cloning performance.

Key Changes:

  • Introduces new cloner.py module with usd_replicate, physx_replicate, filter_collisions, and grid_transforms functions
  • Implements template/prototype-based cloning architecture where assets spawn as prototypes under /World/template, then clone to environments
  • Adds random_heterogenous_cloning scene-level flag to control prototype assignment (random vs round-robin)
  • Removes regex validation checks that previously prevented spawning with regex patterns in leaf prim paths
  • Deprecates random_choice in MultiAssetSpawnerCfg and MultiUsdFileCfg in favor of scene-level control
  • Simplifies multi-asset spawner logic by delegating cloning responsibility to scene manager

Performance Impact:
Simulation start time improved from 27.5s to 5.2s (5.3x faster) for 8192 heterogeneous environments.

Breaking Changes:

  • Spawner behavior changes from direct environment cloning to prototype-based cloning
  • Asset prim paths now use {ENV_REGEX_NS} placeholder instead of hardcoded /World/envs/env_.*

Confidence Score: 3/5

  • Safe to merge with one critical bug fix required
  • The refactor is well-structured with significant performance improvements, but has a critical bug where clone_in_fabric config is not passed to physx_replicate. The architectural changes are sound, tests have been updated, and the codebase is more maintainable. However, the missing parameter could affect users who configure fabric cloning.
  • source/isaaclab/isaaclab/scene/interactive_scene.py requires the use_fabric parameter fix at line 214

Important Files Changed

File Analysis

Filename Score Overview
source/isaaclab/isaaclab/scene/cloner.py 4/5 New cloning implementation with usd_replicate, physx_replicate, filter_collisions, and grid_transforms functions
source/isaaclab/isaaclab/scene/interactive_scene.py 3/5 Refactored to use new internal replicators, removed GridCloner dependency, added template/prototype-based cloning
source/isaaclab/isaaclab/sim/spawners/wrappers/wrappers.py 4/5 Simplified multi-asset spawning to only create prototypes, removed manual cloning logic
source/isaaclab/isaaclab/scene/interactive_scene_cfg.py 5/5 Added random_heterogenous_cloning flag to control prototype assignment at scene level

Sequence Diagram

sequenceDiagram
    participant User
    participant InteractiveScene
    participant Spawner
    participant cloner
    participant USD/PhysX

    User->>InteractiveScene: Initialize scene with config
    InteractiveScene->>InteractiveScene: Create /World/envs/env_0
    InteractiveScene->>InteractiveScene: Initialize /World/template
    
    loop For each asset in config
        InteractiveScene->>Spawner: spawn(prim_path="/World/template/.../proto_asset_.*")
        Spawner->>USD/PhysX: Create prototype prims under template
        USD/PhysX-->>Spawner: Prototypes created
        Spawner-->>InteractiveScene: Return first prototype prim
    end
    
    InteractiveScene->>cloner: usd_replicate(env_0 with positions)
    cloner->>USD/PhysX: Clone empty env prims with grid positions
    USD/PhysX-->>cloner: Env prims created
    
    InteractiveScene->>InteractiveScene: clone_environments()
    
    alt Homogeneous (all proto_idx == 0)
        InteractiveScene->>cloner: physx_replicate(env_0 -> all envs)
        cloner->>USD/PhysX: Replicate physics from single source
    else Heterogeneous
        InteractiveScene->>cloner: physx_replicate(per-object sources)
        cloner->>USD/PhysX: Replicate physics per prototype
    end
    
    InteractiveScene->>cloner: usd_replicate(prototypes -> envs)
    cloner->>USD/PhysX: Copy USD specs with transforms
    
    InteractiveScene->>InteractiveScene: Deactivate /World/template
    
    opt If filter_collisions enabled
        InteractiveScene->>cloner: filter_collisions()
        cloner->>USD/PhysX: Create inverted collision groups
    end
    
    InteractiveScene-->>User: Scene ready
Loading

15 files reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

Greptile Overview

Greptile Summary

This PR refactors environment cloning to use direct PhysX and USD APIs, removing the Isaac Sim Cloner dependency. The refactor introduces template-based prototype cloning with heterogeneous scene support.

Key Changes:

  • New cloner.py module with usd_replicate(), physx_replicate(), and clone_from_template() functions
  • Assets spawn to /World/template with prototypes, then get distributed across environments
  • Scene-level random_heterogenous_cloning flag controls random vs round-robin prototype assignment
  • Deprecates random_choice in MultiAssetSpawnerCfg and MultiUsdFileCfg
  • Simplified spawner wrappers by removing manual cloning logic
  • Performance improvement: simulation start time reduced from ~27.5s to ~5.2s (8192 envs)

Critical Issues Found:

  1. cloner_cfg never populated with values from self.cfg (interactive_scene.py:137) - random_heterogenous_cloning won't work
  2. Missing use_fabric parameter in physx_replicate() call (cloner.py:151)
  3. replicate_args undefined when clone_usd=False but clone_physx=True (cloner.py:150-151)

Confidence Score: 1/5

  • This PR has critical bugs that will cause runtime failures and break advertised functionality
  • Three critical logic errors found: (1) config values never transferred to cloner_cfg breaks the new random_heterogenous_cloning feature, (2) missing use_fabric parameter means clone_in_fabric config is ignored, (3) undefined replicate_args causes NameError in certain config combinations. These bugs will cause failures in production.
  • Pay close attention to source/isaaclab/isaaclab/scene/cloner.py and source/isaaclab/isaaclab/scene/interactive_scene.py - both contain critical bugs

Important Files Changed

File Analysis

Filename Score Overview
source/isaaclab/isaaclab/scene/cloner.py 1/5 New cloner module with critical bugs: missing use_fabric parameter, uninitialized replicate_args when clone_usd=False
source/isaaclab/isaaclab/scene/interactive_scene.py 1/5 Major refactor replacing Isaac Sim Cloner; critical bug: cloner_cfg never populated with config values like random_heterogenous_cloning
source/isaaclab/isaaclab/sim/spawners/wrappers/wrappers.py 4/5 Simplifies multi-asset spawning by removing manual cloning logic; spawns prototypes directly to template paths

Sequence Diagram

sequenceDiagram
    participant User as User Config
    participant IS as InteractiveScene
    participant Cloner as cloner.clone_from_template
    participant USD as usd_replicate
    participant PhysX as physx_replicate
    participant Spawner as MultiAssetSpawner

    User->>IS: Create scene with config
    IS->>IS: Initialize cloner_cfg (line 137)
    Note over IS: BUG: Config values not transferred!
    
    IS->>Spawner: Spawn assets to /World/template
    Spawner->>Spawner: Create prototypes (proto_asset_0, proto_asset_1, ...)
    
    IS->>Cloner: clone_from_template(stage, num_clones, cloner_cfg)
    
    Cloner->>Cloner: Discover prototypes under template_root
    Cloner->>Cloner: Build per-prototype mapping (random or round-robin)
    
    alt cfg.clone_usd = True
        Cloner->>USD: usd_replicate() - Copy USD specs
        USD->>USD: Copy prims depth-first with transforms
    end
    
    alt cfg.clone_physx = True
        Cloner->>PhysX: physx_replicate() - Register with PhysX
        Note over PhysX: BUG: use_fabric not passed!
        Note over PhysX: BUG: replicate_args undefined if clone_usd=False!
        PhysX->>PhysX: replicate() per source prim
    end
    
    Cloner->>Cloner: Deactivate template_root prim
    
    IS->>IS: Apply collision filtering if enabled
Loading

15 files reviewed, 3 comments

Edit Code Review Agent Settings | Greptile

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

Greptile Overview

Greptile Summary

Refactors environment cloning to use direct PhysX and USD APIs, removing Isaac Sim Cloner dependency. Introduces heterogeneous cloning support with per-object replication, improving PhysX cloning time for heterogeneous scenes (simulation start time reduced from ~27s to ~5s for 8192 envs).

Key Changes:

  • Adds new source/isaaclab/isaaclab/scene/cloner.py module with usd_replicate(), physx_replicate(), and clone_from_template() functions
  • Introduces TemplateCloneCfg configuration class with random_heterogenous_cloning flag for controlling prototype assignment
  • Adds comprehensive test suite in test_cloner.py covering USD/PhysX replication scenarios
  • Optimizes cloning by detecting homogeneous vs heterogeneous environments and using appropriate replication strategy

Critical Issues Found:

  • Missing clone_in_fabric field in TemplateCloneCfg (line 85) - will cause AttributeError when accessed
  • Undefined replicate_args variable when clone_usd=False but clone_physx=True (line 149-150) - will cause NameError
  • Missing use_fabric parameter in physx_replicate() call (line 150) - ignores user's fabric configuration from InteractiveSceneCfg.clone_in_fabric

These bugs are consistent with issues flagged in previous comments for interactive_scene.py calls.

Confidence Score: 1/5

  • This PR has critical runtime errors that will break functionality in production
  • Score of 1 reflects multiple critical bugs that will cause runtime crashes: (1) AttributeError when accessing missing cfg.clone_in_fabric field, (2) NameError when replicate_args is undefined in specific configuration combinations, (3) configuration being silently ignored. These are not edge cases - they affect core cloning functionality documented in previous review comments for other files
  • Pay critical attention to source/isaaclab/isaaclab/scene/cloner.py - contains multiple blocking bugs that must be fixed before merge

Important Files Changed

File Analysis

Filename Score Overview
source/isaaclab/isaaclab/scene/cloner.py 1/5 New cloner module with critical bugs: (1) missing clone_in_fabric config field causes AttributeError, (2) undefined replicate_args when clone_usd=False and clone_physx=True causes NameError, (3) missing use_fabric parameter in physx_replicate call ignores user configuration
source/isaaclab/test/sim/test_cloner.py 5/5 New comprehensive test suite for cloner utilities covering USD replication with masks/positions, depth-ordering, PhysX replication, and template-based cloning with heterogeneous assets

Sequence Diagram

sequenceDiagram
    participant User
    participant InteractiveScene
    participant clone_from_template
    participant usd_replicate
    participant physx_replicate
    participant PhysXReplicator

    User->>InteractiveScene: clone_environments()
    
    alt Scene setup from config (heterogeneous)
        InteractiveScene->>clone_from_template: clone_from_template(stage, num_clones, cfg)
        clone_from_template->>clone_from_template: Discover prototypes under template_root
        clone_from_template->>clone_from_template: Build prototype mapping (random or round-robin)
        clone_from_template->>usd_replicate: Initial prototype stamping
        clone_from_template->>clone_from_template: Deactivate template_root
        
        alt clone_usd enabled
            alt All prototypes map to env_0 (homogeneous)
                clone_from_template->>usd_replicate: Clone whole env_0 to all envs
            else Heterogeneous environments
                clone_from_template->>usd_replicate: Clone per-object to destinations
            end
        end
        
        alt clone_physx enabled
            Note over clone_from_template: BUG: replicate_args undefined if clone_usd=False
            clone_from_template->>physx_replicate: physx_replicate(replicate_args)
            Note over clone_from_template: BUG: Missing use_fabric parameter
        end
        
    else Manual scene setup (homogeneous)
        InteractiveScene->>InteractiveScene: Create mapping for env_0 -> all envs
        
        alt copy_from_source = False
            InteractiveScene->>physx_replicate: physx_replicate(replicate_args)
            Note over InteractiveScene: BUG: Missing use_fabric parameter
        end
        
        InteractiveScene->>usd_replicate: usd_replicate with positions
    end
    
    usd_replicate->>usd_replicate: Sort by path depth (parents first)
    usd_replicate->>usd_replicate: Copy USD specs per environment
    usd_replicate->>usd_replicate: Author xformOp:translate/orient if provided
    
    physx_replicate->>PhysXReplicator: register_replicator(stage_id, callbacks)
    PhysXReplicator->>PhysXReplicator: For each source, replicate to mapped envs
    PhysXReplicator->>PhysXReplicator: unregister_replicator()
Loading

2 files reviewed, 3 comments

Edit Code Review Agent Settings | Greptile

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

Greptile Overview

Greptile Summary

Refactors environment cloning to use direct USD/PhysX APIs, removing Isaac Sim Cloner dependency. Adds heterogeneous cloning support with per-object replication and scene-level random_heterogenous_cloning flag.

Key Changes:

  • New cloner.py module with clone_from_template(), usd_replicate(), physx_replicate() functions
  • Replaces GridCloner with internal replication logic in InteractiveScene
  • Improved PhysX cloning performance (27.5s → 5.2s simulation start time for 8192 envs)
  • Adds clone_in_fabric config option for PhysX fabric support

Critical Issue:

  • cloner.py:152 references replicate_args which is only defined inside if cfg.clone_usd: block (lines 136-149), causing NameError when clone_usd=False but clone_physx=True

Confidence Score: 1/5

  • Critical bug will cause runtime crash with certain config combinations
  • The replicate_args undefined variable bug in cloner.py:152 is a critical logical error that will cause immediate NameError when clone_usd=False and clone_physx=True. This configuration is valid according to the config class and would be expected to work, but will crash at runtime. Tests don't cover this edge case.
  • source/isaaclab/isaaclab/scene/cloner.py requires immediate fix for undefined variable bug

Important Files Changed

File Analysis

Filename Score Overview
source/isaaclab/isaaclab/scene/cloner.py 1/5 New cloner module with critical bug: replicate_args undefined when clone_usd=False but clone_physx=True (line 152)
source/isaaclab/test/sim/test_cloner.py 4/5 Comprehensive test suite for new cloner utilities, covers USD/PhysX replication with good edge cases

Sequence Diagram

sequenceDiagram
    participant IS as InteractiveScene
    participant CT as clone_from_template
    participant UR as usd_replicate
    participant PR as physx_replicate
    participant Stage as USD Stage
    
    IS->>IS: Initialize scene with TemplateCloneCfg
    IS->>IS: Create env_0 prim
    IS->>UR: Clone env_0 to env_1..N (with positions)
    
    IS->>IS: _add_entities_from_cfg()
    Note over IS: Spawns prototypes in /World/template
    
    IS->>CT: clone_from_template()
    Note over CT: Discovers prototypes under template_root
    
    CT->>CT: Build clone_plan with mapping
    Note over CT: Random or round-robin assignment
    
    CT->>UR: usd_replicate(prototypes to envs)
    UR->>Stage: Copy USD specs depth-first
    Note over UR: Parents before children
    
    alt cfg.clone_usd == True
        CT->>CT: Build replicate_args
        alt All protos map to env_0
            CT->>UR: Replicate whole env_0
        else Heterogeneous
            CT->>UR: Replicate per-object
        end
    end
    
    alt cfg.clone_physx == True
        CT->>PR: physx_replicate(replicate_args)
        Note right of CT: BUG: replicate_args undefined<br/>if clone_usd=False
        PR->>Stage: Register PhysX replication
    end
    
    IS->>IS: filter_collisions()
    Note over IS: Create collision groups per env
Loading

2 files reviewed, 2 comments

Edit Code Review Agent Settings | Greptile

@ooctipus
Copy link
Collaborator Author

ooctipus commented Nov 5, 2025

This PR requires discussion with team

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

Greptile Overview

Greptile Summary

This PR successfully refactors the cloner to use direct PhysX and USD APIs, removing the Isaac Sim Cloner dependency and delivering significant performance improvements (27.5s → 5.2s simulation start time).

Key Changes:

  • New cloner.py module with usd_replicate(), physx_replicate(), and clone_from_template() functions
  • InteractiveScene refactored to use new cloner APIs
  • Adds heterogeneous cloning support with random_heterogenous_cloning config flag
  • Comprehensive test suite in test_cloner.py

Critical Issues Found:

  • cloner.py:152: replicate_args undefined when clone_usd=False and clone_physx=True - causes NameError at runtime
  • interactive_scene.py:137: cloner_cfg instantiated with defaults but never populated with scene-specific values (num_clones, random_heterogenous_cloning, clone_in_fabric, etc.)

Both issues will cause runtime failures in specific configurations.

Confidence Score: 1/5

  • This PR has critical bugs that will cause runtime failures in multiple configurations
  • Two critical logic errors identified: (1) replicate_args undefined when clone_usd=False and clone_physx=True causing NameError, and (2) cloner_cfg never populated with scene config values, causing cloner to use incorrect default values. Both issues will break functionality and need to be fixed before merge.
  • Pay close attention to source/isaaclab/isaaclab/scene/cloner.py (lines 151-152) and source/isaaclab/isaaclab/scene/interactive_scene.py (lines 137-138)

Important Files Changed

File Analysis

Filename Score Overview
source/isaaclab/isaaclab/scene/cloner.py 1/5 New cloner module with critical bug: replicate_args undefined when clone_usd=False and clone_physx=True causing NameError
source/isaaclab/isaaclab/scene/interactive_scene.py 2/5 Refactored to use new cloner module; cloner_cfg instantiated with defaults but never populated with scene-specific config values
source/isaaclab/test/sim/test_cloner.py 3/5 New test file with good coverage, but missing test case for clone_usd=False with clone_physx=True configuration

Sequence Diagram

sequenceDiagram
    participant User
    participant InteractiveScene
    participant TemplateCloneCfg
    participant clone_from_template
    participant usd_replicate
    participant physx_replicate
    participant Stage

    User->>InteractiveScene: __init__(cfg)
    InteractiveScene->>TemplateCloneCfg: create default config
    Note over InteractiveScene,TemplateCloneCfg: BUG: config values not populated
    InteractiveScene->>Stage: DefinePrim(env_0)
    InteractiveScene->>usd_replicate: replicate env_0 to env_1..N
    
    alt Scene setup from config
        InteractiveScene->>InteractiveScene: _add_entities_from_cfg()
        Note over InteractiveScene: Creates template prototypes
        InteractiveScene->>InteractiveScene: clone_environments()
        InteractiveScene->>clone_from_template: clone templates
        
        clone_from_template->>Stage: discover prototypes
        clone_from_template->>clone_from_template: build clone_plan mapping
        clone_from_template->>usd_replicate: replicate prototypes
        
        alt cfg.clone_usd = True
            clone_from_template->>usd_replicate: replicate environments
            Note over clone_from_template: Sets replicate_args
        end
        
        alt cfg.clone_physx = True
            clone_from_template->>physx_replicate: replicate with PhysX
            Note over clone_from_template: BUG: replicate_args may be undefined
        end
    else Scene setup manually
        InteractiveScene->>usd_replicate: replicate env_0
        InteractiveScene->>physx_replicate: replicate physics
    end
    
    alt cfg.filter_collisions
        InteractiveScene->>InteractiveScene: filter_collisions()
    end
Loading

3 files reviewed, 2 comments

Edit Code Review Agent Settings | Greptile

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

Greptile Overview

Greptile Summary

Refactors environment cloning from Isaac Sim's GridCloner to custom usd_replicate and physx_replicate functions, adds heterogeneous cloning support with per-object replication.

Key Changes:

  • New cloner.py module with clone_from_template(), usd_replicate(), physx_replicate() for direct USD/PhysX API usage
  • InteractiveScene updated to use new cloner with template-based prototype spawning under /World/template
  • Added scene-level random_heterogenous_cloning flag for controlling prototype distribution
  • Simplified spawn_multi_asset to spawn prototypes directly without manual cloning logic
  • Deprecated random_choice in MultiAssetSpawnerCfg and MultiUsdFileCfg

Critical Issues Found:

  • interactive_scene.py:137 - cloner_cfg created with defaults but never populated with actual scene configuration values (num_clones, clone_regex, random_heterogenous_cloning, clone_in_fabric, device)
  • interactive_scene.py:149-154 - Dead code attempting to use unpopulated clone_plan dict, will cause ValueError if _global_template_prim_paths contains items

Confidence Score: 1/5

  • Critical configuration bug will cause cloner to use wrong settings, potentially breaking heterogeneous scene cloning
  • The cloner_cfg bug at line 137 is critical - configuration values from InteractiveSceneCfg are never passed to the cloner, meaning features like random_heterogenous_cloning and clone_in_fabric won't work as intended. The dead code at lines 149-154 will crash if collision filtering with template paths is attempted. While the core cloner implementation is clean, the integration layer has fundamental bugs.
  • Pay immediate attention to source/isaaclab/isaaclab/scene/interactive_scene.py - lines 137 and 149-154 must be fixed before merge

Important Files Changed

File Analysis

Filename Score Overview
source/isaaclab/isaaclab/scene/cloner.py 4/5 New file introducing usd_replicate, physx_replicate, and clone_from_template functions - clean implementation with proper depth-ordered USD replication
source/isaaclab/isaaclab/scene/interactive_scene.py 1/5 Critical bugs: cloner_cfg never populated with scene config (line 137), clone_plan dead code causes runtime error (lines 149-154)
source/isaaclab/isaaclab/sim/spawners/wrappers/wrappers.py 4/5 Simplified spawn_multi_asset by removing manual cloning logic, now spawns prototypes directly at template paths
source/isaaclab/test/sim/test_cloner.py 4/5 New tests cover usd_replicate, physx_replicate, and clone_from_template - good coverage but missing edge cases

Sequence Diagram

sequenceDiagram
    participant User
    participant InteractiveScene
    participant Spawner as spawn_multi_asset
    participant Cloner as clone_from_template
    participant USD as usd_replicate
    participant PhysX as physx_replicate

    User->>InteractiveScene: __init__(cfg)
    InteractiveScene->>InteractiveScene: Create cloner_cfg (TemplateCloneCfg)
    Note over InteractiveScene: BUG: cloner_cfg not populated with cfg values
    InteractiveScene->>USD: usd_replicate() env_0 xforms
    InteractiveScene->>InteractiveScene: _add_entities_from_cfg()
    
    loop For each asset in cfg
        InteractiveScene->>Spawner: spawn_multi_asset(prim_path, cfg)
        Note over Spawner: prim_path = "/World/template/.../proto_asset_.*"
        loop For each asset variant
            Spawner->>Spawner: Spawn prototype at template path
        end
        Spawner-->>InteractiveScene: Return first proto prim
    end
    
    InteractiveScene->>InteractiveScene: clone_environments()
    InteractiveScene->>Cloner: clone_from_template(stage, num_clones, cloner_cfg)
    
    Cloner->>Cloner: Discover prototypes under template_root
    Cloner->>Cloner: Build per-prototype mapping (random or modulo)
    Cloner->>USD: usd_replicate(sources, destinations, env_ids, mask)
    
    USD->>USD: Sort by path depth (parents before children)
    loop For each depth level
        USD->>USD: Copy prim specs with Sdf.CopySpec
        USD->>USD: Author xformOp:translate/orient if provided
    end
    
    Cloner->>Cloner: Deactivate template_root
    
    alt All prototypes map to env_0
        Cloner->>USD: usd_replicate() whole env_0 with positions
        Cloner->>PhysX: physx_replicate() whole env mapping
    else Heterogeneous mapping
        Cloner->>USD: usd_replicate() per-object
        Cloner->>PhysX: physx_replicate() per-object mapping
    end
    
    PhysX->>PhysX: Register replicator callbacks
    PhysX->>PhysX: Call replicate() per source
    PhysX->>PhysX: Unregister replicator
    
    Cloner-->>InteractiveScene: Cloning complete
    
    alt filter_collisions enabled
        InteractiveScene->>Cloner: filter_collisions(stage, paths)
    end
    
    InteractiveScene-->>User: Scene ready
Loading

14 files reviewed, 2 comments

Edit Code Review Agent Settings | Greptile

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

Greptile Overview

Greptile Summary

Refactors environment cloning to use direct USD/PhysX APIs instead of Isaac Sim's GridCloner, introducing heterogeneous cloning with per-object replication and a scene-level random_heterogenous_cloning flag.

Major changes:

  • New cloner.py module with usd_replicate(), physx_replicate(), and clone_from_template() functions
  • InteractiveScene refactored to use new cloner APIs and prepare templates under /World/template
  • Deprecates random_choice in MultiAssetSpawnerCfg/MultiUsdFileCfg in favor of scene-level control
  • Significant performance improvement: simulation start time reduced from 27.5s to 5.2s (8192 envs)

Critical issues found:

  • cloner_cfg at interactive_scene.py:139 never populated with scene config values (num_clones, clone_regex, random_heterogenous_cloning, clone_in_fabric, device)
  • clone_plan dict at interactive_scene.py:151 created but never populated before use at lines 154-156, causing ValueError when _global_template_prim_paths is non-empty

Confidence Score: 1/5

  • This PR has critical bugs that will cause runtime failures in common scenarios
  • Two critical logic bugs in interactive_scene.py: (1) cloner_cfg never populated with required config values, (2) clone_plan dict accessed before being populated. These will cause failures when using heterogeneous cloning or global collision filters.
  • source/isaaclab/isaaclab/scene/interactive_scene.py requires immediate fixes to cloner_cfg initialization and clone_plan usage

Important Files Changed

File Analysis

Filename Score Overview
source/isaaclab/isaaclab/scene/cloner.py 4/5 New cloner module with USD/PhysX replication; implementation looks solid with proper depth ordering and mapping logic
source/isaaclab/isaaclab/scene/interactive_scene.py 1/5 Critical bugs: cloner_cfg never populated with scene config; clone_plan dict created but never populated before use causing ValueError
source/isaaclab/test/sim/test_cloner.py 4/5 Good test coverage for USD/PhysX replication and template cloning

Sequence Diagram

sequenceDiagram
    participant User
    participant InteractiveScene
    participant Cloner
    participant USDStage
    participant PhysXReplicator

    User->>InteractiveScene: __init__(cfg)
    InteractiveScene->>InteractiveScene: Create cloner_cfg (BUG: not populated!)
    InteractiveScene->>InteractiveScene: _add_entities_from_cfg()
    InteractiveScene->>USDStage: Spawn prototypes to /World/template
    InteractiveScene->>InteractiveScene: clone_plan created (BUG: never populated!)
    InteractiveScene->>InteractiveScene: clone_environments()
    InteractiveScene->>Cloner: clone_from_template(stage, num_clones, cloner_cfg)
    
    Cloner->>USDStage: Discover prototypes under template_root
    Cloner->>Cloner: Build prototype mapping (random or modulo)
    Cloner->>Cloner: usd_replicate(sources, destinations, mapping)
    Cloner->>USDStage: Copy USD specs in depth order
    Cloner->>USDStage: Author xformOp:translate/orient
    
    alt cfg.clone_physx
        Cloner->>PhysXReplicator: physx_replicate(sources, destinations, mapping)
        PhysXReplicator->>PhysXReplicator: Register replicator callbacks
        PhysXReplicator->>USDStage: Replicate PhysX schemas
        PhysXReplicator->>PhysXReplicator: Unregister replicator
    end
    
    Cloner-->>InteractiveScene: Cloning complete
    InteractiveScene->>Cloner: filter_collisions(stage, env_prim_paths)
    Cloner->>USDStage: Create PhysicsCollisionGroups per env
Loading

14 files reviewed, 2 comments

Edit Code Review Agent Settings | Greptile

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

Greptile Overview

Greptile Summary

Refactors environment cloning to work directly with PhysX and USD APIs, removing the Isaac Sim GridCloner dependency. Introduces heterogeneous cloning with per-object replication and scene-level control via random_heterogenous_cloning flag.

Key Changes:

  • Replaces GridCloner with new cloner.py module implementing usd_replicate(), physx_replicate(), and clone_from_template()
  • Adds template-based cloning with prototype discovery and flexible env-to-prototype mapping
  • Spawners now create prototypes directly instead of copying templates
  • Removes random_choice from spawner configs in favor of scene-level random_heterogenous_cloning

Critical Issue:
The cloner_cfg object is initialized with default values but never populated with scene configuration (clone_regex, random_heterogenous_cloning, clone_in_fabric, device). This causes the cloner to use incorrect values, potentially breaking heterogeneous cloning, fabric cloning, and device allocation.

Confidence Score: 2/5

  • Critical configuration bug will cause incorrect cloning behavior in production
  • Major refactor with a critical bug where cloner_cfg is never populated with scene configuration values. This will cause heterogeneous cloning to use wrong randomization, fabric cloning to be ignored, and device allocation to default to CPU. Previous comments identified this issue but it remains unfixed.
  • source/isaaclab/isaaclab/scene/interactive_scene.py requires immediate fix for cloner_cfg initialization at line 139

Important Files Changed

File Analysis

Filename Score Overview
source/isaaclab/isaaclab/scene/interactive_scene.py 2/5 Refactors cloning from GridCloner to direct PhysX/USD APIs. Critical bug: cloner_cfg initialized with defaults but never populated with scene config (clone_regex, random_heterogenous_cloning, clone_in_fabric, device), causing incorrect cloning behavior.

Sequence Diagram

sequenceDiagram
    participant User
    participant InteractiveScene
    participant Cloner
    participant USD
    participant PhysX

    User->>InteractiveScene: __init__(cfg)
    InteractiveScene->>InteractiveScene: Create cloner_cfg (with defaults)
    Note over InteractiveScene: BUG: Config values not populated
    InteractiveScene->>InteractiveScene: _add_entities_from_cfg()
    InteractiveScene->>InteractiveScene: Replace prim_path regex with template path
    Note over InteractiveScene: Uses cloner_cfg.template_root
    InteractiveScene->>InteractiveScene: Spawn assets as prototypes
    InteractiveScene->>InteractiveScene: clone_environments()
    
    alt cfg.replicate_physics == True
        InteractiveScene->>USD: Set envIdInBoundsBitCount
    end
    
    alt _is_scene_setup_from_cfg()
        InteractiveScene->>Cloner: clone_from_template(stage, num_clones, cloner_cfg)
        Cloner->>Cloner: Discover prototypes under template_root
        Cloner->>Cloner: Build per-prototype mapping
        Note over Cloner: BUG: Uses wrong device/clone_regex/etc
        
        alt random_heterogenous_cloning
            Cloner->>Cloner: Random prototype assignment
        else
            Cloner->>Cloner: Round-robin assignment (modulo)
        end
        
        Cloner->>USD: usd_replicate(prototypes)
        USD-->>Cloner: Prototypes replicated
        
        alt clone_physx == True
            Cloner->>PhysX: physx_replicate(mapping)
            Note over PhysX: BUG: Missing use_fabric parameter
            PhysX-->>Cloner: Physics replicated
        end
        
        Cloner-->>InteractiveScene: Cloning complete
    else
        InteractiveScene->>USD: usd_replicate(env_0)
        InteractiveScene->>PhysX: physx_replicate(env_0)
    end
    
    alt filter_collisions == True
        InteractiveScene->>Cloner: filter_collisions(global_prim_paths)
        Cloner->>USD: Create collision groups
        Cloner-->>InteractiveScene: Collisions filtered
    end
    
    InteractiveScene-->>User: Scene ready
Loading

1 file reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

Greptile Overview

Greptile Summary

Refactors environment cloning to use new internal usd_replicate and physx_replicate functions instead of Isaac Sim's GridCloner, removing hard dependency on Isaac Sim Cloner API.

Key Changes:

  • Replaces GridCloner with custom template-based cloning via new cloner module
  • Adds heterogeneous environment support with per-object replication when replicate_physics=False
  • Introduces random_heterogenous_cloning config flag for prototype assignment control
  • Significantly improves simulation startup time (27.5s → 5.2s in multi_asset demo with 8192 envs)
  • Assets now spawn to /World/template with proto_asset_* naming, then replicate to environments

Latest commit (1f2eece) addressed:

  • cloner_cfg now properly initialized with clone_regex, random_heterogenous_cloning, clone_in_fabric, and device parameters

Remaining concerns from prior reviews:

  • Issues in cloner.py (not in scope of this file review): missing replicate_args definition when clone_usd=False and clone_physx=True, missing use_fabric parameter in physx_replicate calls

Confidence Score: 3/5

  • Proceed with caution - the refactored interactive_scene.py appears correct, but critical bugs exist in the companion cloner.py module that will cause runtime failures
  • Score of 3 reflects that interactive_scene.py itself has been properly updated with correct configuration initialization (thanks to commit 1f2eece), but the PR introduces a new cloner.py dependency with critical bugs flagged in previous comments. While this specific file review shows no new issues in interactive_scene.py, the overall PR safety is compromised by issues in the cloner module.
  • Pay close attention to source/isaaclab/isaaclab/scene/cloner.py (not in this review scope) - it contains critical bugs that will cause NameError when clone_usd=False and clone_physx=True, and missing use_fabric parameters in physx_replicate calls

Important Files Changed

File Analysis

Filename Score Overview
source/isaaclab/isaaclab/scene/interactive_scene.py 3/5 Major refactor replacing Isaac Sim Cloner with custom USD/PhysX replication. Previous comments identified critical issues with cloner_cfg missing num_clones parameter (defaults to 1) and missing handling in cloner.py for clone_usd=False case.

Sequence Diagram

sequenceDiagram
    participant User
    participant InteractiveScene
    participant TemplateCloneCfg
    participant CloneFromTemplate
    participant UsdReplicate
    participant PhysxReplicate
    participant FilterCollisions

    User->>InteractiveScene: __init__(cfg)
    InteractiveScene->>InteractiveScene: Create env_prim_paths list
    InteractiveScene->>InteractiveScene: DefinePrim(env_0)
    InteractiveScene->>TemplateCloneCfg: Create cloner_cfg
    Note over TemplateCloneCfg: clone_regex, random_heterogenous_cloning,<br/>clone_in_fabric, device
    InteractiveScene->>InteractiveScene: grid_transforms() → env_origins
    InteractiveScene->>UsdReplicate: Replicate env_0 to env_1..N with positions
    
    alt Scene setup from config
        InteractiveScene->>InteractiveScene: _add_entities_from_cfg()
        Note over InteractiveScene: Assets spawn to /World/template<br/>with proto_asset_* naming
        InteractiveScene->>InteractiveScene: Convert template paths to env paths
        InteractiveScene->>InteractiveScene: clone_environments()
        
        alt replicate_physics=True
            InteractiveScene->>InteractiveScene: Set physxScene:envIdInBoundsBitCount=4
        end
        
        InteractiveScene->>CloneFromTemplate: clone_from_template(stage, num_clones, cloner_cfg)
        CloneFromTemplate->>CloneFromTemplate: Discover prototypes under template_root
        CloneFromTemplate->>CloneFromTemplate: Build proto→env mapping (random or round-robin)
        CloneFromTemplate->>UsdReplicate: Replicate prototypes to destinations
        CloneFromTemplate->>CloneFromTemplate: Deactivate template_root
        
        alt All envs use proto_0 (homogeneous)
            CloneFromTemplate->>UsdReplicate: Clone env_0 to all envs with positions
        else Heterogeneous prototypes
            CloneFromTemplate->>UsdReplicate: Clone per-prototype instances
        end
        
        alt clone_physx=True
            CloneFromTemplate->>PhysxReplicate: Replicate physics with mapping
        end
        
        alt filter_collisions=True
            InteractiveScene->>FilterCollisions: filter_collisions(global_prim_paths)
            FilterCollisions->>FilterCollisions: Create PhysicsCollisionGroups per env
            FilterCollisions->>FilterCollisions: Set inverted filtering
        end
    else Manual scene setup
        InteractiveScene->>InteractiveScene: clone_environments()
        InteractiveScene->>InteractiveScene: Create mapping (all envs → env_0)
        
        alt copy_from_source=False
            InteractiveScene->>PhysxReplicate: Replicate physics
        end
        
        InteractiveScene->>UsdReplicate: Replicate USD with positions
    end
Loading

1 file reviewed, no comments

Edit Code Review Agent Settings | Greptile

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

Greptile Overview

Greptile Summary

Refactors environment cloning from Isaac Sim's GridCloner to custom USD/PhysX replication APIs, improving heterogeneous scene cloning performance (5.2s vs 27.5s simulation start in 8192 env benchmark).

Key Changes:

  • New cloner.py module with usd_replicate(), physx_replicate(), and clone_from_template() functions
  • InteractiveScene now uses TemplateCloneCfg for prototype-based cloning with random or deterministic assignment
  • Adds random_heterogenous_cloning flag to InteractiveSceneCfg for controlling prototype distribution
  • Test files updated to use new cloner API

Critical Issues:

  • cloner.py:154: replicate_args undefined when clone_usd=False and clone_physx=True, causing NameError
  • interactive_scene.py:189: Missing use_fabric parameter in physx_replicate() call
  • cloner.py:88-89: clone_in_fabric field properly added to config (previous comments resolved)

Architecture:
The refactor moves from a monolithic cloner to composable USD/PhysX replication, enabling per-object cloning for heterogeneous environments while preserving whole-environment replication for homogeneous cases.

Confidence Score: 2/5

  • This PR has critical bugs that will cause runtime errors in certain configurations
  • The PR contains a critical NameError in cloner.py:154 where replicate_args is undefined when clone_usd=False and clone_physx=True. This will crash at runtime for any code path using that configuration. Additionally, the missing use_fabric parameter in interactive_scene.py:189 means the configuration flag won't be respected. While the refactor architecture is sound and performance improvements are significant, these blocking bugs must be fixed before merge.
  • Pay close attention to source/isaaclab/isaaclab/scene/cloner.py (lines 137-154) and source/isaaclab/isaaclab/scene/interactive_scene.py (line 189)

Important Files Changed

File Analysis

Filename Score Overview
source/isaaclab/isaaclab/scene/cloner.py 2/5 New cloner module with critical bug: replicate_args undefined when clone_usd=False and clone_physx=True, causing NameError at line 154. Missing use_fabric parameter in physx_replicate calls.
source/isaaclab/isaaclab/scene/interactive_scene.py 3/5 Refactored to use new cloner module instead of Isaac Sim GridCloner. The cloner_cfg is properly initialized with scene config values. The use_fabric parameter is missing in direct physx_replicate call at line 189.

Sequence Diagram

sequenceDiagram
    participant InteractiveScene
    participant clone_from_template
    participant usd_replicate
    participant physx_replicate
    participant USD Stage
    participant PhysX Replicator

    InteractiveScene->>InteractiveScene: __init__
    InteractiveScene->>InteractiveScene: Create cloner_cfg (TemplateCloneCfg)
    InteractiveScene->>usd_replicate: Replicate empty env_0 to all envs
    usd_replicate->>USD Stage: Copy env_0 prim to env_1...env_N
    
    InteractiveScene->>InteractiveScene: _add_entities_from_cfg()
    Note over InteractiveScene: Spawn prototypes in /World/template
    
    InteractiveScene->>InteractiveScene: clone_environments()
    InteractiveScene->>clone_from_template: Clone prototypes to envs
    
    clone_from_template->>clone_from_template: Discover prototypes
    clone_from_template->>clone_from_template: Build prototype mapping
    Note over clone_from_template: Random or round-robin assignment
    
    clone_from_template->>usd_replicate: Replicate prototypes
    usd_replicate->>USD Stage: Copy prototype specs to destinations
    
    alt All prototypes map to env_0
        clone_from_template->>usd_replicate: Clone whole env_0
        usd_replicate->>USD Stage: Copy entire env_0 to all envs
    else Heterogeneous mapping
        clone_from_template->>usd_replicate: Clone per-object
        usd_replicate->>USD Stage: Copy individual objects per env
    end
    
    alt cfg.clone_physx is True
        clone_from_template->>physx_replicate: Replicate for PhysX
        physx_replicate->>PhysX Replicator: Register replicator
        physx_replicate->>PhysX Replicator: Call replicate() per source
        physx_replicate->>PhysX Replicator: Unregister replicator
    end
    
    InteractiveScene->>InteractiveScene: filter_collisions()
    InteractiveScene->>USD Stage: Create collision groups
Loading

5 files reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

Greptile Overview

Greptile Summary

This PR replaces the Isaac Sim GridCloner dependency with custom usd_replicate and physx_replicate functions in a new cloner.py module. The refactor enables heterogeneous environment cloning where different prototypes can be distributed across environments either randomly or deterministically.

Key Changes:

  • New cloner.py module with TemplateCloneCfg, clone_from_template(), usd_replicate(), physx_replicate(), and helper functions
  • InteractiveScene refactored to use new cloner instead of GridCloner from Isaac Sim
  • Template-based cloning: assets spawn to /World/template/proto_asset_* then replicate to environments
  • Scene-level random_heterogenous_cloning flag controls prototype distribution (random vs round-robin)
  • Spawner wrappers simplified to create prototypes without manual cloning logic
  • Test updates for new path templating format

Critical Issues Found:

  • In cloner.py:153-154, replicate_args is only defined inside conditional blocks guarded by cfg.clone_usd, but line 154 uses it unconditionally when cfg.clone_physx=True, causing NameError when clone_usd=False and clone_physx=True
  • In interactive_scene.py:189, physx_replicate() call missing required use_fabric parameter

Confidence Score: 2/5

  • This PR has critical runtime errors that will cause crashes in specific configurations
  • Two critical logic bugs identified: (1) undefined variable replicate_args when clone_usd=False and clone_physx=True in cloner.py causing NameError, and (2) missing required use_fabric parameter in interactive_scene.py causing incorrect PhysX behavior. Both issues will cause runtime failures in production.
  • Pay close attention to source/isaaclab/isaaclab/scene/cloner.py (critical undefined variable bug) and source/isaaclab/isaaclab/scene/interactive_scene.py (missing parameter)

Important Files Changed

File Analysis

Filename Score Overview
source/isaaclab/isaaclab/scene/cloner.py 2/5 new cloner module with USD and PhysX replication functions - critical bug where replicate_args undefined when clone_usd=False and clone_physx=True
source/isaaclab/isaaclab/scene/interactive_scene.py 3/5 refactored to use new cloner module instead of Isaac Sim GridCloner - missing use_fabric parameter in physx_replicate call
source/isaaclab/test/sensors/test_contact_sensor.py 5/5 test updated to use new {ENV_REGEX_NS} template format instead of hardcoded paths - straightforward migration

Sequence Diagram

sequenceDiagram
    participant User
    participant InteractiveScene
    participant Cloner
    participant USD
    participant PhysX

    User->>InteractiveScene: Initialize scene with cfg
    InteractiveScene->>InteractiveScene: Create env_prim_paths list
    InteractiveScene->>Cloner: grid_transforms() for env positions
    InteractiveScene->>Cloner: usd_replicate() empty env prims
    InteractiveScene->>InteractiveScene: _add_entities_from_cfg()
    Note over InteractiveScene: Assets spawn to template root<br/>with proto_asset_* naming
    InteractiveScene->>InteractiveScene: clone_environments()
    alt replicate_physics=True
        InteractiveScene->>USD: Set physxScene:envIdInBoundsBitCount
    end
    alt scene setup from cfg
        InteractiveScene->>Cloner: clone_from_template()
        Cloner->>Cloner: Discover prototypes in template_root
        Cloner->>Cloner: Build clone_plan with random/round-robin mapping
        alt clone_usd=True
            Cloner->>USD: usd_replicate() templates to envs
        end
        alt clone_physx=True
            Cloner->>PhysX: physx_replicate() with use_fabric flag
        end
    else manual scene setup
        InteractiveScene->>Cloner: physx_replicate() directly (missing use_fabric!)
        InteractiveScene->>Cloner: usd_replicate() with positions
    end
    alt filter_collisions=True
        InteractiveScene->>Cloner: filter_collisions()
        Cloner->>USD: Create collision groups per env
    end
Loading

2 files reviewed, 2 comments

Edit Code Review Agent Settings | Greptile

Comment on lines 153 to 154
if cfg.clone_physx:
physx_replicate(stage, *replicate_args, use_fabric=cfg.clone_in_fabric)
Copy link
Contributor

Choose a reason for hiding this comment

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

logic: replicate_args only defined when cfg.clone_usd=True (inside blocks at lines 140-146 and 150-151) - causes NameError if clone_usd=False but clone_physx=True

Suggested change
if cfg.clone_physx:
physx_replicate(stage, *replicate_args, use_fabric=cfg.clone_in_fabric)
if cfg.clone_physx:
if not cfg.clone_usd:
# replicate_args not defined above when clone_usd=False, so build it here
if torch.all(proto_idx == 0):
replicate_args = [clone_path_fmt.format(0)], [clone_path_fmt], world_indices, clone_plan["mapping"]
else:
src = [tpl.format(int(idx)) for tpl, idx in zip(clone_plan["dest"], proto_idx.tolist())]
replicate_args = src, clone_plan["dest"], world_indices, clone_plan["mapping"]
physx_replicate(stage, *replicate_args, use_fabric=cfg.clone_in_fabric)

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

Greptile Overview

Greptile Summary

This PR adds cloning infrastructure updates to test files by integrating the new cloner.usd_replicate() API. The changes in the test files are minimal and focused:

Test File Changes:

  • Adds from isaaclab.scene import cloner import
  • Inserts cloner.usd_replicate() calls in scene generation functions to replicate the /World/Table_0 prim across environments
  • Both test files follow identical patterns for integrating the new cloning API

Key Points:

  • The test changes themselves are straightforward additions that integrate the new cloning system
  • The changes are consistent with the PR's goal of refactoring cloner logic into usd_replicate and physx_replicate
  • Previous comments have identified critical bugs in the core cloner module (not in these test files) including:
    • Missing use_fabric parameter in physx_replicate calls
    • Undefined replicate_args when clone_usd=False but clone_physx=True
    • Missing population of cloner_cfg with scene config values
    • Missing clone_in_fabric field in TemplateCloneCfg

Test File Specific Observations:
The test files add the cloning calls after object creation, which ensures the Table prims are replicated before simulation starts. This is the expected integration pattern for the new API.

Confidence Score: 4/5

  • Test files are safe with straightforward cloning API integration, but core cloner module has critical bugs
  • The test file changes themselves are simple and correct - they just add calls to the new cloner.usd_replicate() API. However, the score is 4/5 (not 5/5) because previous review comments have identified multiple critical bugs in the core cloner module (source/isaaclab/isaaclab/scene/cloner.py and interactive_scene.py) that these tests depend on. These bugs include undefined variables, missing parameters, and unpopulated config values that could cause runtime errors.
  • The test files in this changeset are fine, but the core cloner implementation files (cloner.py and interactive_scene.py) have critical bugs that need fixing before these tests will work reliably

Important Files Changed

File Analysis

Filename Score Overview
source/isaaclab/test/assets/test_rigid_object.py 4/5 Adds cloner.usd_replicate() call for Table cloning in test setup - straightforward integration of new cloning API
source/isaaclab/test/assets/test_rigid_object_collection.py 4/5 Adds cloner.usd_replicate() call for Table cloning in test setup - mirrors changes in test_rigid_object.py

Sequence Diagram

sequenceDiagram
    participant Test as Test Function
    participant Gen as generate_cubes_scene()
    participant Prim as prim_utils
    participant Obj as RigidObject/Collection
    participant Clone as cloner.usd_replicate()
    participant Stage as USD Stage
    
    Test->>Gen: Call with num_cubes/num_envs
    Gen->>Prim: create_prim() for Table_0
    Note over Prim: Create initial Table prim
    Gen->>Obj: Initialize RigidObject(Cfg)
    Note over Obj: Object references /World/Table_.*/Object
    Gen->>Clone: usd_replicate(sources=[Table_0], dest=[Table_{}])
    Clone->>Stage: Replicate Table_0 to Table_1, Table_2, etc
    Note over Stage: USD prims cloned across environments
    Gen-->>Test: Return object & origins
    Test->>Test: sim.reset() & run tests
Loading

2 files reviewed, no comments

Edit Code Review Agent Settings | Greptile

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

Greptile Overview

Greptile Summary

Refactors test suite to work with new cloning APIs (usd_replicate, physx_replicate) replacing Isaac Sim's GridCloner. Changes follow two patterns:

  • Prototype-based tests (test_spawn_shapes.py, test_stage_in_memory.py): Remove multi-env creation loops, create single prototype, let spawner handle replication
  • Manual replication tests (test_articulation.py, test_deformable_object.py): Add explicit cloner.usd_replicate() calls but incorrectly create all envs before replication
  • Camera tests (test_multi_tiled_camera.py): Add helper to replicate camera groups, update regex patterns

Critical issues:

  • test_articulation.py and test_deformable_object.py create all environment prims in loops, then call usd_replicate() to copy to same destinations - causes duplicate prim errors
  • Tests will fail at runtime when usd_replicate() attempts to create prims that already exist

Confidence Score: 2/5

  • Not safe to merge - critical logic errors in test setup will cause runtime failures
  • Two test files have fundamental logic errors where all environment prims are pre-created, then usd_replicate() tries to copy to those same paths causing duplicate creation failures. These tests will not pass.
  • Pay close attention to test_articulation.py and test_deformable_object.py - both have duplicate prim creation issues

Important Files Changed

File Analysis

Filename Score Overview
source/isaaclab/test/assets/test_articulation.py 3/5 Adds cloner.usd_replicate() call after creating environment prims, but all envs are already created in loop at line 178 - potential duplicate creation issue
source/isaaclab/test/assets/test_deformable_object.py 4/5 Adds cloner.usd_replicate() for table cloning - change appears consistent with refactor pattern
source/isaaclab/test/sensors/test_multi_tiled_camera.py 4/5 Adds _replicate_group_origins() helper and updates path patterns from .* to _.* - consistent refactor to use new cloning APIs
source/isaaclab/test/sim/test_spawn_shapes.py 5/5 Removes multi-environment creation loops to only create single prototype - correctly adapts tests to new cloning paradigm where spawners handle replication
source/isaaclab/test/sim/test_stage_in_memory.py 4/5 Changes from creating cloned envs to creating asset prototypes under single parent, updates path patterns from env_.* to asset_.* - aligns with new prototype-based cloning

Sequence Diagram

sequenceDiagram
    participant Test as Test Setup
    participant USD as USD Stage
    participant Cloner as cloner.usd_replicate()
    
    Note over Test,Cloner: test_articulation.py (INCORRECT)
    Test->>USD: Create /World/Env_0 (line 178)
    Test->>USD: Create /World/Env_1 (line 178)
    Test->>USD: Create /World/Env_2 (line 178)
    Test->>Cloner: usd_replicate([Env_0], [Env_{}])
    Cloner->>USD: Try to create /World/Env_1 (EXISTS!)
    USD-->>Cloner: Error: Prim already exists
    
    Note over Test,Cloner: test_spawn_shapes.py (CORRECT)
    Test->>USD: Create /World/env_0 only
    Test->>USD: Spawn cone at /World/env_.*/Cone
    Note over USD: Spawner handles replication internally
Loading

Additional Comments (2)

  1. source/isaaclab/test/assets/test_articulation.py, line 177-187 (link)

    logic: All envs already created in loop (lines 177-178), then usd_replicate tries to copy /World/Env_0 to destinations that already exist - causing duplicate prim creation

  2. source/isaaclab/test/assets/test_deformable_object.py, line 60-95 (link)

    logic: All tables already created in loop (lines 61-62), then usd_replicate tries to copy /World/Table_0 to destinations that already exist

5 files reviewed, 2 comments

Edit Code Review Agent Settings | Greptile

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

Greptile Overview

Greptile Summary

Refactors environment cloning to use internal usd_replicate and physx_replicate APIs instead of Isaac Sim's GridCloner, removing the hard dependency.

Key changes:

  • Replaces GridCloner with new template-based cloning system (cloner.TemplateCloneCfg)
  • Adds heterogeneous cloning support with per-object replication when environments differ
  • Introduces random_heterogenous_cloning flag for prototype assignment control
  • Improves PhysX cloning performance for heterogeneous scenes (5.2s vs 27.5s simulation startup in benchmarks)
  • Adds test skip for Repose-Cube with create_stage_in_memory

Issue found:

  • Missing use_fabric parameter in physx_replicate call at interactive_scene.py:189 - causes config option clone_in_fabric to be ignored in non-cfg scene setup path

Confidence Score: 3/5

  • Safe to merge after fixing the missing use_fabric parameter
  • Major refactor with significant performance improvements, but missing parameter causes config option to be ignored in one code path. The bug is localized and easy to fix - it only affects users who manually clone environments without using config-based scene setup and have clone_in_fabric enabled.
  • source/isaaclab/isaaclab/scene/interactive_scene.py:189 needs the use_fabric parameter added

Important Files Changed

File Analysis

Filename Score Overview
source/isaaclab/isaaclab/scene/interactive_scene.py 3/5 Refactors cloning logic to use new internal replicators; missing use_fabric parameter in physx_replicate call at line 189
source/isaaclab_tasks/test/env_test_utils.py 5/5 Adds skip condition for Repose-Cube environments when running with create_stage_in_memory - straightforward test fix

Sequence Diagram

sequenceDiagram
    participant User
    participant InteractiveScene
    participant Cloner
    participant USD_Stage
    participant PhysX

    User->>InteractiveScene: __init__(cfg)
    InteractiveScene->>InteractiveScene: Create cloner_cfg
    InteractiveScene->>Cloner: grid_transforms()
    Cloner-->>InteractiveScene: env origins
    InteractiveScene->>Cloner: usd_replicate() [env xforms]
    Cloner->>USD_Stage: Create env_0 to env_N prims
    
    alt Scene from config
        InteractiveScene->>InteractiveScene: _add_entities_from_cfg()
        InteractiveScene->>InteractiveScene: Spawn assets to template
        InteractiveScene->>InteractiveScene: clone_environments()
        
        alt replicate_physics=True
            InteractiveScene->>USD_Stage: Set envIdInBoundsBitCount
        end
        
        alt Scene setup from cfg
            InteractiveScene->>Cloner: clone_from_template()
            Cloner->>Cloner: Discover prototypes
            Cloner->>Cloner: Build clone mapping
            Cloner->>Cloner: usd_replicate() [prototypes]
            Cloner->>USD_Stage: Clone prototype specs
            
            alt clone_physx=True
                Cloner->>PhysX: physx_replicate()
                PhysX-->>Cloner: Physics setup
            end
        else Manual scene
            InteractiveScene->>Cloner: physx_replicate() [missing use_fabric!]
            InteractiveScene->>Cloner: usd_replicate()
        end
        
        InteractiveScene->>Cloner: filter_collisions()
        Cloner->>USD_Stage: Create collision groups
    end
Loading

2 files reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

Greptile Overview

Greptile Summary

Updates test files to use new cloner.usd_replicate API instead of relying on automatic cloning from spawners.

  • test_articulation.py and test_deformable_object.py: Added explicit usd_replicate calls after creating base environments to clone them - implementations are correct
  • test_multi_tiled_camera.py: Introduced _replicate_group_origins helper function and updated prim path patterns from * to _*, but the helper has a critical bug where it attempts to read translations from prims that haven't been created yet

Confidence Score: 2/5

  • This PR has a critical logic error in test_multi_tiled_camera.py that will cause runtime failures
  • Two test files have correct implementations, but test_multi_tiled_camera.py contains a logic bug where _replicate_group_origins reads translations from non-existent prims before replication occurs, which will cause AttributeError or return None values
  • source/isaaclab/test/sensors/test_multi_tiled_camera.py requires immediate attention to fix the _replicate_group_origins function

Important Files Changed

File Analysis

Filename Score Overview
source/isaaclab/test/assets/test_articulation.py 5/5 Added usd_replicate call to clone environments after articulation creation - implementation looks correct
source/isaaclab/test/assets/test_deformable_object.py 5/5 Added usd_replicate call to clone table environments after deformable object creation - implementation looks correct
source/isaaclab/test/sensors/test_multi_tiled_camera.py 2/5 Added _replicate_group_origins helper and updated prim paths, but function reads non-existent prim translations before replication

Sequence Diagram

sequenceDiagram
    participant Test as Test Function
    participant PrimUtils as prim_utils
    participant Stage as USD Stage
    participant Cloner as cloner.usd_replicate
    participant Asset as Asset (Articulation/DeformableObject/Camera)

    Note over Test: test_articulation.py & test_deformable_object.py
    Test->>PrimUtils: create_prim(env_paths)
    PrimUtils->>Stage: Create base environment(s)
    Test->>Asset: Initialize Asset with prim_path pattern
    Asset->>Stage: Spawn asset in base environment
    Test->>Cloner: usd_replicate(sources, destinations, env_ids, positions)
    Cloner->>Stage: Replicate prims to all environments
    Stage-->>Test: Cloning complete

    Note over Test: test_multi_tiled_camera.py (ISSUE)
    Test->>Asset: Initialize TiledCamera
    Asset->>Stage: Create camera in Origin_i_0
    Test->>Test: Call _replicate_group_origins(i, num_cameras)
    Test->>Stage: Read translations from Origin_i_{0..N-1}
    Note over Test,Stage: BUG: Origins 1..N-1 don't exist yet!
    Test->>Cloner: usd_replicate(sources, destinations, positions)
    Cloner->>Stage: Attempt replication with invalid positions
Loading

3 files reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

get_translate = (
lambda prim_path: stage.GetPrimAtPath(prim_path).GetAttribute("xformOp:translate").Get()
) # noqa: E731
positions = torch.tensor([get_translate(fmt.format(j)) for j in range(num_cameras)])
Copy link
Contributor

Choose a reason for hiding this comment

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

logic: reading translations from prims that don't exist yet - only /World/Origin_{group_index}_0 exists before usd_replicate runs, but this tries to read positions for all j in range(num_cameras)

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Nov 6, 2025

Greptile Overview

Greptile Summary

This PR refactors environment cloning to remove the Isaac Sim GridCloner dependency and implement custom USD and PhysX replication. The changes decouple cloning from spawning, introduce a new cloner.py module with usd_replicate and physx_replicate functions, and add heterogeneous cloning support with per-object replication.

Key Changes

  • New source/isaaclab/isaaclab/scene/cloner.py module implementing TemplateCloneCfg, clone_from_template(), usd_replicate(), and physx_replicate()
  • InteractiveScene refactored to use new cloner instead of Isaac Sim GridCloner
  • Spawners simplified to only create prototypes under /World/template path - no longer handle cloning
  • Added random_heterogenous_cloning config flag to control prototype assignment (random vs round-robin)
  • Deprecated random_choice in MultiAssetSpawnerCfg and MultiUsdFileCfg
  • Performance improvement: simulation start time reduced from 27.5s to 5.2s (81% faster) for 8192 envs

Critical Bug Found

cloner.py:154 - replicate_args undefined when clone_usd=False and clone_physx=True, causing NameError. This configuration is valid but will crash at runtime. The variable is only defined inside the if cfg.clone_usd: blocks (lines 141-152) but used unconditionally in the PhysX replication section.

Other Issues

  • Missing test coverage for clone_usd=False + clone_physx=True configuration that would catch the critical bug
  • The bug was flagged multiple times in previous comments but remains unfixed in the latest commit

Confidence Score: 1/5

  • Critical bug will cause runtime crashes in valid configurations - not safe to merge
  • Score of 1 reflects critical NameError in cloner.py:154 that will crash when users configure clone_usd=False with clone_physx=True. This is a valid configuration per the API but produces undefined variable access. Bug was flagged in multiple previous comments but remains unfixed.
  • Pay critical attention to source/isaaclab/isaaclab/scene/cloner.py - fix the NameError before merging

Important Files Changed

File Analysis

Filename Score Overview
source/isaaclab/isaaclab/scene/cloner.py 1/5 New file implementing custom cloning - contains critical NameError bug when clone_usd=False and clone_physx=True (line 154)
source/isaaclab/isaaclab/scene/interactive_scene.py 3/5 Refactored to use new cloner module - removed Isaac Sim GridCloner dependency, simplified cloning logic
source/isaaclab/isaaclab/sim/spawners/wrappers/wrappers.py 4/5 Simplified spawner to create prototypes only - removed cloning logic and carb settings dependency
source/isaaclab/test/sim/test_cloner.py 3/5 New test file for cloner module - missing test case for clone_usd=False + clone_physx=True configuration

Sequence Diagram

sequenceDiagram
    participant User
    participant InteractiveScene
    participant Spawner
    participant Cloner
    participant USD_Stage
    participant PhysX

    User->>InteractiveScene: __init__(cfg)
    InteractiveScene->>InteractiveScene: create cloner_cfg
    InteractiveScene->>USD_Stage: create /World/template
    InteractiveScene->>USD_Stage: create env_0 prim
    InteractiveScene->>Cloner: usd_replicate(env_0 to env_1..N)
    Cloner->>USD_Stage: replicate empty env prims
    
    InteractiveScene->>InteractiveScene: _add_entities_from_cfg()
    loop for each asset config
        InteractiveScene->>Spawner: spawn asset
        Note over Spawner: prototype path = /World/template/.../proto_asset_.*
        Spawner->>USD_Stage: spawn prototypes (proto_asset_0, proto_asset_1, ...)
        Spawner-->>InteractiveScene: return prim
    end

    InteractiveScene->>InteractiveScene: clone_environments()
    
    alt replicate_physics=True
        InteractiveScene->>Cloner: clone_from_template(clone_physx=True)
        Cloner->>Cloner: discover prototypes
        Cloner->>Cloner: build mapping (random or modulo)
        Cloner->>Cloner: check if all envs use proto_0
        
        alt homogeneous (all proto_0)
            Cloner->>Cloner: prepare whole-env replication args
            opt clone_usd=True
                Cloner->>USD_Stage: usd_replicate entire env_0
            end
            Cloner->>PhysX: physx_replicate entire env_0
        else heterogeneous (mixed prototypes)
            Cloner->>Cloner: prepare per-object replication args
            opt clone_usd=True
                Cloner->>USD_Stage: usd_replicate per object
            end
            Cloner->>PhysX: physx_replicate per object
            Note over Cloner,PhysX: BUG: replicate_args undefined if clone_usd=False!
        end
    else replicate_physics=False
        InteractiveScene->>Cloner: clone_from_template(clone_physx=False)
        Cloner->>USD_Stage: usd_replicate only
    end
    
    opt filter_collisions=True
        InteractiveScene->>Cloner: filter_collisions()
        Cloner->>PhysX: setup collision groups
    end
    
    InteractiveScene-->>User: scene ready
Loading

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

24 files reviewed, 1 comment

Edit Code Review Agent Settings | Greptile


if not copy_from_source:
# skip physx cloning, this means physx will walk and parse the stage one by one faithfully
cloner.physx_replicate(self.stage, *replicate_args)
Copy link
Contributor

Choose a reason for hiding this comment

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

logic: missing use_fabric parameter - should pass self.cfg.clone_in_fabric

Suggested change
cloner.physx_replicate(self.stage, *replicate_args)
cloner.physx_replicate(self.stage, *replicate_args, use_fabric=self.cfg.clone_in_fabric)

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

Greptile Overview

Greptile Summary

This PR refactors environment cloning to remove the Isaac Sim GridCloner dependency and introduces new internal replicators (usd_replicate, physx_replicate). It adds heterogeneous cloning support with per-object replication for PhysX.

Key Changes

  • New cloner.py module with template-based cloning functions (clone_from_template, usd_replicate, physx_replicate, filter_collisions, grid_transforms)
  • InteractiveScene refactored to use new cloner instead of GridCloner
  • Added TemplateCloneCfg for controlling prototype assignment (random vs round-robin)
  • Spawners now create prototypes in /World/template, then cloner distributes to environments
  • Performance improvement: simulation start time reduced from 27.5s to 5.2s (8192 envs)

Critical Issues Found

  • cloner.py:155: NameError when clone_usd=False and clone_physx=True - replicate_args only defined inside the if cfg.clone_usd: block
  • interactive_scene.py:191: Missing use_fabric parameter in physx_replicate call

Confidence Score: 1/5

  • This PR has critical runtime errors that will cause crashes in specific configurations
  • Score reflects a critical NameError bug in cloner.py:155 that occurs when clone_usd=False and clone_physx=True, plus a missing config parameter. These are not edge cases - they represent valid configuration combinations that will crash at runtime
  • Pay close attention to source/isaaclab/isaaclab/scene/cloner.py line 155 - this MUST be fixed before merge

Important Files Changed

File Analysis

Filename Score Overview
source/isaaclab/isaaclab/scene/cloner.py 2/5 New file with critical bug: replicate_args undefined when clone_usd=False and clone_physx=True (line 155)
source/isaaclab/isaaclab/scene/interactive_scene.py 3/5 Refactored to use new cloner module; missing use_fabric parameter in physx_replicate call at line 191

Sequence Diagram

sequenceDiagram
    participant User
    participant InteractiveScene
    participant Cloner
    participant USD
    participant PhysX

    User->>InteractiveScene: __init__(cfg)
    InteractiveScene->>InteractiveScene: Create TemplateCloneCfg
    InteractiveScene->>InteractiveScene: Define env_0 prim
    InteractiveScene->>InteractiveScene: Define template root
    InteractiveScene->>Cloner: grid_transforms(num_envs, spacing)
    Cloner-->>InteractiveScene: positions, orientations
    InteractiveScene->>Cloner: usd_replicate(env_0 to all envs)
    Cloner->>USD: Copy env_0 spec to env_1..N
    
    InteractiveScene->>InteractiveScene: _add_entities_from_cfg()
    Note over InteractiveScene: Spawners create prototypes<br/>in /World/template
    
    InteractiveScene->>InteractiveScene: clone_environments()
    InteractiveScene->>Cloner: clone_from_template(stage, num_clones, cfg)
    
    Cloner->>Cloner: Discover prototypes under template_root
    Cloner->>Cloner: Build mapping (random or round-robin)
    Cloner->>Cloner: usd_replicate(prototypes to envs)
    Cloner->>USD: Copy prototype specs to destinations
    
    alt cfg.clone_physx is True
        Cloner->>Cloner: physx_replicate(replicate_args)
        Cloner->>PhysX: Register replicator
        Cloner->>PhysX: replicate() for each source
        Cloner->>PhysX: Unregister replicator
    end
    
    Cloner->>USD: SetActive(template_root, False)
    
    alt cfg.filter_collisions
        InteractiveScene->>Cloner: filter_collisions(stage, paths)
        Cloner->>USD: Create collision groups
        Cloner->>USD: Setup inverted filtering
    end
Loading

2 files reviewed, no comments

Edit Code Review Agent Settings | Greptile

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

Greptile Overview

Greptile Summary

Refactors environment cloning to use internal usd_replicate and physx_replicate functions instead of Isaac Sim's GridCloner, removing the hard dependency. Adds heterogeneous cloning support with per-object replication when environments differ.

Key changes:

  • Introduced new cloner.py module with TemplateCloneCfg, clone_from_template(), usd_replicate(), and physx_replicate() functions
  • Refactored InteractiveScene to use new cloner APIs, removing GridCloner dependency
  • Added random_heterogenous_cloning flag to InteractiveSceneCfg for prototype assignment control
  • Improved PhysX cloning time for heterogeneous scenes while preserving whole-env replication for homogeneous settings
  • Removed clone_in_fabric=True from most environment configs (now defaults to False)

Critical issues found:

  • cloner.py:154 - replicate_args undefined when clone_usd=False but clone_physx=True, causing NameError
  • interactive_scene.py:191 - Missing use_fabric parameter in physx_replicate() call
  • Test coverage missing for the clone_usd=False with clone_physx=True edge case

Confidence Score: 2/5

  • This PR has critical bugs that will cause runtime failures in certain configurations
  • Score reflects critical logic errors in cloner.py where replicate_args is undefined when clone_usd=False but clone_physx=True, causing NameError. Additionally, missing use_fabric parameter in interactive_scene.py:191 means the config option won't be respected. These are not edge cases - they affect core functionality when users have heterogeneous environments with replicate_physics=False.
  • Pay close attention to source/isaaclab/isaaclab/scene/cloner.py (lines 148-155) and source/isaaclab/isaaclab/scene/interactive_scene.py (line 191)

Important Files Changed

File Analysis

Filename Score Overview
source/isaaclab/isaaclab/scene/cloner.py 2/5 New cloning module with critical bugs in clone_from_template - replicate_args undefined when clone_usd=False but clone_physx=True, and missing use_fabric parameter in physx_replicate calls
source/isaaclab/isaaclab/scene/interactive_scene.py 3/5 Refactored to use new cloner module - cloner_cfg properly initialized but missing use_fabric parameter in physx_replicate call at line 191
source/isaaclab/isaaclab/scene/interactive_scene_cfg.py 5/5 Adds random_heterogenous_cloning config flag for controlling prototype assignment strategy
source/isaaclab/test/sim/test_cloner.py 4/5 New test coverage for cloner functions - tests USD replication, depth ordering, PhysX replication, but missing test case for clone_usd=False with clone_physx=True edge case

Sequence Diagram

sequenceDiagram
    participant User
    participant InteractiveScene
    participant Spawner
    participant Cloner
    participant USD
    participant PhysX

    User->>InteractiveScene: __init__(cfg)
    InteractiveScene->>InteractiveScene: Create env_prim_paths[]
    InteractiveScene->>Cloner: grid_transforms(num_envs, spacing)
    Cloner-->>InteractiveScene: env_origins
    InteractiveScene->>Cloner: usd_replicate(env_0 -> env_1..N)
    Cloner->>USD: Copy empty env prims with positions
    
    InteractiveScene->>InteractiveScene: _add_entities_from_cfg()
    
    loop For each asset in cfg
        InteractiveScene->>InteractiveScene: Resolve prim_path to template path
        InteractiveScene->>Spawner: spawn(template_path/proto_asset_.*)
        Spawner->>USD: Create prototypes in /World/template
    end
    
    InteractiveScene->>InteractiveScene: clone_environments()
    
    alt replicate_physics == True
        InteractiveScene->>USD: Set physxScene:envIdInBoundsBitCount
    end
    
    alt Scene setup from cfg
        InteractiveScene->>Cloner: clone_from_template(stage, num_clones, cfg)
        
        Cloner->>Cloner: Discover prototypes in template_root
        Cloner->>Cloner: Build mapping (random or modulo)
        
        Cloner->>Cloner: usd_replicate(prototypes)
        Cloner->>USD: Copy prims depth-first
        
        alt All envs use proto_0
            Cloner->>Cloner: usd_replicate(env_0 -> all envs)
            Cloner->>USD: Clone whole env_0 with positions
        else Heterogeneous envs
            Cloner->>Cloner: usd_replicate(per-object)
            Cloner->>USD: Clone objects individually
        end
        
        alt clone_physx == True
            Cloner->>Cloner: physx_replicate()
            Cloner->>PhysX: Register replicator callbacks
            PhysX->>PhysX: Replicate physics properties
            Cloner->>PhysX: Unregister replicator
        end
    else Manual scene setup
        InteractiveScene->>Cloner: physx_replicate(env_0 -> all)
        InteractiveScene->>Cloner: usd_replicate(env_0 -> all)
    end
    
    alt filter_collisions == True
        InteractiveScene->>Cloner: filter_collisions()
        Cloner->>USD: Create collision groups per env
    end
Loading

12 files reviewed, no comments

Edit Code Review Agent Settings | Greptile

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

35 files reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

Comment on lines +154 to +155
if cfg.clone_physx:
physx_replicate(stage, *replicate_args, use_fabric=cfg.clone_in_fabric)
Copy link
Contributor

Choose a reason for hiding this comment

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

logic: replicate_args only defined when cfg.clone_usd=True (lines 140-152) but used unconditionally here - causes NameError if clone_usd=False and clone_physx=True

Suggested change
if cfg.clone_physx:
physx_replicate(stage, *replicate_args, use_fabric=cfg.clone_in_fabric)
if cfg.clone_physx:
if not cfg.clone_usd:
# replicate_args not defined above when clone_usd=False
if torch.all(proto_idx == 0):
replicate_args = [clone_path_fmt.format(0)], [clone_path_fmt], world_indices, clone_plan["mapping"]
else:
src = [tpl.format(int(idx)) for tpl, idx in zip(clone_plan["dest"], proto_idx.tolist())]
replicate_args = src, clone_plan["dest"], world_indices, clone_plan["mapping"]
physx_replicate(stage, *replicate_args, use_fabric=cfg.clone_in_fabric)

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

Labels

enhancement New feature or request isaac-lab Related to Isaac Lab team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant