Skip to content

Commit

Permalink
WOQ: ensure group_size is a power of two when loading checkpoints (#3…
Browse files Browse the repository at this point in the history
…116)
  • Loading branch information
Xia-Weiwen authored Jul 23, 2024
1 parent 18f4d9d commit 76dfb92
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions intel_extension_for_pytorch/utils/weight_only_quantization.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,9 @@ def _get_linear_parameters(attr_name, state_dict, checkpoint_config):
if scales.size(-1) != 1:
# qweight is compressed along the last dim int4 * 8 -> int32
group_size = qweight.size(-1) * 8 // scales.size(-1)
# Ensure group_size is a power of two
assert group_size > 0
group_size = 2 ** (group_size - 1).bit_length()
return qweight, scales, qzeros, bias, group_size, g_idx


Expand Down

0 comments on commit 76dfb92

Please sign in to comment.