Skip to content

Fix option-like --kit_args values failing argparse on all entry points - #6363

Merged
hujc7 merged 6 commits into
isaac-sim:developfrom
hujc7:jichuanh/fix-kit-args-forwarding
Jul 8, 2026
Merged

hujc7 merged 6 commits into
isaac-sim:developfrom
hujc7:jichuanh/fix-kit-args-forwarding

Conversation

@hujc7

@hujc7 hujc7 commented Jul 6, 2026 •

Copy link
Copy Markdown
Collaborator

Problem

--kit_args "--ext-folder=/path/to/ext"       # exit 2: "argument --kit_args: expected one argument"
--kit_args=--ext-folder=/path/to/ext         # worked
--kit_args "--ext-folder=/a --ext-folder=/b" # worked

argparse rejects a value token that looks like an option (--prefixed, no space) — and Kit args always start with --. Affects every entry point.

Fix

Two normalization points, sharing one fusing helper that rewrites
["--kit_args", "--ext-folder=/path/to/ext"] into ["--kit_args=--ext-folder=/path/to/ext"]:

  1. AppLauncher.add_app_launcher_args fuses the pair in sys.argv before any parsing. Covers every script that parses sys.argv: demos, tutorials, tools, benchmarks, and the per-library play scripts.
  2. dispatch_library_entrypoint applies the same fusing to the explicit argv list it forwards to the per-library train/play scripts. Those scripts parse that list (not sys.argv), so the sys.argv normalization alone never reached the unified train command or the multi-GPU ranks (each child rank runs through the dispatcher).

Already-working forms are unchanged: a guard test asserts the equals-attached, quoted multi-token, and plain-flag forms are forwarded byte-identical.

Tests: 17 in source/isaaclab/test/cli/test_train_multigpu_command_building.py. 12 fail with the AppLauncher fusing reverted; the dispatcher regression test fails with the dispatcher fusing reverted. Verified end-to-end: cartpole training via train --rl_library rsl_rl ... --kit_args "--ext-folder=..." (previously exit 2) now trains to completion, and the same command without --kit_args behaves identically to before.

Type of change

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

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 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)
  • I have added my name to the CONTRIBUTORS.md or my name already exists there

hujc7 added 3 commits July 6, 2026 00:46
The multi-GPU launcher forwards unrecognized arguments to the child
train.py verbatim. Kit arguments always start with "--", so the
space-separated form --kit_args "--foo=/bar" arrived as two tokens
and the child's argparse rejected the option-like value token with
"expected one argument", exiting with code 2 on every rank.

Fuse ["--kit_args", <value>] pairs into a single --kit_args=<value>
token when building the torchrun and skrl JAX commands, and document
the "="-attached form in AppLauncher's --kit_args help since direct
single-process invocations hit the same argparse behavior.
Cover fusing the space-separated form into --kit_args=<value> on both
the torchrun and skrl JAX paths, pass-through of the "="-attached and
multi-token forms, acceptance of the forwarded arguments by the
training script's argparse spec, and --dry_run output parsing. The
tests run without a GPU or Isaac Sim installation.
@hujc7
hujc7 requested review from kellyguo11 and ooctipus as code owners July 6, 2026 07:58
@github-actions github-actions Bot added bug Something isn't working isaac-lab Related to Isaac Lab team labels Jul 6, 2026
@greptile-apps

greptile-apps Bot commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR fixes a bug where passing a single Kit argument in space-separated form (e.g. --kit_args "--ext-folder=/path") to the multi-GPU training launcher caused every rank to exit immediately with argparse error "expected one argument". The root cause is that argparse refuses to consume a value token starting with -- (no embedded space) when using the default nargs=None, so the two-token form ["--kit_args", "--ext-folder=..."] was always rejected at the child process level.

  • Adds _with_fused_kit_args helper that rewrites any ["--kit_args", <value>] pair in the forwarded train_args list into a single --kit_args=<value> token, applied on both the torchrun and skrl JAX launcher paths before the child command is built; the =-attached and multi-option forms pass through unchanged.
  • Updates the --kit_args help text and docstring in app_launcher.py to document the =-attached form as the reliable spelling for a single option-like value.
  • Adds a new GPU-free test file with six targeted regression cases covering all forwarding variants and confirming the child argparse accepts the fused token.

Confidence Score: 5/5

Safe to merge — the change is a targeted, well-tested one-function addition with no impact on execution paths that do not involve --kit_args.

The helper is narrow in scope, both affected command-building paths receive the same treatment, and six GPU-free regression tests cover all relevant variants including child argparse acceptance.

No files require special attention.

Important Files Changed

Filename Overview
scripts/reinforcement_learning/train_multigpu.py Adds _with_fused_kit_args helper and applies it in both _build_torchrun_command and _build_skrl_jax_command to fuse the two-token form ["--kit_args", "--opt=val"] into a single --kit_args=--opt=val token before child argparse sees it.
source/isaaclab/test/cli/test_train_multigpu_command_building.py New test file covering space-separated fusion (torchrun and skrl JAX paths), equals-attached passthrough, multi-token passthrough, child-argparse acceptance, and dry-run output — all runnable without GPU or Isaac Sim.
source/isaaclab/isaaclab/app/app_launcher.py Documentation-only change: adds a note to the --kit_args help text and docstring pointing users to the =-attached form for single option-like values.
source/isaaclab/changelog.d/jichuanh-fix-kit-args-forwarding.rst New changelog fragment accurately describing the bug and the fix.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A["User: train_multigpu.py\n--kit_args --ext-folder=/path"] --> B["_parse_args()\nparse_known_args"]
    B --> C["train_args =\n['--kit_args', '--ext-folder=/path']"]
    C --> D["_build_distributed_command()"]
    D --> E{Is skrl JAX?}
    E -- No --> F["_build_torchrun_command()"]
    E -- Yes --> G["_build_skrl_jax_command()"]
    F --> H["_with_fused_kit_args(train_args)\nBEFORE: ['--kit_args', '--ext-folder=/path']\nAFTER: ['--kit_args=--ext-folder=/path']"]
    G --> H
    H --> I["_with_distributed_arg()\nadds --distributed"]
    I --> J["Child train.py command\n--kit_args=--ext-folder=/path --distributed"]
    J --> K["AppLauncher argparse\nAccepts --kit_args=value"]
Loading
%%{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["User: train_multigpu.py\n--kit_args --ext-folder=/path"] --> B["_parse_args()\nparse_known_args"]
    B --> C["train_args =\n['--kit_args', '--ext-folder=/path']"]
    C --> D["_build_distributed_command()"]
    D --> E{Is skrl JAX?}
    E -- No --> F["_build_torchrun_command()"]
    E -- Yes --> G["_build_skrl_jax_command()"]
    F --> H["_with_fused_kit_args(train_args)\nBEFORE: ['--kit_args', '--ext-folder=/path']\nAFTER: ['--kit_args=--ext-folder=/path']"]
    G --> H
    H --> I["_with_distributed_arg()\nadds --distributed"]
    I --> J["Child train.py command\n--kit_args=--ext-folder=/path --distributed"]
    J --> K["AppLauncher argparse\nAccepts --kit_args=value"]
Loading

Reviews (1): Last reviewed commit: "Add changelog fragment for --kit_args fo..." | Re-trigger Greptile

Move the --kit_args fix from the multi-GPU launcher into
AppLauncher.add_app_launcher_args: fuse ["--kit_args", "<option-like
value>"] pairs in sys.argv into single --kit_args=<value> tokens before
any parsing. Argparse rejects a value token that looks like an option
(dash-prefixed, no space), so the documented space-separated form failed
for a single Kit argument on every entry point, not only the multi-GPU
forwarding path. Normalizing at the argument's owner fixes direct and
forwarded invocations alike; the launcher-side fuse is removed as
redundant and the launcher now forwards tokens verbatim.
@hujc7 hujc7 changed the title Fix --kit_args forwarding in multi-GPU training launcher Fix option-like --kit_args values failing argparse on all entry points Jul 6, 2026
hujc7 added 2 commits July 7, 2026 16:50
The unified train.py/play.py dispatcher hands each per-library script
an explicit argv list copied from sys.argv before any AppLauncher code
runs, and the per-library scripts parse that list rather than sys.argv.
The sys.argv normalization in add_app_launcher_args therefore never
reached the unified train command or the multi-GPU child ranks, which
still failed with "argument --kit_args: expected one argument".

Apply the same fusing to the dispatcher's argv list before forwarding.
Covered by a stub-entrypoint regression test that fails without the fix
and a guard test asserting already-working argv forms are forwarded
unchanged.
@hujc7
hujc7 merged commit 86492c9 into isaac-sim:develop Jul 8, 2026
37 checks passed
hujc7 added a commit to hujc7/IsaacLab that referenced this pull request Jul 8, 2026
Re-sync onto latest develop (adds isaac-sim#6431 rendering-test timeout bump, isaac-sim#5730,
isaac-sim#6363, OVPhysX test enablement). Keep device_scope test_devices() migration
in test_rigid_object.py over develop's cpu/cuda:0 list.
matthewtrepte pushed a commit to matthewtrepte/IsaacLab that referenced this pull request Aug 4, 2026
isaac-sim#6363)

## Problem

```bash
--kit_args "--ext-folder=/path/to/ext"       # exit 2: "argument --kit_args: expected one argument"
--kit_args=--ext-folder=/path/to/ext         # worked
--kit_args "--ext-folder=/a --ext-folder=/b" # worked
```

argparse rejects a value token that looks like an option (`-`-prefixed,
no space) — and Kit args always start with `--`. Affects every entry
point.

## Fix

Two normalization points, sharing one fusing helper that rewrites
`["--kit_args", "--ext-folder=/path/to/ext"]` into
`["--kit_args=--ext-folder=/path/to/ext"]`:

1. `AppLauncher.add_app_launcher_args` fuses the pair in `sys.argv`
before any parsing. Covers every script that parses `sys.argv`: demos,
tutorials, tools, benchmarks, and the per-library play scripts.
2. `dispatch_library_entrypoint` applies the same fusing to the explicit
argv list it forwards to the per-library train/play scripts. Those
scripts parse that list (not `sys.argv`), so the `sys.argv`
normalization alone never reached the unified `train` command or the
multi-GPU ranks (each child rank runs through the dispatcher).

Already-working forms are unchanged: a guard test asserts the
equals-attached, quoted multi-token, and plain-flag forms are forwarded
byte-identical.

Tests: 17 in
`source/isaaclab/test/cli/test_train_multigpu_command_building.py`. 12
fail with the `AppLauncher` fusing reverted; the dispatcher regression
test fails with the dispatcher fusing reverted. Verified end-to-end:
cartpole training via `train --rl_library rsl_rl ... --kit_args
"--ext-folder=..."` (previously exit 2) now trains to completion, and
the same command without `--kit_args` behaves identically to before.

## Type of change

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

## 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
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.

2 participants