Quantization: Add 2bit to precision constants, Fix -1 group_size handling in ModelBuilder#2338
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds support for 2-bit quantization and fixes handling of per-channel quantization (group_size == -1) in the ModelBuilder pass. The changes enable proper loading and processing of quantized models that use per-channel quantization or 2-bit precision.
Changes:
- Added
BITS2 = 2to thePrecisionBitsenum to support 2-bit quantization - Fixed ModelBuilder logic to handle group_size == -1 (per-channel quantization) correctly by avoiding division by -1
- Enabled and enhanced test coverage for ModelBuilder with Olive-quantized models, including group_size == -1 test cases
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| olive/constants.py | Added BITS2 constant to PrecisionBits enum for 2-bit quantization support |
| olive/passes/onnx/model_builder.py | Refactored qweight tensor processing to properly handle group_size == -1 and simplified the logic by removing separate scales handling |
| test/passes/onnx/test_model_builder.py | Removed skip decorator and added group_size parametrization to test both normal (16) and per-channel (-1) quantization |
xiaoyu-work
approved these changes
Feb 18, 2026
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
Checklist before requesting a review
lintrunner -a(Optional) Issue link