Skip to content

fix(ptx-schedule): the usage string omits the --output spelling it accepts - #1109

Merged
nihalpasham merged 1 commit into
NVIDIA:mainfrom
vyncint:fix/ptx-schedule-usage-output-flag
Aug 21, 2026
Merged

nihalpasham merged 1 commit into
NVIDIA:mainfrom
vyncint:fix/ptx-schedule-usage-output-flag

Conversation

@vyncint

@vyncint vyncint commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

main.rs parses the output path as "-o" | "--output", but its usage line shows only [-o OUTPUT]:

usage: ptx-schedule INPUT.ptx [--list-sites] [--seed N] [--intensity F]
       [--max-sleep-ns N] [--focus TEXT] [-o OUTPUT] [--decisions-json FILE]

Every other flag the loop accepts appears there, so --output is the one working spelling a reader cannot discover. Nothing is broken — both forms work — but this usage text is the only help the binary has, since it hand-rolls its argument parsing rather than deriving --help from clap.

Name both, as the match arm does.

The rest of the tree is clean on this

I compared every hand-written usage string's flags against the flags its parser accepts. ptx-schedule was the only real mismatch:

  • smoketest.sh documents all eight of its flags.
  • The cargo-oxide and cuda-intrinsics-gen binaries derive help from clap, so there is no hand-written string to drift from.
  • The --output-file / --verbose / --version strings in cuda-artifact-finalizer are arguments it passes to ptxas, not flags of its own.

Verified: the documented set and the parsed set are now equal in both directions; fmt clean, clippy --all-targets -- -D warnings clean, and the crate's 9 tests pass.

…cepts

`main.rs` parses the output path as `"-o" | "--output"`, but its usage line
shows only `[-o OUTPUT]`:

    usage: ptx-schedule INPUT.ptx [--list-sites] [--seed N] [--intensity F]
           [--max-sleep-ns N] [--focus TEXT] [-o OUTPUT] [--decisions-json FILE]

Every other flag the loop accepts appears there, so `--output` is the one
working spelling a reader cannot discover. Nothing is broken -- both forms work
-- but the usage text is the only help this binary has, since it hand-rolls its
argument parsing rather than deriving `--help` from clap.

Name both, as the arm does.

Checked the rest of the tree for the same gap: comparing every flag a
hand-written usage string documents against the flags its parser accepts,
`ptx-schedule` was the only real mismatch. `smoketest.sh` documents all eight
of its flags; the `cargo-oxide` and `cuda-intrinsics-gen` binaries derive help
from clap, so there is no hand-written string to drift; and the `--output-file`
/ `--verbose` / `--version` strings in `cuda-artifact-finalizer` are arguments
it passes to ptxas, not flags of its own.

Verified: the documented set and the parsed set are now equal in both
directions; fmt clean, `clippy --all-targets -- -D warnings` clean, and the
crate's 9 tests pass.

Signed-off-by: Vyncint Ng <[email protected]>
@nihalpasham

Copy link
Copy Markdown
Collaborator
  • Verified bidirectional parity: the seven documented flags equal the seven parser arms in main.rs, including the restored --output spelling; nothing asserts the old string.
  • One pre-existing nit, out of scope here: the brackets mark the flag optional, but outside --list-sites the output path is required (main.rs exits with the usage message when it is missing). Candidate for a later polish pass.

@nihalpasham nihalpasham added bug Something isn't working fuzzer Fuzzing infrastructure (rustlantis, difftest) labels Aug 21, 2026
@nihalpasham
nihalpasham merged commit 7b481af into NVIDIA:main Aug 21, 2026
50 checks passed
nihalpasham added a commit that referenced this pull request Aug 23, 2026
…#1136)

* fix(ptx-schedule): the usage line brackets an option the CLI requires

#1109's review flagged this: the brackets mark `-o|--output` optional, but
outside `--list-sites` the output path is required, and the binary exits with
the usage message when it is missing.

    ptx-schedule INPUT.ptx [--list-sites] ... [-o|--output OUTPUT] ...

One bracketed list cannot state this CLI's shape. `--output` is required to
perturb and meaningless when listing, so bracketing it is wrong in one mode and
misleading in the other. It becomes one line per invocation form, which is what
`cuda-intrinsics-gen`'s usage text already does for the same reason:

    usage:
      ptx-schedule INPUT.ptx --list-sites
            print the schedule-sensitive sites as JSON; the options below are ignored
      ptx-schedule INPUT.ptx -o|--output OUTPUT [--seed N] [--intensity F]
            [--max-sleep-ns N] [--focus TEXT] [--decisions-json FILE]
            write a perturbed copy of INPUT.ptx to OUTPUT

The second half of the same problem: every way to get the command line wrong
printed the identical block with nothing said about which way. `usage_because`
prefixes the reason, and the six copies of `args.next().unwrap_or_else(|| usage())`
-- each meaning "this flag needs a value", none saying so -- become one
`next_value` helper that names the flag. Before, all four of these printed the
same wall of text; now:

    ptx-schedule                          error: an input PTX file is required
    ptx-schedule x.ptx --seed             error: --seed needs a value
    ptx-schedule x.ptx --bogus            error: unrecognized argument "--bogus"
    ptx-schedule x.ptx --seed 7           error: -o|--output is required unless --list-sites is given

Exit code stays 2 in every case, and both working forms are unchanged --
verified against a real module: `--list-sites` prints the JSON, and
`--seed 7 -o out.ptx` reports `sites=2 injected=2`.

Two tests. The first turns #1109's hand-checked parity into an assertion: the
usage text names exactly the long flags the parser accepts, both directions,
reading the arms out of the source (an arm can name two spellings, `"-o" |
"--output"`, so it takes every quoted flag on the line). The second pins the
shape this PR is about -- `--output` is not bracketed on the form that requires
it, and does not appear on the listing form. They fail respectively when a flag
is dropped from the text and when the brackets are put back.

The README needs no change: its two examples are already the two forms, one
with `-o` and one without.

Verified: 16 tests pass, fmt clean, `clippy --all-targets -- -D warnings`
clean, `cargo doc --document-private-items` clean.

Signed-off-by: Vyncint Ng <[email protected]>

* fix(ptx-schedule): parse exclusive modes with clap

Model list and rewrite as exclusive modes, reject malformed commands before file access, and exercise both valid forms through the binary.

Signed-off-by: nihalp <[email protected]>

---------

Signed-off-by: Vyncint Ng <[email protected]>
Signed-off-by: nihalp <[email protected]>
Co-authored-by: nihalp <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working fuzzer Fuzzing infrastructure (rustlantis, difftest)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants