From e3fd2776a318a3a7b9d33315cc42c04c181f6d2f Mon Sep 17 00:00:00 2001 From: B-201 <116639249+B-201@users.noreply.github.com> Date: Mon, 29 Apr 2024 19:23:04 +0800 Subject: [PATCH] Fix bug causing random initialization of bias when using GPTQ quantization with models without bias (#1827) * Fix gptq quantization for models without bias * Fix gptq quantization for models without bias --- optimum/gptq/quantizer.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/optimum/gptq/quantizer.py b/optimum/gptq/quantizer.py index 289e3256825..2c2c9d7e71a 100644 --- a/optimum/gptq/quantizer.py +++ b/optimum/gptq/quantizer.py @@ -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 = layer.bias is not None 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))