QuantizedModel: support group_size -1 (per-channel) #1244
Merged
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.
Both gptq and awq support per channel quantization. This is represented using
group_size = -1
. But the builder is not able to handle this case.This PR makes
group_size
into a property that returnsin_features
if_group_size == -1
. The group size cannot be set during init sincein_features
is set after init.Note: The resultant MatMulNBits node might be invalid if the group_size is not supported by the operator kernel, but it can be converted into a valid DQ -> MatMul. This can be done either in the builder or subsequently using an olive pass https://github.com/microsoft/Olive/blob/50f360aeacfb949abc0d845e4070922555f7c58a/olive/passes/onnx/mnb_to_qdq.py#L27.
This PR also fixes this issue.