Skip to content

Commit 76dfb92

Browse files
authored
WOQ: ensure group_size is a power of two when loading checkpoints (#3116)
1 parent 18f4d9d commit 76dfb92

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

‎intel_extension_for_pytorch/utils/weight_only_quantization.py‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,9 @@ def _get_linear_parameters(attr_name, state_dict, checkpoint_config):
159159
if scales.size(-1) != 1:
160160
# qweight is compressed along the last dim int4 * 8 -> int32
161161
group_size = qweight.size(-1) * 8 // scales.size(-1)
162+
# Ensure group_size is a power of two
163+
assert group_size > 0
164+
group_size = 2 ** (group_size - 1).bit_length()
162165
return qweight, scales, qzeros, bias, group_size, g_idx
163166

164167

0 commit comments

Comments
 (0)