Skip to content

[RL] Fix lazy import in isaaclab_rl subpackage - #7517

Merged
StafaH merged 1 commit into
isaac-sim:developfrom
StafaH:fix/lazy-rl-entrypoint-imports
Sep 3, 2026
Merged

[RL] Fix lazy import in isaaclab_rl subpackage#7517
StafaH merged 1 commit into
isaac-sim:developfrom
StafaH:fix/lazy-rl-entrypoint-imports

Conversation

@StafaH

@StafaH StafaH commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

Description

Make the isaaclab_rl root package and unified entrypoints use the standard stub-driven lazy export mechanism. This prevents single-GPU play imports from loading the multi-GPU Torch Elastic launcher during Torch initialization, which caused a circular-import failure on Windows with Torch 2.11.

The change also adds static export stubs for both public namespaces and subprocess regression coverage for every isaaclab_rl package initializer, ensuring namespace imports do not eagerly load Torch or unrelated RL frameworks.

Type of change

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

Release backport

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

Testing

  • 54 focused entrypoint, installed-workflow, and multi-GPU command tests passed
  • Full Isaac Lab formatting and lint checks passed
  • isaaclab_rl changelog validation passed

Checklist

  • I have read and understood the contribution guidelines
  • I have run the pre-commit checks with uv run isaaclab -f
  • Documentation changes are not required for this internal import fix
  • My changes generate no new warnings
  • I have added tests that prove the fix is effective
  • I have added a changelog fragment for the touched package
  • My name already exists in CONTRIBUTORS.md

@StafaH
StafaH requested a review from a team September 3, 2026 05:45
@github-actions github-actions Bot added bug Something isn't working isaac-lab Related to Isaac Lab team labels Sep 3, 2026
@greptile-apps

greptile-apps Bot commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR replaces eager and manually maintained isaaclab_rl exports with the repository’s stub-driven lazy-export mechanism, preventing ordinary entrypoint imports from initializing Torch Elastic and unrelated RL frameworks.

  • Adds runtime-adjacent .pyi export maps for the root and entrypoints namespaces.
  • Adds isolated subprocess regression coverage for package initialization and selected public exports.
  • Documents the lazy-import fix in the package changelog.

Confidence Score: 5/5

The PR appears safe to merge, with the public export mappings preserved and package metadata ensuring the runtime-required stubs are installed.

The new lazy exporter is supplied with complete sibling stubs, representative public imports remain resolvable, and the added subprocess tests verify that ordinary namespace and play-entrypoint imports avoid the unwanted framework initialization.

Important Files Changed

Filename Overview
source/isaaclab_rl/isaaclab_rl/init.py Replaces the custom root-level lazy forwarding implementation with the standard stub-driven lazy exporter while preserving version initialization.
source/isaaclab_rl/isaaclab_rl/init.pyi Defines the root package’s existing public entrypoint exports for runtime lazy resolution and static analysis.
source/isaaclab_rl/isaaclab_rl/entrypoints/init.py Removes eager imports of API, dispatch, and multi-GPU modules in favor of stub-driven symbol loading.
source/isaaclab_rl/isaaclab_rl/entrypoints/init.pyi Maps each entrypoint export to its implementation module, allowing the multi-GPU launcher to remain unloaded until requested.
source/isaaclab_rl/test/test_entrypoints.py Adds isolated import checks demonstrating that package initialization and play entrypoint resolution do not eagerly load Torch or unrelated RL frameworks.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart LR
    A[Import isaaclab_rl] --> B[lazy_export reads __init__.pyi]
    B --> C[Public names registered lazily]
    C --> D{Symbol requested}
    D -->|run_play_cli| E[Load entrypoints dispatch]
    D -->|run_train_multigpu_cli| F[Load Torch Elastic multigpu module]
    A -. no eager load .-> F
Loading

Reviews (1): Last reviewed commit: "Fix lazy imports in isaaclab_rl" | Re-trigger Greptile

@isaaclab-review-bot isaaclab-review-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Isaac Lab Review Bot

The PR replaces the root and entrypoints package initializers with the shared stub-driven lazy export mechanism, preserving their public symbol sets while deferring Torch Elastic and unrelated framework imports.

  • Design and architecture: The revised import path consistently uses isaaclab.utils.module.lazy_export() with adjacent stubs. The root namespace delegates symbols to entrypoints, while the entrypoints stub maps each symbol to api, dispatch, or multigpu, allowing the multi-GPU launcher to remain deferred.
  • API: The new stubs preserve the previous exports: twelve root symbols and thirteen entrypoints symbols, including BackendName only under isaaclab_rl.entrypoints. __version__ remains eagerly available and is represented in the root stub. No public API removal or rename is evident.
  • Implementation: The subprocess tests directly exercise clean-interpreter namespace imports and selected symbol imports, checking that Torch, Torch Elastic, and unrelated RL frameworks are not loaded eagerly. The changelog fragment matches the affected source package. Installed-wheel inclusion of the runtime-consumed .pyi files remains the main packaging surface to validate, but the supplied patch does not establish a concrete packaging failure.

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.

@StafaH

StafaH commented Sep 3, 2026

Copy link
Copy Markdown
Contributor 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 3, 2026
@kellyguo11

Copy link
Copy Markdown
Contributor

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 3, 2026
@StafaH
StafaH merged commit 8ca264b into isaac-sim:develop Sep 3, 2026
53 of 81 checks passed
kellyguo11 added a commit that referenced this pull request Sep 4, 2026
# Description

Backports the following merged `develop` PRs to `release/3.0.0`:

- #7220 — prune unused Docker volumes on package-test runners
- #7169 — cache the resolved OVRTX Warp device
- #6889 — move the OVPhysX collider cache out of the Python interpreter
directory
- #7345 — document the registered XR camera PiP tasks
- #7050 — update and reorganize the LEAPP documentation
- #7473 — register external RSL-RL tasks before agent discovery
- #7467 — update the China storage profile to Isaac Sim 6.1
- #7385 — accept legal float scale values when seeding Fabric frame
views from USD
- #7517 — use lazy exports in `isaaclab_rl`

The duplicate #7517 in the original request is included once.

Seven source commits replayed cleanly. Two required release-specific
reconciliation:

- #7169 retains the release branch's mapped OVRTX write path, which was
removed separately on `develop`, while resolving and caching one Warp
device for render-product IDs, mappings, and CUDA streams.
- #7050 preserves the #7494 export-backend clarification that is already
present on the release branch while applying the broader LEAPP
documentation overhaul.

No new dependencies are added.

## Type of change

- Bug fix (non-breaking change which fixes an issue)
- Performance improvement
- Documentation update
- CI/infrastructure update

## Release backport

- [ ] <!-- backport-active-release --> This PR already targets the
active release branch; do not backport it again.

## Validation

- `uv run --no-project --with pytest python -m pytest -q
.github/actions/run-package-tests/test_cleanup_docker_storage.py` — 10
passed
- Nine isolated `isaaclab_rl` namespace/lazy-import regression cases
passed
- Resolved-device OVRTX mapping behavior check passed with Warp 1.16.0
- `uv run --no-project python -m compileall -q` on all changed Python
modules and tests
- `uv run --no-project python tools/changelog/cli.py check` against the
exact `upstream/release/3.0.0` base
- `pre-commit==4.6.2 run --all-files` passed all available hooks
- `git diff --check upstream/release/3.0.0..HEAD`

The full project test environment and documentation build cannot resolve
on this macOS/arm64 host because the release lockfile supports Linux and
Windows only. The Git LFS hook was also unavailable because `git-lfs` is
not installed; none of the changed paths are LFS-tracked. Linux CI
remains authoritative for simulator, OVRTX, Fabric, and full
documentation validation.

## Checklist

- [x] I have read and understood the contribution guidelines
- [x] I have run the available formatting and static checks
- [x] I have included the corresponding documentation changes
- [x] Each touched source package includes its original changelog
fragment
- [x] Every backported commit records its source commit with `cherry
picked from commit`
- [x] The original contributors are preserved as commit authors

---------

Signed-off-by: Zeng Qingcheng <60593302+NeoZng@users.noreply.github.com>
Co-authored-by: myurasov-nv <168484206+myurasov-nv@users.noreply.github.com>
Co-authored-by: Peter Verswyvelen <pverswyvelen@nvidia.com>
Co-authored-by: pv-nvidia <197907000+pv-nvidia@users.noreply.github.com>
Co-authored-by: hujc <jichuanh@nvidia.com>
Co-authored-by: hougantc-nvda <127865892+hougantc-nvda@users.noreply.github.com>
Co-authored-by: Frank Lai NV <frlai@nvidia.com>
Co-authored-by: peterd-NV <peterd@nvidia.com>
Co-authored-by: Sheikh Dawood <7774242+sheikh-nv@users.noreply.github.com>
Co-authored-by: Zeng Qingcheng <60593302+NeoZng@users.noreply.github.com>
Co-authored-by: Antoine RICHARD <antoiner@nvidia.com>
Co-authored-by: Mustafa H <34825877+StafaH@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working isaac-lab Related to Isaac Lab team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants