Add --test HF CLI path for 2-layer random model configs, olive run and ModelBuilder support, Qwen how-to/layer-types fix, and merge conflict resolution#2459
Conversation
Agent-Logs-Url: https://github.com/microsoft/Olive/sessions/e2149604-9db1-438e-a31f-01a53886093d Co-authored-by: xadupre <22452781+xadupre@users.noreply.github.com>
Agent-Logs-Url: https://github.com/microsoft/Olive/sessions/e2149604-9db1-438e-a31f-01a53886093d Co-authored-by: xadupre <22452781+xadupre@users.noreply.github.com>
Agent-Logs-Url: https://github.com/microsoft/Olive/sessions/e2149604-9db1-438e-a31f-01a53886093d Co-authored-by: xadupre <22452781+xadupre@users.noreply.github.com>
--test HF CLI path for 2-layer random model configs
Agent-Logs-Url: https://github.com/microsoft/Olive/sessions/d4221aaf-b4a3-4bed-85fe-30a12dcdfd6e Co-authored-by: xadupre <22452781+xadupre@users.noreply.github.com>
--test HF CLI path for 2-layer random model configs--test HF CLI path for 2-layer random model configs with fail-fast loading
Agent-Logs-Url: https://github.com/microsoft/Olive/sessions/57fd060e-5678-4015-b277-c7d14ec52145 Co-authored-by: xadupre <22452781+xadupre@users.noreply.github.com>
Agent-Logs-Url: https://github.com/microsoft/Olive/sessions/57fd060e-5678-4015-b277-c7d14ec52145 Co-authored-by: xadupre <22452781+xadupre@users.noreply.github.com>
Agent-Logs-Url: https://github.com/microsoft/Olive/sessions/cf4d7fdc-1de9-4098-adc3-3bedd436d7d0 Co-authored-by: xadupre <22452781+xadupre@users.noreply.github.com>
Agent-Logs-Url: https://github.com/microsoft/Olive/sessions/cf4d7fdc-1de9-4098-adc3-3bedd436d7d0 Co-authored-by: xadupre <22452781+xadupre@users.noreply.github.com>
Agent-Logs-Url: https://github.com/microsoft/Olive/sessions/cf4d7fdc-1de9-4098-adc3-3bedd436d7d0 Co-authored-by: xadupre <22452781+xadupre@users.noreply.github.com>
--test HF CLI path for 2-layer random model configs with fail-fast loading--test HF CLI path for 2-layer random model configs with reusable saved test models
Agent-Logs-Url: https://github.com/microsoft/Olive/sessions/c421adc3-0615-4d10-bf15-b21d632d70b2 Co-authored-by: xadupre <22452781+xadupre@users.noreply.github.com>
Agent-Logs-Url: https://github.com/microsoft/Olive/sessions/c421adc3-0615-4d10-bf15-b21d632d70b2 Co-authored-by: xadupre <22452781+xadupre@users.noreply.github.com>
Agent-Logs-Url: https://github.com/microsoft/Olive/sessions/c421adc3-0615-4d10-bf15-b21d632d70b2 Co-authored-by: xadupre <22452781+xadupre@users.noreply.github.com>
Agent-Logs-Url: https://github.com/microsoft/Olive/sessions/c421adc3-0615-4d10-bf15-b21d632d70b2 Co-authored-by: xadupre <22452781+xadupre@users.noreply.github.com>
Agent-Logs-Url: https://github.com/microsoft/Olive/sessions/c421adc3-0615-4d10-bf15-b21d632d70b2 Co-authored-by: xadupre <22452781+xadupre@users.noreply.github.com>
Agent-Logs-Url: https://github.com/microsoft/Olive/sessions/c421adc3-0615-4d10-bf15-b21d632d70b2 Co-authored-by: xadupre <22452781+xadupre@users.noreply.github.com>
Agent-Logs-Url: https://github.com/microsoft/Olive/sessions/c421adc3-0615-4d10-bf15-b21d632d70b2 Co-authored-by: xadupre <22452781+xadupre@users.noreply.github.com>
|
Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details. Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
Agent-Logs-Url: https://github.com/microsoft/Olive/sessions/5bd5199d-42fa-4109-94a3-c7995abe72a2 Co-authored-by: xadupre <22452781+xadupre@users.noreply.github.com>
|
Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details. Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
--test HF CLI path for 2-layer random model configs, olive run and ModelBuilder support, and Qwen how-to--test HF CLI path for 2-layer random model configs, olive run and ModelBuilder support, and Qwen how-to/layer-types fix
|
@copilot resolve the merge conflicts in this pull request |
Agent-Logs-Url: https://github.com/microsoft/Olive/sessions/2f777346-5b6a-423f-89fd-f40de41d2b70 Co-authored-by: xadupre <22452781+xadupre@users.noreply.github.com>
Co-authored-by: xadupre <22452781+xadupre@users.noreply.github.com>
Resolved in 5daba5d. I merged Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
--test HF CLI path for 2-layer random model configs, olive run and ModelBuilder support, and Qwen how-to/layer-types fix--test HF CLI path for 2-layer random model configs, olive run and ModelBuilder support, Qwen how-to/layer-types fix, and merge conflict resolution
There was a problem hiding this comment.
Pull request overview
This PR adds a --test mode for Hugging Face-backed Olive CLI workflows and olive run, enabling generation and reuse of a lightweight random-initialized 2-layer “test model” (including persistence via test_model_path) to support fast smoke checks before running full conversions. It also threads test_model_config through HF config/IO/dummy-input generation, updates ModelBuilder to export from the saved reduced checkpoint when present, and adds a Qwen-focused how-to plus targeted tests.
Changes:
- Add CLI + config support for
--testto emitinput_model.test_model_configandinput_model.test_model_path, includingolive run --testoverride behavior. - Extend HF loading utilities to apply reduced-layer config overrides, instantiate from
from_config, and optionally persist/reuse a saved test model directory. - Update ModelBuilder to use the saved test-model checkpoint when
test_model_configis active; add tests and a new Qwen smoke-test how-to doc.
Reviewed changes
Copilot reviewed 13 out of 13 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| test/passes/onnx/test_model_builder.py | Adds coverage ensuring ModelBuilder uses a saved test_model_path when test_model_config is set. |
| test/common/test_hf.py | Adds unit tests for reduced-config application, trust_remote_code handling, persistence/reuse, and fail-fast behavior. |
| test/cli/test_cli.py | Adds CLI workflow tests for olive run --test overrides and optimize→run smoke flow. |
| test/cli/test_base.py | Adds tests for get_input_model_config emitting test_model_config/test_model_path and validation when output path isn’t available. |
| olive/passes/onnx/model_builder.py | Switches ModelBuilder input to test_model_path when test_model_config is present (materializing if needed). |
| olive/model/handler/mixin/hf.py | Threads test_model_config into HF config/IO/dummy-input helpers. |
| olive/model/handler/hf.py | Adds test_model_path resource + test_model_config JSON config plumbing and passes them into HF loader. |
| olive/common/hf/utils.py | Implements reduced-layer config application + random init via from_config, plus optional persistence/reuse. |
| olive/common/hf/model_io.py | Adds test_model_config parameter propagation into config-based IO/dummy-input generation. |
| olive/cli/run.py | Enables olive run --test to inject HF test-model settings into an existing HF input_model in a run config. |
| olive/cli/base.py | Adds shared helper and CLI option wiring for --test on HF input model options. |
| docs/source/how-to/index.md | Links the new Qwen --test smoke-check how-to from the How Tos index. |
| docs/source/how-to/cli/cli-convert-qwen-test.md | New how-to describing a Qwen smoke check using olive optimize --dry_run followed by olive run --test. |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Describe your changes
Adds a CLI test path for Hugging Face models so generated
config.jsoncan carry a lightweight random-model definition instead of always using pretrained weights. When--testis passed, Olive now preserves the source architecture, instantiates a random model with 2 hidden layers, and can persist that test model for reuse.CLI/config support
--testto HF-backed CLI commands using shared input-model options.--testnow accepts an optional folder path where the generated test model is saved for reuse.input_model.test_model_configinto generated run configs, and now also emitsinput_model.test_model_pathwhen a save folder is provided or derived.{ "input_model": { "type": "HfModel", "model_path": "model-id", "test_model_config": { "hidden_layers": 2 }, "test_model_path": "path/to/test_model" } }--testis used without an explicit folder, Olive uses<output_path>/test_model.--testis used in a context where no output path is available, Olive now fails clearly instead of silently skipping persistence.olive runsupportolive run --testso it can apply the same lightweight HF test-model override to an existing Hugging Faceinput_modelalready present in a workflow config.olive run --testis used without an explicit folder, it derives the saved test-model location from the effective workflow output path.olive run --testnow fails clearly when the workflow config does not contain a Hugging Faceinput_model.HF model loading
test_model_config.num_hidden_layers,num_layers,n_layer,n_layers).layer_typesto match the reduced hidden-layer count so the saved reduced config remains valid when reloaded.from_config) so the model is random-initialized rather than loaded from pretrained weights.from_configloading path to avoid nestedtry/excepthandling by only passingtrust_remote_codewhen the model class signature supports it.test_model_pathalready contains a saved HF model, Olive loads that model instead of recreating it; otherwise it creates the reduced model once and saves it there.ModelBuilder support
--testworkflows export from the saved reduced Hugging Face test checkpoint instead of still using the original full checkpoint.test_model_configis present, ModelBuilder now materializes or reusestest_model_pathbefore export and passes that saved checkpoint to the builder.IO config / dummy input propagation
test_model_configthrough HF IO-config and dummy-input generation so the reduced-layer model shape metadata stays consistent with the generated test model.Documentation
--testsmoke check first, then rerun the full conversion.olive optimize --dry_runfollowed byolive run --test, matching the new CLI support.Qwen/Qwen3-0.6Band renamed the how-to page and index entry to match.Merge conflict resolution
origin/maininto this PR branch and resolved the conflict intest/passes/onnx/test_model_builder.py.ModelBuilderfallback/multi-file output test coverage and this PR's saved test-model-path coverage.ModelBuildertests to define the new Hugging Face test-model attributes used by this PR (test_model_configandtest_model_path).Targeted coverage
--testtest_model_configtest_model_path--testneeds an explicit folderolive run --testoverriding an existing HFinput_modelfrom a workflow configolive run --testis used on a non-HF workflow configtrust_remote_codehandling for supported, omitted, and unsupportedfrom_configsignaturestest_model_configis activeolive optimize --dry_runthenolive run --testcommands withhf-internal-testing/tiny-random-LlamaForCausalLMand verifies an ONNX artifact is producedlayer_typesaligned with the reduced hidden-layer count and can be reloaded successfullyModelBuildertests covering saved test-model reuse, single-file annotation fallback, and multi-file output component namingExamples:
Checklist before requesting a review
lintrunner -aRelease notes: Added a
--testoption for Hugging Face CLI workflows that can take a folder path, writes a lightweight 2-layer random-model config, saves and reuses the generated HF test model from that folder, fails fast if the reduced test model cannot be instantiated from the expected model class, only passestrust_remote_codewhen the targetfrom_configsupports it, and now keeps Qwen-stylelayer_typesmetadata aligned with reduced test-model layer counts so saved reduced configs reload cleanly. Also addedolive run --testsupport for workflow configs with Hugging Face input models, updated ModelBuilder to export from the saved reduced test checkpoint for--testflows, and added a Qwen3 0.6B how-to page for running a quick smoke test before the full conversion with an explicit output path for the generated ONNX files.(Optional) Issue link