-
Notifications
You must be signed in to change notification settings - Fork 159
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[luci/pass] Add basic quantization support for weights in GPTQuantizeWeightsWithGPTQPass #14475
Conversation
…uantizeWeightsWithGPTQPass This commit implements basic quantization of weights in `QuantizeDequantizeWeightsWithGPTQPass`, supporting both 4-bit and 8-bit quantization. Only channel-wise quantization is supported. ONE-DCO-1.0-Signed-off-by: y01000.you <[email protected]>
nudged_max[i]); | ||
} | ||
|
||
quantize = [&](uint32_t *indices, loco::TensorShape &dimension, int index_channel_dim) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
quantize = [&](uint32_t *indices, loco::TensorShape &dimension, int index_channel_dim) { | |
auto quantize = [&](uint32_t *indices, loco::TensorShape &dimension, int index_channel_dim) { |
IterFunc quantize; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IterFunc quantize; |
assert(min <= max); | ||
const int32_t kMinScale = 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
assert(min <= max); | |
const int32_t kMinScale = 0; | |
assert(min <= max); | |
const int32_t kMinScale = 0; |
|
||
assert(scaling_factor[idx_channel] > 0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
assert(scaling_factor[idx_channel] > 0); | |
assert(scaling_factor[idx_channel] > 0); | |
auto data_clipped = data < min[idx_channel] ? min[idx_channel] : data; | ||
data_clipped = data_clipped > max[idx_channel] ? max[idx_channel] : data_clipped; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
may not use min(max(a,b),c)
form ?
1/ plz add link to draft |
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
move this format change to another PR
min[idx_channel] = data < min[idx_channel] ? data : min[idx_channel]; | ||
max[idx_channel] = data > max[idx_channel] ? data : max[idx_channel]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why not use std::min
, std::max
???
This commit refactors the QuantizeDequantizeWeightsWithGPTQPass.cpp file to improve its readability and maintainability. ONE-DCO-1.0-Signed-off-by: y01000.you <[email protected]>
This commit implements basic quantization of weights in
QuantizeDequantizeWeightsWithGPTQPass
, supporting both 4-bit and 8-bit quantization. Only channel-wise quantization is supported.ONE-DCO-1.0-Signed-off-by: y01000.you [email protected]