Add composite model support to build command#1058
Open
xieofxie wants to merge 2 commits into
Open
Conversation
Detect composite (seq2seq) models like Qwen3 and fan out into one build per sub-component, each written to a subdirectory under the output dir (e.g. output/decoder_prefill/, output/decoder_gen/). - Add _warn_partial_composite_build() helper for mid-run failures - Composite detection reuses resolve_composite_components from loader - Per-component configs are auto-generated with generate_build_config, inheriting quant/compile settings from the outer config - Reject --use-cache for composite models (cache keys are ambiguous) - Error handling mirrors export command: ValueError -> UsageError, RuntimeError re-raised, OSError suppressed, unexpected -> ClickException - Add 6 unit tests covering fan-out, --use-cache rejection, error surfacing, partial build warnings, and quant/compile carry-over
- Remove redundant second optimizer.optimize() call in optimize_onnx() that caused ORT SymbolicShapeInference to segfault on Qwen3 graphs - Make pattern matcher edge lookup graceful: return None for orphaned edges (missing producer after ORT graph optimization) instead of asserting, so pattern matching skips unresolvable edges cleanly - Update tests to match new behavior
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds composite (seq2seq) model detection and fan-out to
winml build, mirroring the pattern already implemented inwinml export. Previously, runningwinml buildon a composite model like Qwen3 would attempt a single-model build and fail. Now, composite models are automatically detected and each sub-component is built independently into its own subdirectory.Changes
src/winml/modelkit/commands/build.py_warn_partial_composite_build()helper that warns when a composite build fails mid-run, listing completed components without deleting them (same safety semantics as export's_warn_partial_composite).resolve_composite_componentswith the same error handling as export:ValueError→UsageError(e.g. ambiguous composite needing explicit--task)RuntimeErrorre-raised (empty registry guard)OSErrorsuppressed (model ref not resolvable as HF config)ClickException--use-cache(cache keys are ambiguous for multi-component builds)generate_build_config(task=component_task)quant/compilefrom the outer config (already patched by CLI overrides)_run_single_buildper component intooutput_dir/<component_name>/tests/unit/commands/test_build.pyTestBuildCompositeclass with 6 tests:_run_single_buildper component into correct subdirectories--use-cacherejected for composite modelsValueErrorduring composite resolution surfaces as usage errorquant/compilefrom outer config