Skip to content

fix(cli): drop unreachable guards in validate_pipeline_parallel_args - #2532

Merged
inureyes merged 5 commits into
mainfrom
fix/issue-1131-pp-validator-dead-guards
Oct 22, 2026
Merged

inureyes merged 5 commits into
mainfrom
fix/issue-1131-pp-validator-dead-guards

Conversation

@inureyes

@inureyes inureyes commented Oct 22, 2026 •

Copy link
Copy Markdown
Member

Closes #1131

Implements reading (a) from the maintainer comment on #1131: TP-only (--tp-size > 1 with PP off) is a shipped path and stays accepted. The set of accepted and rejected inputs is unchanged; only two messages that could never be emitted are gone.

  • Removed two unreachable ensure!s in validate_pipeline_parallel_args. The "2D parallelism requires --pp-size >= 2" check was the exact negation of the early return above it. The --pp-size must be at least 2 else arm only ran with pp_layers == None, where the early return already guarantees pp_size >= 2; it is not named in the issue but falls under the "no unreachable branch" criterion.
  • Kept the total_ranks > 0 check, simplified to the equivalent pp_size > 0 with the same message. It is reachable: --pp-size 0 --pp-layers "0-3,4-7" --tp-size 2 passes the early return. The issue body assumed pp_size >= 1 there, but --pp-size is an unrestricted usize.
  • Tests: renamed ..._rejects_2d_without_pp_enabled to ..._accepts_tp_only_when_pp_disabled and ..._requires_two_stages_without_manual_ranges to ..._accepts_single_stage_and_manual_ranges, since both always asserted is_ok(). Added tests that reach every remaining check: the pp_size 0 topology error, --pp-micro-batch-size 0, an empty --pp-layers, and multimodal input under PP.
  • The flag-names-in-error-strings invariant already exists on main as every_flag_named_in_command_source_exists_in_some_help in tests/cli_help_consistency.rs (from test: assert every flag named in src/commands exists in some --help #1604, checked against the union of all subcommand helps and flag-surface dumps), so no duplicate was added. A stricter per-command variant was evaluated with a throwaway script (each command source's string-literal --flag tokens against its own subcommand's help: generate*.rs against generate, serve.rs against serve incl. --dump-flag-surface, and the other single-subcommand sources against their own). It found no real gaps, so no new test was added and no stale flag needed fixing.

Validation (test-fast profile, default features): cargo test -p mlxcel --bin mlxcel validate_pipeline_parallel (7 passed), cargo test --test cli_help_consistency (27 passed), cargo clippy -p mlxcel --bin mlxcel --tests -- -D warnings (clean), cargo fmt --check on touched files (clean).

Unverified: CI results.

The maintainer decision on #1131 is reading (a): TP-only (`--tp-size > 1` with PP off) is a supported path and stays accepted. Two ensures in the validator could never fail: the "2D parallelism requires --pp-size >= 2" check, which is the exact negation of the early return above it, and the `--pp-size must be at least 2` else arm, which only runs when the early return already guaranteed pp_size >= 2.

The `total_ranks > 0` check is kept because it is reachable (`--pp-size 0 --pp-layers 0-3,4-7 --tp-size 2`); it is simplified to `pp_size > 0` with an accurate comment. The misnamed test is renamed to match its assertion and a new test pins the reachable inconsistent-topology branch.

Refs #1131
Formatting only; no behavior change. Refs #1131
@inureyes inureyes added status:review Under review type:bug Bug fixes, error corrections, or issue resolutions priority:low Low priority labels Oct 22, 2026
validate_pipeline_parallel_args_requires_two_stages_without_manual_ranges has asserted is_ok() on every input since it was added, and its name described the `--pp-size must be at least 2` else arm this PR removes as unreachable. Rename it to validate_pipeline_parallel_args_accepts_single_stage_and_manual_ranges and add a comment saying why each case is accepted, so no test name in the file contradicts its assertions.

Validated with the test-fast validate_pipeline_parallel unit tests (6 passed), the cli_help_consistency suite (27 passed), and clippy on the bin with tests (clean).

Refs #1131
validate_pipeline_parallel_args had no test reaching the --pp-micro-batch-size zero check, the empty --pp-layers check, or the text-only (image/audio/video) check. One new test now exercises each and asserts on the error message.

Validation:
- cargo test --profile test-fast -p mlxcel --bin mlxcel validate_pipeline_parallel: 7 passed
- cargo test --profile test-fast --test cli_help_consistency: 27 passed
- clippy -D warnings (bin + tests) and cargo fmt --check clean

Refs #1131
@inureyes inureyes added status:done Completed and removed status:review Under review labels Oct 22, 2026
@inureyes
inureyes merged commit be1c4bc into main Oct 22, 2026
54 of 55 checks passed
@inureyes
inureyes deleted the fix/issue-1131-pp-validator-dead-guards branch October 22, 2026 10:22
@inureyes inureyes added this to the 0.8 milestone Nov 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

priority:low Low priority status:done Completed type:bug Bug fixes, error corrections, or issue resolutions

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(cli): unreachable 2D-parallelism guard in validate_pipeline_parallel_args, decide whether to delete it or widen the early return

1 participant