Repository navigation
Migrate composite model weight adapters - #670
xiaoyu-work wants to merge 3 commits into
Conversation
Performance Comparison
|
🏗️ Architecture Diff
No architecture changes detected. ✅ Legend: ⚪ No change · 🔵 Minor (attrs/inits) · 🟡 Moderate (nodes added/removed) · 🔴 Major (interface changed) |
e409b2d to
a8a5c5b
Compare
ea293cb to
18bdcfd
Compare
a8a5c5b to
7562458
Compare
18bdcfd to
b4e4bb8
Compare
7562458 to
e5ce365
Compare
Add an explicit model-weight adapter boundary and migrate Gemma4, Qwen3.5/QMoE, and T5 to preserve architecture-specific semantics while handing component-routed packed weights to the generic loader. Validate every affine quantized op is fully bound. Signed-off-by: Xiaoyu Zhang <[email protected]>
Update binding validation and adapter fixtures for ComponentDescriptor.module_attribute_path. Signed-off-by: Xiaoyu Zhang <[email protected]>
b4e4bb8 to
f998a0b
Compare
There was a problem hiding this comment.
🔵 Needs a closer look
It changes core weight-loading/quantization behavior across multiple model families and build entrypoints, so it warrants final human review despite strong test coverage.
Pull request overview
This PR introduces an explicit model-weight adapter boundary in the checkpoint loading pipeline (while preserving legacy preprocess_weights), updates several model implementations to respect per-component quantization plans, and adds a binding gate that fails builds/publication when affine-quantized ops still have unbound parameters after weight application.
Changes:
- Add
adapt_model_weights()+ModelWeightAdapter/WeightAdapterContextas the new narrow model-specific adapter boundary with legacy fallback. - Make Qwen3.5/QMoE, Gemma4, and T5 preprocessing/component-quantization interactions component-plan aware (including routing and aliasing).
- Add
validate_quantized_component_bindings()and invoke it in build paths to ensure MatMulNBits/GatherBlockQuantized parameters are actually bound.
File summaries
| File | Description |
|---|---|
| src/mobius/weights/_adapters.py | Introduces the explicit model-weight adapter boundary with legacy preprocess_weights fallback. |
| src/mobius/weights/_adapters_test.py | Adds tests covering legacy hook compatibility and explicit adapter precedence. |
| src/mobius/weights/init.py | Exposes adapter API from the mobius.weights public surface. |
| src/mobius/models/t5.py | Adjusts tied-weight handling when component_quantization is active to avoid double preprocessing. |
| src/mobius/models/qwen35.py | Routes decoder quantization decisions through the decoder component plan and avoids double preprocessing in component mode. |
| src/mobius/models/qwen35_test.py | Adds regression test ensuring plan-only quantization keeps QMoE graph/weights aligned. |
| src/mobius/models/gemma4.py | Makes decoder/vision/audio/embedding construction and routing component-quantization aware; adds HF alias metadata. |
| src/mobius/models/gemma4_test.py | Adds component-plan layout, aliasing, routing, and embedding-sidecar routing regressions. |
| src/mobius/integrations/transformers/_builder.py | Switches weight preprocessing to adapt_model_weights() and enforces post-load binding validation. |
| src/mobius/components/_moe.py | Uses decoder component quantization when selecting QMoE quantization compatibility. |
| src/mobius/_component_quantization.py | Extends module→HF-name resolution (incl. .linear alias), allows specialized quantized modules when layouts match, and adds binding validator. |
| src/mobius/_component_quantization_test.py | Adds test ensuring the binding validator rejects unfilled affine-quantized parameters. |
| src/mobius/main.py | Applies adapter boundary in CLI load path and enforces binding validation post-weight-load. |
| CHANGELOG.md | Documents the adapter migration and component-sidecar routing/binding behavior. |
Review details
- Files reviewed: 14/14 changed files
- Comments generated: 1
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| preprocess = getattr(module, "preprocess_weights", None) | ||
| if preprocess is None: | ||
| return dict(state_dict) |
|
@copilot resolve the merge conflicts in this pull request |
…loader' into refactor/component-weight-adapters Signed-off-by: GitHub <[email protected]> # Conflicts: # src/mobius/__main__.py # src/mobius/_component_quantization.py # src/mobius/integrations/transformers/_builder.py # src/mobius/models/gemma4.py # src/mobius/models/gemma4_test.py # src/mobius/models/qwen35.py # src/mobius/models/t5.py Co-authored-by: xiaoyu-work <[email protected]>
Resolved and published the stacked-base merge conflicts in |
|
|
## Summary - Add typed weight records, component-owned bundles, and the Olive/GPTQ/AWQ codec registry. - Load existing quantized checkpoint weights using independent component layouts and per-projection HuggingFace source-name overrides and exclusions; do not quantize floating-point checkpoint weights. - Preserve Gemma4, Qwen3.5/QMoE, and T5 architecture-specific weight adaptations, tied tables, and component sidecar routing, and validate quantized parameter binding. - Preserve default attention head dimensions and KV-head counts when HuggingFace configuration overrides only a subset of layers. - Keep Gemma4 per-layer inputs in `[batch, sequence, layers, projection]` form between embedding and decoder components for OpenVINO; other execution providers retain the flattened layout. - Restore the seq2seq, vision-language, and speech independent-component quantization matrix coverage lost during the earlier graph-test file split. ## Loading correctness fixes - Recognize canonical weights only as complete, shape-matching groups so raw GPTQ/AWQ scales remain available to their codec; validate zero points using each projection's effective symmetry. - Normalize quantized embedding tables for two-dimensional GatherBlockQuantized storage rather than treating them as linear projections. - Honor Qwen3.5-MoE's model-declared float exclusions and Whisper's declared output head during both graph construction and loading. - Preserve the distinction between an absent component mapping (legacy global rules) and an explicitly empty mapping (float components). - Defer Gemma4 component packing until projection overrides are resolved. Restore T5 HuggingFace source aliases and separate decoder-stack rules from the independently owned top-level LM head. ## Consolidation Replaces #666, #669, and #670 and consolidates the related development from `test/per-component-quantization-stack` into this single PR. The branch starts directly from `main` at `a471d3416e9c52d5508d28730962e18c8a1053d0`. The design (#664) and canonical component manifests (#665) are already merged and are not separate dependencies of this PR. This includes all seven previously uncommitted Gemma4/config/EP files from the old development worktree, not just the three original PR heads. The committed old feature stack was also compared with main plus this PR: production feature areas were retained, and its missing graph-layout matrix tests were restored in the current split test modules. ## Review and CI follow-up Addressed all eight inline review threads, including duplicate/already-resolved reports, in `190eb8a5`: - Literal module rules now respect path boundaries; the compatibility normalizer rejects a missing task clearly. Redundant Protocol statements and alias parentheses are removed. - Fixed the Gemma3 split-tied loading regression, including its previously floating-point scaled embedding. A shared scaled quantized embedding preserves Gemma4 behavior, and actual embedding execution plus unsupported-tie guards are covered. - Corrected the LLaVA fixture's missing `vision_model` namespace without relaxing target validation. - Updated the stale GGUF integration expectation to the export contract already established by #688; tokenizer-identity rejection and full logit/generation comparisons remain intact. The original full L4/L5 jobs hit their explicit one-hour limits after recording failures. Those failed case IDs also occur on the exact base `a471d341`, but cancellation lost exception details, so they are not claimed to be infrastructure-only or fixed. No model selection, tolerance, or timeout was weakened. Isolated GPT-2 diagnostics at the original head each executed and passed exactly one selected case: L4 https://github.com/onnxruntime/mobius/actions/runs/34308638240 and L5 https://github.com/onnxruntime/mobius/actions/runs/34308638242 . These single-case successes do not certify the all-model golden jobs. Fresh full CI for the published follow-up: https://github.com/onnxruntime/mobius/actions/runs/34309655380 . ## Validation - **874 passed, 16 skipped, 4 deselected** in the focused loading/config/model/CLI/graph suite, including the repaired CI selectors and scaled quantized embedding execution. - **1 passed** for the real pinned `smollm2-135m-instruct-f16` GGUF CLI export/reload, full-logit, and generation integration case. - Ruff lint and formatting passed for the changed Python files. Independent review of this follow-up found no significant issues. - Runs used the repository-required onnx-ir API through isolated dependencies; the shared environment was not modified. - The original seven-file pending patch remains consolidated in this PR. Local evidence does not claim that the all-model golden jobs or physical NPU execution are green. --------- Signed-off-by: Xiaoyu Zhang <[email protected]> Signed-off-by: xiaoyu-work <[email protected]> Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Summary
preprocess_weightscompatibilityStack
Validation
.linearalias, per-component layouts, sidecar routing, and quantized embedding regressions