-
Notifications
You must be signed in to change notification settings - Fork 5
feat: Add export override options to winml eval command #1141
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -253,7 +253,9 @@ def _load_model(config: WinMLEvaluationConfig) -> WinMLPreTrainedModel | WinMLCo | |
|
|
||
| if config.model_path is not None: | ||
| # Pre-built ONNX: precision is already baked into the model and is | ||
| # ignored here (mirrors winml perf's ONNX path). | ||
| # ignored here (mirrors winml perf's ONNX path). Export overrides / | ||
| # shape_config are HuggingFace-export concepts and never reach here — | ||
| # the CLI warns and drops them for pre-built ONNX inputs. | ||
| from transformers import AutoConfig | ||
|
|
||
| hf_config = AutoConfig.from_pretrained(config.model_id) | ||
|
|
@@ -270,14 +272,28 @@ def _load_model(config: WinMLEvaluationConfig) -> WinMLPreTrainedModel | WinMLCo | |
| model.config = hf_config | ||
| return model | ||
|
|
||
| # HuggingFace build path — export overrides (--input-specs/--export-config/ | ||
| # --dynamic-axes) are merged under the build config's ``export`` section as a | ||
| # sparse dict so from_pretrained routes them through merge_export_overrides | ||
| # (patching auto-resolved input_tensors by name / re-deriving dynamic_axes). | ||
| # Passing a dict rather than a WinMLBuildConfig avoids clobbering the | ||
| # auto-resolved export config with default fields. Mirrors winml build/perf. | ||
| build_override: Any = quant_override | ||
| if config.export_overrides: | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Updated todo list Here's a PR-ready comment: Review: input option precedenceI checked the implementation against the intended precedence order: CLI explicit > config-file explicit > CLI default > config-class default The four new flags ( ✅ What's correct
❌ Precedence bug:
|
||
| override_dict: dict[str, Any] = {"export": config.export_overrides} | ||
| if not config.quant: | ||
| override_dict["quant"] = None | ||
| build_override = override_dict | ||
|
|
||
| return WinMLAutoModel.from_pretrained( | ||
| config.model_id, | ||
| task=config.task, | ||
| device=config.device, | ||
| precision=config.precision, | ||
| ep=config.ep, | ||
| allow_unsupported_nodes=config.allow_unsupported_nodes, | ||
| config=quant_override, | ||
| config=build_override, | ||
| shape_config=config.shape_config, | ||
| **pipeline_kwargs, | ||
| ) | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
An optional suggestion: as we are having more and more options, do you think they can be wrapped into a single "--additional-options" for all those optional command line inputs?