Skip to content
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

Fix bugs for gptq exporting with static_groups #1614

Merged
merged 6 commits into from
Feb 28, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion neural_compressor/adaptor/torch_utils/gptq.py
Original file line number Diff line number Diff line change
Expand Up @@ -668,7 +668,8 @@ def tmp(_, inp, out):
gptq_config[self.get_full_layer_name(layer_name, block_idx)] = {"scale": scale}
if not weight_config_this_layer["sym"]:
gptq_config[self.get_full_layer_name(layer_name, block_idx)]["zero"] = zp
if weight_config_this_layer["act_order"]: # save perm for restoring the weights
if weight_config_this_layer["act_order"] and not weight_config_this_layer["static_groups"]:
# save perm for restoring the weights, but only when static_groups is not enabled.
gptq_config[self.get_full_layer_name(layer_name, block_idx)]["perm"] = gptq_for_this_block[
layer_name
].perm
Expand Down Expand Up @@ -828,6 +829,11 @@ def fasterquant(self, W, blocksize=128, percdamp=0.01, groupsize=-1, act_order=F
zero.append(self.quantizer.zero)
else:
idx = i1 + i
if (i1 + i) % groupsize == 0:
# load the pre-calculated quantization parameters in groups
static_quantizer = groups[(i1 + i) // groupsize]
scale.append(static_quantizer.scale)
zero.append(static_quantizer.zero)
if act_order:
idx = perm[idx]
self.quantizer = groups[idx // groupsize]
Expand Down