Fix gemma4 multi component quantization - #2637
Open
Xiaoyu (xiaoyu-work) wants to merge 9 commits into
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR improves robustness in Olive’s weight quantization for tiny FP16 values and extends ModelConfig.select_components to support selecting multiple Hugging Face model components (aggregating their runtime source paths) for component-scoped PyTorch optimization.
Changes:
- Clamp
WeightQuantizer.find_qparamsscales to the smallest positive representable value to avoid FP16 underflow to zero. - Allow
HfModelcomponent selection of multiple components and aggregate theircomponent_source_pathsintomodel_attributes. - Update/add tests covering multi-component selection aggregation and tiny-FP16 scale underflow prevention.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
olive/common/quant/utils.py |
Clamps computed quantization scales to a minimum positive value to prevent underflow to zero. |
olive/model/config/model_config.py |
Updates HF component selection logic to support multiple selected components and aggregate source paths into model_attributes. |
test/common/quant/test_utils.py |
Adds a unit test ensuring tiny nonzero FP16 weights do not yield zero scales. |
test/model/test_composite_model.py |
Updates HF-model component selection tests to validate multi-component aggregation instead of expecting an error. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Co-authored-by: xiaoyu-work <85524621+xiaoyu-work@users.noreply.github.com>
Ti-Tai Wang (titaiwangms)
self-requested a review
August 28, 2026 00:05
Xiaoyu (xiaoyu-work)
enabled auto-merge (squash)
August 31, 2026 22:35
Xiaoyu (xiaoyu-work)
force-pushed
the
fix/gemma4-multi-component-quantization
branch
from
August 31, 2026 22:42
5996154 to
74a029e
Compare
Contributor
Review team verdict: Request changesThe review team found one critical model-correctness issue and several major checkpoint integrity and integration problems.
Non-blocking compatibility questions
|
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.
Describe your changes
This pull request improves quantization robustness for small floating point values and enhances the
ModelConfigcomponent selection logic to support multiple components, along with corresponding test updates.Quantization robustness:
olive/common/quant/utils.py, thefind_qparamsmethod now clamps the calculatedscalesto a minimum positive value to prevent underflow to zero for tiny FP16 values, ensuring numerical stability during quantization.test_find_qparams_tiny_fp16_values_do_not_underflow) to verify that quantizing nonzero FP16 groups does not produce zero scales, preventing underflow issues.ModelConfig component selection enhancements:
ModelConfig.select_components, allowing aggregation of multiple components for component-scoped PyTorch optimization._select_hf_componentto handle multiple selected components, aggregating their names and source paths intomodel_attributes, and improved error handling for missing source paths.Checklist before requesting a review
lintrunner -a(Optional) Issue link