Skip to content

feat(cli): unify quant/optimize/analyze/max-optim flags across build, config, perf, eval#923

Merged
xieofxie merged 2 commits into
mainfrom
hualxie/unify-build-pipeline-flags
Jun 23, 2026
Merged

feat(cli): unify quant/optimize/analyze/max-optim flags across build, config, perf, eval#923
xieofxie merged 2 commits into
mainfrom
hualxie/unify-build-pipeline-flags

Conversation

@xieofxie

Copy link
Copy Markdown
Contributor

Summary

Unifies the five build-pipeline CLI flags — --quant/--no-quant, --optimize/--no-optimize, --analyze/--no-analyze, and --max-optim-iterations — across build, config, perf, and eval so they share one definition and identical semantics, defined in utils/cli.py.

Shared helpers (utils/cli.py)

  • quant_option()--quant/--no-quant, with --quantize/--no-quantize kept as an alias so existing perf invocations keep working.
  • optimize_option()--optimize/--no-optimize
  • analyze_option()--analyze/--no-analyze
  • max_optim_iterations_option()--max-optim-iterations
  • build_pipeline_extra_kwargs() centralizes the (optimize, analyze, max_optim_iterations)(skip_optimize, hack_max_optim_iterations) mapping shared by build/perf/eval.

Per-command changes

Command Change
build Refactored to use the shared helpers (behavior unchanged).
perf --quantize → canonical --quant (alias retained); optimize/analyze/max-optim added and plumbed through BenchmarkConfig, the single-model load path, and the per-module build path.
eval quant/optimize/analyze/max-optim added to WinMLEvaluationConfig and applied in _load_model.
config Flags added for CLI parity; the build-only flags warn when passed, since config only emits a static config.

Plumbing fix

WinMLAutoModel.from_pretrained now forwards skip_optimize / hack_max_optim_iterations to build_hf_model so the HF build path honors these flags (from_onnx already forwarded them).

Testing

  • tests/unit/utils/test_cli.py — new coverage for the four option helpers (incl. the --quantize alias) and build_pipeline_extra_kwargs.
  • tests/unit/commands/test_boolean_flag_pairs.py — updated to the unified surface (canonical --quant + alias, new flags on config/perf/eval).
  • tests/unit/eval/test_eval.py — updated _load_model call assertion + new test that --no-quant/--no-optimize/--max-optim-iterations reach from_pretrained.
  • Ran tests/unit/commands, tests/unit/eval, tests/unit/utils/test_cli.py, tests/unit/optracing, tests/regression/test_design_gaps.py — all green.

… config, perf, eval

Add shared Click option decorators in utils/cli.py so the build-pipeline
toggles share one definition and identical semantics across commands:

- quant_option() -> --quant/--no-quant, with --quantize/--no-quantize kept
  as an alias (perf previously used --quantize; existing invocations keep
  working)
- optimize_option() -> --optimize/--no-optimize
- analyze_option() -> --analyze/--no-analyze
- max_optim_iterations_option() -> --max-optim-iterations
- build_pipeline_extra_kwargs() centralizes the (optimize, analyze,
  max_optim_iterations) -> (skip_optimize, hack_max_optim_iterations)
  mapping shared by build/perf/eval

All four commands now expose the full set:

- build: refactored to use the shared helpers (behavior unchanged)
- perf: --quantize renamed to --quant (alias retained); optimize/analyze/
  max-optim added and plumbed through BenchmarkConfig and the per-module
  build path
- eval: quant/optimize/analyze/max-optim added to WinMLEvaluationConfig and
  applied in _load_model
- config: flags added for CLI parity; the build-only flags warn when passed
  since config only emits a static config

WinMLAutoModel.from_pretrained now forwards skip_optimize /
hack_max_optim_iterations to build_hf_model so the HF build path honors these
flags (from_onnx already forwarded them).
@xieofxie xieofxie requested a review from a team as a code owner June 22, 2026 01:09
`winml config` only emits a static WinMLBuildConfig and never runs the build
pipeline, so --optimize/--analyze/--max-optim-iterations had no effect there.
Remove them (and the accompanying "ignored" warning) so config exposes only
the flags that change its output: --quant/--no-quant and --compile/--no-compile.
The other three remain on build/perf/eval, which do run the pipeline.

@DingmaomaoBJTU DingmaomaoBJTU left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall the PR is well-structured and correct. build_pipeline_extra_kwargs is a clean centralization that eliminates the per-command duplication and makes the flag→kwarg mapping testable. The --quantize alias on perf and all the new eval wiring looks right. All 175 affected unit tests pass. Two minor nits follow.

Comment thread src/winml/modelkit/utils/cli.py
Comment thread src/winml/modelkit/eval/evaluate.py
@xieofxie xieofxie merged commit b448652 into main Jun 23, 2026
9 checks passed
@xieofxie xieofxie deleted the hualxie/unify-build-pipeline-flags branch June 23, 2026 05:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants