Repository navigation
Make AppLauncher teardown truthful and re-entrancy-safe; document mGPU NCCL workaround - #6636
Conversation
The AppLauncher abort handler for SIGTERM/SIGABRT/SIGSEGV calls SimulationApp.close() directly. When another signal is delivered while close() is already running -- for example a repeated SIGTERM from a distributed launcher tearing down workers, or a fault raised inside close() itself -- the handler re-enters and calls close() again. The nested calls recurse until the interpreter stack overflows, so the process neither shuts down cleanly nor reports the original signal. On multi-GPU training this surfaced as workers that ignored SIGTERM and had to be escalated to SIGKILL, and as a spurious segmentation fault that masked the real first failure behind the stack overflow. Guard the handler with a re-entrancy flag: the first signal closes the app once, and any signal that arrives while closing falls back to the default action and re-raises, so the process terminates with the original signal. Add a kitless regression test that drives the handler with a close() that re-signals, asserting close() runs exactly once and the re-entrant signal falls back to SIG_DFL.
Multi-GPU training with RTX rendering enabled fails on some systems when the participating GPUs span multiple NUMA nodes: one of the first collectives times out (NCCL watchdog on an early BROADCAST/ALLREDUCE) while the same training passes on a single-switch GPU set, and while rendering-disabled training passes on any GPU set. Disabling NCCL's cuMem allocator restores these runs. Add the symptom signature and workaround to the existing NCCL troubleshooting section of the multi-GPU documentation.
Greptile SummaryThis PR consolidates all
Confidence Score: 5/5Safe to merge; the exit-path logic is well-reasoned, each decision is explicitly documented, and the two workarounds are clearly annotated as temporary with a deletion path tied to an upstream issue. All changes are in the teardown/signal-handling path, exercised by the new unit and integration tests. The implementation carefully handles the re-entrant signal case, the fast-shutdown workaround, and exit-code preservation. The only findings are minor edge cases that do not affect correctness under normal conditions. No files require special attention; the core logic in app_launcher.py is well-tested by the two new test files. Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[AppLauncher.__init__] --> B[_SimulationAppLifecycle.__init__]
B --> C[announce_startup]
C --> D[install_exit_handlers]
D --> E{Process ends how?}
E -->|Normal exit| F[_close_at_exit]
F --> G{sys.last_exc set?}
G -->|Yes| H[app.close exit_code=1]
G -->|No| I[app.close exit_code=0]
E -->|SIGTERM or SIGABRT| J[_on_abort_signal]
J --> K{_closing True?}
K -->|Yes re-entrant| L[SIG_DFL + raise_signal]
K -->|No| M[_closing=True disable fast shutdown]
M --> N[app.close]
N --> O[SIG_DFL + raise_signal 128+signum]
E -->|SIGINT| P[default_int_handler KeyboardInterrupt raised]
E -->|SIGSEGV| Q[Not intercepted carb minidumps]
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
flowchart TD
A[AppLauncher.__init__] --> B[_SimulationAppLifecycle.__init__]
B --> C[announce_startup]
C --> D[install_exit_handlers]
D --> E{Process ends how?}
E -->|Normal exit| F[_close_at_exit]
F --> G{sys.last_exc set?}
G -->|Yes| H[app.close exit_code=1]
G -->|No| I[app.close exit_code=0]
E -->|SIGTERM or SIGABRT| J[_on_abort_signal]
J --> K{_closing True?}
K -->|Yes re-entrant| L[SIG_DFL + raise_signal]
K -->|No| M[_closing=True disable fast shutdown]
M --> N[app.close]
N --> O[SIG_DFL + raise_signal 128+signum]
E -->|SIGINT| P[default_int_handler KeyboardInterrupt raised]
E -->|SIGSEGV| Q[Not intercepted carb minidumps]
Reviews (2): Last reviewed commit: "Fail loudly if the SimulationApp workaro..." | Re-trigger Greptile |
Extend the re-entrancy fix into a complete teardown-correctness change based on a combined review with the atexit exit-code fix (isaac-sim#6634): - Report killed-by-signal status: the handler previously ran a graceful close whose Kit fast-shutdown path terminated the process with exit code 0, so a SIGTERM-ed worker was recorded as successful and distributed launchers misattributed the failure. The handler now disables fast shutdown so close() performs the full teardown and returns, then re-raises the signal with the default action so the process exits with the conventional 128+signum status. The override is marked WORKAROUND(isaac-sim) for removal once SimulationApp can propagate a nonzero exit status through its fast-shutdown path. - Arm the re-entrancy guard in the atexit close (extracted to the testable _close_app_at_exit method) so a signal arriving during a normal shutdown takes the guarded path instead of starting a nested teardown of a half-closed app. - Stop intercepting SIGSEGV: a Python handler never runs for a synchronous main-thread segfault (the process spins on signal delivery), reports success for worker-thread segfaults, and replaces the carb crash reporter's handler, suppressing minidumps. - Restore Python's default SIGINT handler over SimulationApp's, which exits 0 before user finally blocks or KeyboardInterrupt handlers can run. Marked WORKAROUND(isaac-sim) for removal once the upstream handler preserves exception semantics and a nonzero exit status. - Remove the unregistered, dead _interrupt_signal_handle_callback. Tests cover the single-close-plus-reraise contract, the re-entrant signal path, and the atexit guard arming; all three fail against the previous behavior.
Launch a headless CPU AppLauncher in a child process, send SIGTERM once the app is ready, and assert the process dies by SIGTERM instead of reporting a successful exit, with no abort-handler recursion in stderr. Verified against the previous behavior: without the handler fix the child exits 0 (Kit fast shutdown swallows the termination status); with the fix it reports killed-by-SIGTERM.
Paired experiments on the deterministic cross-NUMA reproduction show the narrower knob is sufficient: the same GPU set that fails flag-free passes with only cuMem host allocations disabled. Recommend it first, with the full cuMem allocator disable as the fallback, so affected systems keep the device-side allocator benefits.
Gather the startup announcements (CI marker, Kit version diagnostics) and the entire exit-path policy (atexit close, signal handlers, exit codes) into a nested AppLauncher._SimulationAppLifecycle class. The pieces coordinate through one guard flag and exist for one reason -- report the process state truthfully to whatever supervises it -- so a single class with the policy table as its docstring replaces logic previously spread across __init__ and three private methods. Absorb the atexit exit-code fix from PR isaac-sim#6634 (nblauch) into the lifecycle class: the atexit close passes a nonzero exit code when an unhandled exception is pending, so Kit fast shutdown does not replace the failure status with 0. Includes that PR's integration test and a kitless unit test for the exit-code selection. SystemExit is documented as not yet detected. Behavior is otherwise unchanged; all kitless unit tests and both real-Kit integration tests (SIGTERM status, exception exit code) pass.
Merge the two single-test real-Kit integration files into test_app_launcher_exit_status.py: both launch a headless AppLauncher in a child process and assert on the exit outcome (killed by SIGTERM, failed with an unhandled exception), sharing one trigger harness. Rename the kitless unit file to test_simulation_app_lifecycle.py to match the class it exercises; its previous name predated the exit-code coverage.
The two WORKAROUND(isaac-sim) blocks were wrapped in blanket exception suppression, so an upstream SimulationApp change could silently disable them and quietly reintroduce the exit-status masking. Print a clear warning when the fast-shutdown override does not take, and fall back to a plain close() with a warning if close() stops accepting exit_code. Reference the upstream fix (isaac-sim/IsaacSim#717) in the workaround note; once it lands, both blocks can be deleted.
The upstream SimulationApp fix is merged (isaacsim.simulation_app 2.18.5): close(exit_code) now performs its full teardown and exits with the given status under fast shutdown. Replace the interim fast-shutdown disable in the abort handler with close(exit_code=128 + signum): on 2.18.5+ the app tears down fully and exits truthfully; on older builds the status is still truthful without the teardown; if close() returns (fast shutdown disabled), the handler re-raises the signal with the default action as before. The remaining WORKAROUND(isaac-sim) is the SIGINT re-registration, which the merged fix does not cover. The SIGTERM integration test accepts both truthful outcomes (exit status 128+SIGTERM or death by SIGTERM) and passes against both the pre-fix and the fixed SimulationApp builds.
The upstream exit-status fix (isaacsim.simulation_app 2.18.5) deliberately excluded the SIGINT handler because fixing it changes user-visible Ctrl-C semantics for every SimulationApp consumer; state that rationale at the workaround site.
Compress the class docstring and per-site comments to essentials, fold the duplicated exit_code TypeError fallback into a _close_app helper, and describe the SIGINT registration as behavior not handled on the sim side (changing it there affects Ctrl-C semantics for every consumer) rather than as a workaround.
The readiness loop iterated the child's stdout with a blocking readline, so its 300-second deadline was only checked between lines: a child hanging silently during startup stalled the test and its CI shard until the job timeout. Wait on an event fed by a daemon reader thread instead, fail fast when the child exits before printing the ready marker, and preserve the collected child output in the failure report.
| export NCCL_ALGO=Ring | ||
|
|
||
| On some multi-GPU systems, distributed training with RTX rendering enabled (for example, | ||
| camera-based tasks launched with ``--enable_cameras``) fails when the participating GPUs span |
There was a problem hiding this comment.
let's avoid mentioning --enable_cameras, it shouldn't be necessary anymore
| try: | ||
| self._app.close(exit_code=exit_code) | ||
| except TypeError: | ||
| print( |
There was a problem hiding this comment.
should we use logging instead of print here?
There was a problem hiding this comment.
This fires during teardown, where carb.logging may already be disabled (close() calls set_log_enabled(False)), so I kept it on raw sys.__stderr__ — the same channel this class uses for its other teardown diagnostics (the startup marker, Kit-version prints), chosen because __stderr__ survives stdout redirection and log-subsystem shutdown. Happy to switch to logger.warning for consistency if you'd prefer, but it'd be less reliable at this point in shutdown.
| def _close_app(self, exit_code): | ||
| """Close the app with ``exit_code``, warning loudly if the parameter is unsupported.""" | ||
| try: | ||
| self._app.close(exit_code=exit_code) |
There was a problem hiding this comment.
what happens if app.close() hits a different TypeError? could that ever become the case?
There was a problem hiding this comment.
Good catch — yes, it could. A TypeError raised inside close()'s own teardown (rather than from the missing kwarg) would be swallowed by the same except, mislabeled "does not accept exit_code," and then trigger a second close() on a half-torn-down app — the exact re-entrancy this class exists to prevent. Fixed in 7dfdbd3e93c: _close_app now probes inspect.signature(self._app.close) for the exit_code parameter up front, so only a genuinely missing parameter takes the fallback; any TypeError from within close() propagates normally.
| print(f"[ISAACLAB] Kit version: {kit_version}", file=sys.__stderr__, flush=True) | ||
| print(f"[ISAACLAB] Kit kernel: {kernel_version}", file=sys.__stderr__, flush=True) | ||
| print(f"[ISAACLAB] Kit hash: {kit_git_hash}", file=sys.__stderr__, flush=True) | ||
| class _SimulationAppLifecycle: |
There was a problem hiding this comment.
do you want to make this in isaaclab_physx package?
There was a problem hiding this comment.
might be a bit aggressive for this pr?
The unguarded ``except TypeError`` around ``close(exit_code=...)`` conflated two distinct failures: a SimulationApp whose close() lacks the parameter, and a TypeError raised inside close()'s own teardown. The latter was misread as an unsupported parameter, printed a misleading warning, and re-invoked close() on a half-torn-down app -- the exact re-entrancy this class exists to prevent. Probe inspect.signature up front so only a genuinely missing parameter takes the fallback path.
Cameras auto-enable for scenes with Kit-renderer sensors, so the flag is no longer required for camera-based tasks. Remove it from the NCCL NUMA-spanning workaround note.
…U NCCL workaround (isaac-sim#6636) # Summary - Consolidates `AppLauncher` process-lifecycle handling into one nested `_SimulationAppLifecycle` class: startup announcements (CI marker, Kit version diagnostics) plus the entire exit-path policy, with the policy table as the class docstring. - Fixes every exit path that misreported failure as success or destroyed its own diagnostics (full failure-case table below). Absorbs the atexit exit-code fix from isaac-sim#6634. - Documents the NCCL cuMem workaround for multi-GPU RTX training on NUMA-spanning GPU allocations (`NCCL_CUMEM_HOST_ENABLE=0` first, `NCCL_CUMEM_ENABLE=0` as fallback). - The upstream `SimulationApp` exit-status fix (public reference: isaac-sim/IsaacSim#717) has been **merged** (`isaacsim.simulation_app` >= 2.18.5): the signal handler now simply passes `close(exit_code=128 + signum)` — full teardown + truthful status on fixed builds, truthful status on older builds. The one remaining `WORKAROUND(isaac-sim)` is the SIGINT re-registration (upstream handler still exits 0 before user code unwinds); it fails loudly if drift disables it. - Fixes isaac-sim#6573 (absorbed atexit exit-code fix, originally isaac-sim#6634 by @nblauch). - Fixes isaac-sim#6530: the SIGTERM handler no longer returns to the interrupted execution path — the worker exits through `close(exit_code=128 + signum)` (full Kit teardown on `isaacsim.simulation_app` >= 2.18.5) or dies by the re-raised signal, so distributed workers terminate with a truthful status instead of surviving and spamming TCPStore `Broken pipe` errors. # Failure cases and how this PR addresses them Root mechanism: Kit fast shutdown terminated the process with exit code 0 from inside `SimulationApp.close()`, so any death funneled through an unqualified `close()` was reported as success; additionally, the abort-signal handler was unguarded against re-entrancy. | How the process ends | Before this PR | After this PR | |---|---|---| | Unhandled Python exception | atexit close overwrote the pending failure with **exit 0** (CI false-green) | exits 1 (`sys.last_exc` detected; absorbed from isaac-sim#6634; `SystemExit` documented as not yet covered) | | Single SIGTERM (torchrun teardown, SLURM preemption, `kill`) | graceful close → **exit 0**; launcher marks the killed rank SUCCEEDED; surviving ranks hang until the NCCL watchdog | `close(exit_code=128 + signum)`: full teardown + truthful status on `isaacsim.simulation_app` >= 2.18.5; truthful status on older builds; dies by the signal if `close()` returns | | Second signal while a close is running (repeated SIGTERM; fault inside the replicator stop/wait) | handler re-entered `close()` → **infinite recursion** → SIGKILL-only shutdown, spurious SIGSEGV, logs flooded (~975 recursion frames/job observed on OSMO pods) | guard: re-entrant signal falls back to `SIG_DFL` | | Signal racing the normal atexit close | nested full second teardown of a half-closed app | atexit arms the same guard | | `kill -ABRT` | graceful close → **exit 0** | same truthful-close path as SIGTERM | | Real SIGSEGV, main thread | Python handler can never run → process **spins forever** at 100% CPU, crash reporter clobbered (no minidump) | SIGSEGV no longer intercepted → default action, minidumps restored | | Real SIGSEGV, worker thread | handler ran on the main thread → **exit 0** for a crashed process | same: default action, truthful signal death | | Ctrl-C | SimulationApp's handler exits **0** before user `finally`/`KeyboardInterrupt` code runs | Python default handler restored: `KeyboardInterrupt` unwinds user code, nonzero exit | Not addressed here (tracked elsewhere): `sys.exit(N)`/`SystemExit` still exits 0 (gap inside the isaac-sim#6634 mechanism, documented at the detection site). # Implementation notes 1. All exit-path logic lives in `AppLauncher._SimulationAppLifecycle`; the class docstring is the policy table, and each decision carries its rationale in place. 2. The signal handler passes the killed-by-signal status through `close(exit_code=128 + signum)`. With the merged upstream fix (`isaacsim.simulation_app` >= 2.18.5) the app performs its full teardown and exits with that status; on older builds the status is preserved without the teardown; if `close()` returns (fast shutdown disabled), the handler re-raises with the default action. A `TypeError` fallback warns loudly if a future `SimulationApp` drops the parameter. 3. Docs: distributed camera training fails deterministically when the allocated GPUs span NUMA nodes and passes on a single-switch set; disabling NCCL cuMem host allocations rescues the failing shape in paired same-node experiments. Added to the multi-GPU NCCL troubleshooting section. **Testing.** Six kitless unit tests (`test_simulation_app_lifecycle.py`: killed-by-signal status, re-entrancy both directions, exit-code selection, drift fallbacks on both paths) plus two real-Kit integration tests (`test_app_launcher_exit_status.py`: SIGTERM → truthful termination status with no handler recursion; unhandled exception → exits 1). The integration tests pass against both the pre-fix and the fixed (>= 2.18.5) `SimulationApp` builds; on develop's original behavior the SIGTERM test observes exit code 0 (the bug). ## Type of change - Bug fix (non-breaking change which fixes an issue) - Documentation update ## Checklist - [x] I have read and understood the [contribution guidelines](https://isaac-sim.github.io/IsaacLab/main/source/refs/contributing.html) - [x] I have run the [`pre-commit` checks](https://pre-commit.com/) with `./isaaclab.sh --format` - [x] I have made corresponding changes to the documentation - [x] My changes generate no new warnings - [x] I have added tests that prove my fix is effective or that my feature works - [x] I have added a changelog fragment under `source/<pkg>/changelog.d/` for every touched package (do **not** edit `CHANGELOG.rst` or bump `extension.toml` — CI handles that) - [x] I have added my name to the `CONTRIBUTORS.md` or my name already exists there
…he config (1/2) (#8068) ## Description **Part 1 of 2: the design.** The migration of every script and test is in the stacked follow-up, #8090. This PR keeps existing scripts running unchanged, so the two halves can be reviewed separately. `launch_simulation` now starts each simulation runtime through the launcher that the runtime's own backend package provides. The resolved config says which launcher is needed, so core never imports one. ```python # isaaclab.app: the interface every backend runtime implements class SimulationLauncher: device: str | None = None # optional device the runtime picked def __init__(self, launcher_args): ... # constructing it starts the runtime def close(self, exit_code: int = 0): ... # stops it # backend configs name their launcher, resolved lazily like ``class_type`` class PhysxCfg(PhysicsCfg): launcher_type: ClassVar[str] = "isaaclab_physx.app:KitLauncher" class OVRTXRendererCfg(RendererCfg): launcher_type: ClassVar[str] = "isaaclab_ov.app:OvrtxLauncher" ``` `launch_simulation(cfg, args)` scans the resolved config as it already did and collects `launcher_type` from the physics and renderer config instances it resolved. It constructs each launcher once and closes them in reverse order when the block exits. Kit needs that no config names (`require_kit`, no physics config, a Kit visualizer requested only on the CLI) fall back to `KitLauncher`. - **`isaaclab_physx.app.KitLauncher`** is the old `AppLauncher` body, minus dead code: - removed: argument-collision bookkeeping, the Isaac Sim 5 branch, and the hidden `--cpu` flag; - moved in from `launch_simulation`: the Isaac Sim availability check and the "Kit already running" guard. - **`isaaclab_ov.app.OvrtxLauncher`** registers the OVRTX USD schemas, which `launch_simulation` used to do inline. - **Moved into `sim_launcher.py`** because kitless launches need them too: argv fusing, visualizer argument normalization, and the visualizer-settings sync (no longer wrapped in a blanket `suppress(Exception)`). ### Kit stays in `isaaclab_physx` Core code no longer imports `carb`, `omni`, or `omni.replicator`. Kit concerns go through one of two owners, and no new global hook is added. - **The `SimulationContext` backend registry** owns anything tied to a simulation's lifetime: - `isaaclab_physx.app.KitStageBackend` is registered through `get_or_create_backend` when Kit runs; - it attaches the stage to Kit's USD context and closes Kit's context stage when `clear_instance()` closes the other backends; - core stage utilities never touch Kit: `clear_stage()`/`close_stage()` are Kit-free, and Kit's own consumers (PhysX reset/step, RTX render, the Kit visualizer) run the app updates they need. - **No defensive `None` handling on invariants:** a `SimulationContext` always has a stage, so consumers read `SimulationContext.instance().stage` directly (`SceneDataProvider.usd_stage` / `get_usd_stage` are removed). - **`KitLauncher`** owns one-time process setup: - `SettingsManager.set_backend(carb.settings)`, replacing `initialize_carb_settings` and `is_omniverse_mode`; - sharing Isaac Sim's stage-helper context; - one app update in `close()`, so scripts no longer need their own. - **Replicator** is enabled by the Isaac RTX renderer and seeded by the Replicator event terms that use it. The env classes no longer import it. - **`show_stage_in_viewport`** moves to `isaaclab_physx.app`, since it only works under Kit. - **Gravity:** tasks set it through `PhysxManager.set_gravity` instead of `carb.Float3`. ### Exit handling The ~110-line `_SimulationAppLifecycle` class from #6636 is gone. I measured a real Kit process with no handlers installed, and only two exit paths needed help. Both are now handled by two lines in `KitLauncher`: - An unhandled exception exits with 1. Kit's exit path reported 0. - `SIGINT` raises `KeyboardInterrupt`. Kit's own handler exited 0. `SIGTERM`, `SIGABRT`, and `SIGSEGV` keep their default actions. Fixes #7774, supersedes #7775 and #6531. ### Constructing runtime objects after launch Importing `pxr.Usd` before Kit starts makes Kit fail to start. Scripts therefore import only config classes and construct runtime objects with `instantiate(cfg)` (#8085), which resolves the config's lazy `class_type` after the runtime is up. - `ManagerBasedEnvCfg` and `ManagerBasedRLEnvCfg` gain `class_type`. - The 21 task configs with a custom env class name it. A registry test checks that all 126 match their registered entry point. - **Fixed:** `{DIR}` in an inherited `class_type` resolved against the module of a subclass missing `@configclass`, so the call failed with `ModuleNotFoundError`. ### Compatibility in this PR `isaaclab.app.AppLauncher` is deprecated. It now starts Kit through `launch_simulation`, so develop's scripts and tests run unchanged here. It still offers `is_available`, `has_gui`, and `has_window`, which unmigrated scripts use. The migration PR moves every caller and reduces it to an init-only shim. `isaaclab.test.utils.launch_test_simulation(**launcher_args)` starts Kit for a test module through `launch_simulation`. It picks the test device by default. ### Behavior changes - **Removed** (breaking; each only restated an invariant or forwarded elsewhere): - `sim_utils.update_stage`: the simulation's reset, step, and render process stage changes; - `sim_utils.is_current_stage_in_memory`: compare against `SimulationContext.instance().stage`; - `sim_utils.show_stage_in_viewport`: use `isaaclab_physx.app.show_stage_in_viewport`; - `SettingsManager.initialize_carb_settings` (and the module-level function) and `is_omniverse_mode`: `KitLauncher` sets the settings backend, and `has_kit()` checks for Kit; - `SceneDataProvider.usd_stage` / `get_usd_stage`; - the hidden `--cpu` flag: use `--device cpu`. - **Replicator seeding:** the Replicator event terms seed it with `env.cfg.seed` when they are built; `_get_replicator()` only loads it. Calling `env.seed(x)` later no longer reseeds Replicator. - **Kit startup marker** is now `[ISAACLAB] KitLauncher initialization complete`, and `tools/conftest.py` is updated to match. - **SIGTERM** ends the process immediately, without a Kit teardown. - **Warp environments:** `render_mode="rgb_array"` now warns and returns `None`, matching the core environments. Net: +2,326 / −3,045 across 154 files. ## Type of change - Breaking change (`AppLauncher` deprecated; Kit-coupled helpers removed; Kit exit and seeding behavior changed) ## Validation All runs on the display GPU (GPU 0), with develop's scripts and tests unchanged unless listed here. - **Launcher, app, and config tests:** - `isaaclab/test/app` (26) and `isaaclab_physx/test/app` (88); - `test_runtime_compatibility` (27), visualizer intent (8), distributed device (13), `test_preset_kit_decision` (6), `test_preset_cli` (11); - `test_configclass` (37), `test_sb3_leapp_export`, and the CLI tests (234). - **Kit tests through the deprecated adapter:** - `test_simulation_context` (30), PhysX `test_rigid_object` (44), `test_camera` (21); - stage utils (15), stage in memory (3), `test_events` (4), texture randomization (2), `test_manager_based_env` (4). - **Training:** `train.py --task Isaac-Cartpole --max_iterations 2` exits 0 with `isaacsim_physx` and `newton_mjwarp`. - `physics=physx` (kitless ovphysx) fails with an observation batch mismatch. - Develop `93b6e7432` fails the same way, so it is unrelated to this PR. - **Every script under `scripts/` and `examples/`**, compared against develop with the same invocation: - **Scripts outside the standalone matrix (78):** same outcome on develop and here. 52 run, 19 are blocked by an external resource (datasets, XR, Ray, gr00t, robomimic, moviepy), and 7 fail identically on develop. - **Standalone matrix (361 cases):** no regressions. The only case that first looked new was an old-style script with `--visualizer newton_rtx`. Kit and OVRTX cannot share a process, so the adapter now skips that visualizer with a warning, as Kit did on develop. - **Newton-based visualizers next to Kit PhysX:** those cases fail on develop too, when Newton builds its model from USD. - **After rebasing onto the latest develop:** the state machines, `bin_packing`, and Cartpole training still run. - **Known pre-existing failure:** `test_visualizer_integration_newton` has a flat-frame check that fails identically on develop. - Pre-commit passes. The changelog check only flags fragments from other PRs, because it compares against the fork's stale `develop`. ## Release backport - [x] <!-- backport-active-release --> Backport this pull request to the active release branch after it merges into `develop` ## Checklist - [x] I have read and understood the contribution guidelines - [x] I have run the pre-commit checks - [x] I have made corresponding changes to the documentation (API pages for `isaaclab.app`, `isaaclab_physx.app`, `isaaclab_ov.app`) - [x] My changes generate no new warnings - [x] I have added changelog fragments for every touched package
…he config (1/2) (#8068) ## Description **Part 1 of 2: the design.** The migration of every script and test is in the stacked follow-up, #8090. This PR keeps existing scripts running unchanged, so the two halves can be reviewed separately. `launch_simulation` now starts each simulation runtime through the launcher that the runtime's own backend package provides. The resolved config says which launcher is needed, so core never imports one. ```python # isaaclab.app: the interface every backend runtime implements class SimulationLauncher: device: str | None = None # optional device the runtime picked def __init__(self, launcher_args): ... # constructing it starts the runtime def close(self, exit_code: int = 0): ... # stops it # backend configs name their launcher, resolved lazily like ``class_type`` class PhysxCfg(PhysicsCfg): launcher_type: ClassVar[str] = "isaaclab_physx.app:KitLauncher" class OVRTXRendererCfg(RendererCfg): launcher_type: ClassVar[str] = "isaaclab_ov.app:OvrtxLauncher" ``` `launch_simulation(cfg, args)` scans the resolved config as it already did and collects `launcher_type` from the physics and renderer config instances it resolved. It constructs each launcher once and closes them in reverse order when the block exits. Kit needs that no config names (`require_kit`, no physics config, a Kit visualizer requested only on the CLI) fall back to `KitLauncher`. - **`isaaclab_physx.app.KitLauncher`** is the old `AppLauncher` body, minus dead code: - removed: argument-collision bookkeeping, the Isaac Sim 5 branch, and the hidden `--cpu` flag; - moved in from `launch_simulation`: the Isaac Sim availability check and the "Kit already running" guard. - **`isaaclab_ov.app.OvrtxLauncher`** registers the OVRTX USD schemas, which `launch_simulation` used to do inline. - **Moved into `sim_launcher.py`** because kitless launches need them too: argv fusing, visualizer argument normalization, and the visualizer-settings sync (no longer wrapped in a blanket `suppress(Exception)`). ### Kit stays in `isaaclab_physx` Core code no longer imports `carb`, `omni`, or `omni.replicator`. Kit concerns go through one of two owners, and no new global hook is added. - **The `SimulationContext` backend registry** owns anything tied to a simulation's lifetime: - `isaaclab_physx.app.KitStageBackend` is registered through `get_or_create_backend` when Kit runs; - it attaches the stage to Kit's USD context and closes Kit's context stage when `clear_instance()` closes the other backends; - core stage utilities never touch Kit: `clear_stage()`/`close_stage()` are Kit-free, and Kit's own consumers (PhysX reset/step, RTX render, the Kit visualizer) run the app updates they need. - **No defensive `None` handling on invariants:** a `SimulationContext` always has a stage, so consumers read `SimulationContext.instance().stage` directly (`SceneDataProvider.usd_stage` / `get_usd_stage` are removed). - **`KitLauncher`** owns one-time process setup: - `SettingsManager.set_backend(carb.settings)`, replacing `initialize_carb_settings` and `is_omniverse_mode`; - sharing Isaac Sim's stage-helper context; - one app update in `close()`, so scripts no longer need their own. - **Replicator** is enabled by the Isaac RTX renderer and seeded by the Replicator event terms that use it. The env classes no longer import it. - **`show_stage_in_viewport`** moves to `isaaclab_physx.app`, since it only works under Kit. - **Gravity:** tasks set it through `PhysxManager.set_gravity` instead of `carb.Float3`. ### Exit handling The ~110-line `_SimulationAppLifecycle` class from #6636 is gone. I measured a real Kit process with no handlers installed, and only two exit paths needed help. Both are now handled by two lines in `KitLauncher`: - An unhandled exception exits with 1. Kit's exit path reported 0. - `SIGINT` raises `KeyboardInterrupt`. Kit's own handler exited 0. `SIGTERM`, `SIGABRT`, and `SIGSEGV` keep their default actions. Fixes #7774, supersedes #7775 and #6531. ### Constructing runtime objects after launch Importing `pxr.Usd` before Kit starts makes Kit fail to start. Scripts therefore import only config classes and construct runtime objects with `instantiate(cfg)` (#8085), which resolves the config's lazy `class_type` after the runtime is up. - `ManagerBasedEnvCfg` and `ManagerBasedRLEnvCfg` gain `class_type`. - The 21 task configs with a custom env class name it. A registry test checks that all 126 match their registered entry point. - **Fixed:** `{DIR}` in an inherited `class_type` resolved against the module of a subclass missing `@configclass`, so the call failed with `ModuleNotFoundError`. ### Compatibility in this PR `isaaclab.app.AppLauncher` is deprecated. It now starts Kit through `launch_simulation`, so develop's scripts and tests run unchanged here. It still offers `is_available`, `has_gui`, and `has_window`, which unmigrated scripts use. The migration PR moves every caller and reduces it to an init-only shim. `isaaclab.test.utils.launch_test_simulation(**launcher_args)` starts Kit for a test module through `launch_simulation`. It picks the test device by default. ### Behavior changes - **Removed** (breaking; each only restated an invariant or forwarded elsewhere): - `sim_utils.update_stage`: the simulation's reset, step, and render process stage changes; - `sim_utils.is_current_stage_in_memory`: compare against `SimulationContext.instance().stage`; - `sim_utils.show_stage_in_viewport`: use `isaaclab_physx.app.show_stage_in_viewport`; - `SettingsManager.initialize_carb_settings` (and the module-level function) and `is_omniverse_mode`: `KitLauncher` sets the settings backend, and `has_kit()` checks for Kit; - `SceneDataProvider.usd_stage` / `get_usd_stage`; - the hidden `--cpu` flag: use `--device cpu`. - **Replicator seeding:** the Replicator event terms seed it with `env.cfg.seed` when they are built; `_get_replicator()` only loads it. Calling `env.seed(x)` later no longer reseeds Replicator. - **Kit startup marker** is now `[ISAACLAB] KitLauncher initialization complete`, and `tools/conftest.py` is updated to match. - **SIGTERM** ends the process immediately, without a Kit teardown. - **Warp environments:** `render_mode="rgb_array"` now warns and returns `None`, matching the core environments. Net: +2,326 / −3,045 across 154 files. ## Type of change - Breaking change (`AppLauncher` deprecated; Kit-coupled helpers removed; Kit exit and seeding behavior changed) ## Validation All runs on the display GPU (GPU 0), with develop's scripts and tests unchanged unless listed here. - **Launcher, app, and config tests:** - `isaaclab/test/app` (26) and `isaaclab_physx/test/app` (88); - `test_runtime_compatibility` (27), visualizer intent (8), distributed device (13), `test_preset_kit_decision` (6), `test_preset_cli` (11); - `test_configclass` (37), `test_sb3_leapp_export`, and the CLI tests (234). - **Kit tests through the deprecated adapter:** - `test_simulation_context` (30), PhysX `test_rigid_object` (44), `test_camera` (21); - stage utils (15), stage in memory (3), `test_events` (4), texture randomization (2), `test_manager_based_env` (4). - **Training:** `train.py --task Isaac-Cartpole --max_iterations 2` exits 0 with `isaacsim_physx` and `newton_mjwarp`. - `physics=physx` (kitless ovphysx) fails with an observation batch mismatch. - Develop `93b6e7432` fails the same way, so it is unrelated to this PR. - **Every script under `scripts/` and `examples/`**, compared against develop with the same invocation: - **Scripts outside the standalone matrix (78):** same outcome on develop and here. 52 run, 19 are blocked by an external resource (datasets, XR, Ray, gr00t, robomimic, moviepy), and 7 fail identically on develop. - **Standalone matrix (361 cases):** no regressions. The only case that first looked new was an old-style script with `--visualizer newton_rtx`. Kit and OVRTX cannot share a process, so the adapter now skips that visualizer with a warning, as Kit did on develop. - **Newton-based visualizers next to Kit PhysX:** those cases fail on develop too, when Newton builds its model from USD. - **After rebasing onto the latest develop:** the state machines, `bin_packing`, and Cartpole training still run. - **Known pre-existing failure:** `test_visualizer_integration_newton` has a flat-frame check that fails identically on develop. - Pre-commit passes. The changelog check only flags fragments from other PRs, because it compares against the fork's stale `develop`. ## Release backport - [x] <!-- backport-active-release --> Backport this pull request to the active release branch after it merges into `develop` ## Checklist - [x] I have read and understood the contribution guidelines - [x] I have run the pre-commit checks - [x] I have made corresponding changes to the documentation (API pages for `isaaclab.app`, `isaaclab_physx.app`, `isaaclab_ov.app`) - [x] My changes generate no new warnings - [x] I have added changelog fragments for every touched package (cherry picked from commit c9f9e22)
Summary
AppLauncherprocess-lifecycle handling into one nested_SimulationAppLifecycleclass: startup announcements (CI marker, Kit version diagnostics) plus the entire exit-path policy, with the policy table as the class docstring.NCCL_CUMEM_HOST_ENABLE=0first,NCCL_CUMEM_ENABLE=0as fallback).SimulationAppexit-status fix (public reference: Preserve nonzero exit status through fast-shutdown close IsaacSim#717) has been merged (isaacsim.simulation_app>= 2.18.5): the signal handler now simply passesclose(exit_code=128 + signum)— full teardown + truthful status on fixed builds, truthful status on older builds. The one remainingWORKAROUND(isaac-sim)is the SIGINT re-registration (upstream handler still exits 0 before user code unwinds); it fails loudly if drift disables it.close(exit_code=128 + signum)(full Kit teardown onisaacsim.simulation_app>= 2.18.5) or dies by the re-raised signal, so distributed workers terminate with a truthful status instead of surviving and spamming TCPStoreBroken pipeerrors.Failure cases and how this PR addresses them
Root mechanism: Kit fast shutdown terminated the process with exit code 0 from inside
SimulationApp.close(), so any death funneled through an unqualifiedclose()was reported as success; additionally, the abort-signal handler was unguarded against re-entrancy.sys.last_excdetected; absorbed from #6634;SystemExitdocumented as not yet covered)kill)close(exit_code=128 + signum): full teardown + truthful status onisaacsim.simulation_app>= 2.18.5; truthful status on older builds; dies by the signal ifclose()returnsclose()→ infinite recursion → SIGKILL-only shutdown, spurious SIGSEGV, logs flooded (~975 recursion frames/job observed on OSMO pods)SIG_DFLkill -ABRTfinally/KeyboardInterruptcode runsKeyboardInterruptunwinds user code, nonzero exitNot addressed here (tracked elsewhere):
sys.exit(N)/SystemExitstill exits 0 (gap inside the #6634 mechanism, documented at the detection site).Implementation notes
AppLauncher._SimulationAppLifecycle; the class docstring is the policy table, and each decision carries its rationale in place.close(exit_code=128 + signum). With the merged upstream fix (isaacsim.simulation_app>= 2.18.5) the app performs its full teardown and exits with that status; on older builds the status is preserved without the teardown; ifclose()returns (fast shutdown disabled), the handler re-raises with the default action. ATypeErrorfallback warns loudly if a futureSimulationAppdrops the parameter.Testing. Six kitless unit tests (
test_simulation_app_lifecycle.py: killed-by-signal status, re-entrancy both directions, exit-code selection, drift fallbacks on both paths) plus two real-Kit integration tests (test_app_launcher_exit_status.py: SIGTERM → truthful termination status with no handler recursion; unhandled exception → exits 1). The integration tests pass against both the pre-fix and the fixed (>= 2.18.5)SimulationAppbuilds; on develop's original behavior the SIGTERM test observes exit code 0 (the bug).Type of change
Checklist
pre-commitchecks with./isaaclab.sh --formatsource/<pkg>/changelog.d/for every touched package (do not editCHANGELOG.rstor bumpextension.toml— CI handles that)CONTRIBUTORS.mdor my name already exists there