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 bug causing random initialization of bias when using GPTQ quantization with models without bias #1827

Merged
merged 2 commits into from
Apr 29, 2024
Merged
Changes from 1 commit
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
5 changes: 3 additions & 2 deletions optimum/gptq/quantizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -278,19 +278,20 @@ def _replace_by_quant_layers(self, module: nn.Module, names: List[str], name: st
elif isinstance(layer, Conv1D):
in_features = layer.weight.shape[0]
out_features = layer.weight.shape[1]
bias = True if layer.bias else False
if not (self.desc_act) or self.group_size == -1:
new_layer = QuantLinear(
self.bits,
self.group_size,
in_features,
out_features,
True,
bias,
use_cuda_fp16=self.use_cuda_fp16,
weight_dtype=layer.weight.dtype,
)
else:
new_layer = QuantLinear(
self.bits, self.group_size, in_features, out_features, True, weight_dtype=layer.weight.dtype
self.bits, self.group_size, in_features, out_features, bias, weight_dtype=layer.weight.dtype
)
new_layer.device = device
setattr(module, attr, new_layer.to(device))
Expand Down
Loading