Repository navigation
[Core] Fix Kit crashing at startup when moviepy is installed - #8231
Conversation
The import hoist in isaac-sim#8125 moved multi_agent_to_single_agent to the top of isaaclab_rl.entrypoints.common, which imports isaaclab.envs.direct_marl_env and, through the video recorder, moviepy, SciPy, OpenCV and matplotlib before Kit starts. With moviepy installed, OpenBLAS's at-fork handler then crashes Kit's platform-info fork during startup (3/3 runs, against 0/3 before isaac-sim#8125). Import it where the environment is wrapped, after the launch, and keep torch local to the distributed-device path as KitLauncher documents.
|
run-ci |
|
| return | ||
|
|
||
| # torch loads NumPy/OpenBLAS, whose at-fork handlers can crash Kit's platform-info fork during startup | ||
| import torch # noqa: PLC0415 |
There was a problem hiding this comment.
Distributed launches import torch early
With --distributed and an Isaac Sim/Kit configuration, launch_simulation calls _resolve_distributed_device before it starts Kit. This line therefore still imports torch before Kit starts, leaving distributed runs exposed to the NumPy/OpenBLAS startup-fork crash this PR aims to prevent.
| if convert_marl_to_single_agent and isinstance(env.unwrapped.cfg, DirectMARLEnvCfg): | ||
| # imports the environment runtime and its video recorder (moviepy, SciPy), whose OpenBLAS at-fork handlers | ||
| # can crash Kit's startup fork, so it must not load before the launch | ||
| from isaaclab.envs import multi_agent_to_single_agent # noqa: PLC0415 |
There was a problem hiding this comment.
Import order lacks regression coverage
This fix relies on importing common without loading the environment runtime, but the existing import-isolation tests do not import common or check for moviepy and SciPy. A subprocess test for those imports would catch an eager import being restored; without it, the startup crash could return unnoticed.
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
There was a problem hiding this comment.
Isaac Lab Review Bot
The import deferrals preserve the existing execution paths while avoiding heavyweight dependencies before Kit startup. One style cleanup remains: remove the unnecessary # noqa: PLC0415 suppressions, which are inconsistent with equivalent deferred imports already present in the file.
- Design and architecture: Deferring
multi_agent_to_single_agentto the MARL conversion branch andtorchto distributed-device resolution follows the repository pattern for runtime-dependent imports. No new abstraction or ownership boundary is introduced. - API: The signatures, defaults, return behavior, and owning-module exports remain unchanged. The conversion helper is still imported from
isaaclab.envsat its point of use. - Compatibility and deprecation: Breaking changes: none identified. The changed imports affect initialization timing rather than the documented entry-point contracts, and the symbols remain available from their owning modules.
- Implementation: The deferred imports precede their uses on the relevant branches:
torchis loaded only after distributed mode is selected, andmulti_agent_to_single_agentis loaded only when the created environment requires MARL conversion. The control flow remains otherwise unchanged. - Style consistency: The rationale comments document the non-obvious startup constraint. However, the new
# noqa: PLC0415markers are inconsistent with sibling deferred imports such asWarpFrontendand the pretrained-checkpoint utilities, which need no suppression. Remove both new markers while retaining the rationale comments. - Test quality: No test files changed, so there were no added cases to audit for necessity, ownership, or duplication. The PR reports validation through the existing entry-point, common-entry-point, and distributed-device-resolution suites.
Minor fixes needed. Posted 1 actionable finding inline.
Automated review; human maintainers own approval decisions.
| if convert_marl_to_single_agent and isinstance(env.unwrapped.cfg, DirectMARLEnvCfg): | ||
| # imports the environment runtime and its video recorder (moviepy, SciPy), whose OpenBLAS at-fork handlers | ||
| # can crash Kit's startup fork, so it must not load before the launch | ||
| from isaaclab.envs import multi_agent_to_single_agent # noqa: PLC0415 |
There was a problem hiding this comment.
🔵 Suggestion · Style Consistency — noqa marker inconsistent with sibling deferred imports
The two other deferred imports in this same file (WarpFrontend at line 500 and pretrained_checkpoint at line 542) carry only a rationale comment and no # noqa: PLC0415, so the rule is evidently not enforced here and the new suppression is inert. Drop the # noqa: PLC0415 here and on the matching import torch in sim_launcher.py, keeping the explanatory comments.
|
run-ci |
Description
Fixes the Kit startup crash introduced by #8125 when MoviePy is installed. Importing the RL entrypoints pulled in the environment runtime and
moviepy.editor, including unrelated editing dependencies, before Kit launched.ImageSequenceClipdirectly in the recorder instead of loadingmoviepy.editor. This preserves recording without importing SciPy, OpenCV, or matplotlib.There are no launcher or distributed-device changes. Torch remains available before Kit; moving one import did not change that boundary.
Validation
Isaac-Cartpole-Direct, Isaac PhysX, 16 environments, one RSL-RL training iteration completed. A second run with the environment/video recorder deliberately imported before Kit also completed.Release backport
developChecklist