Skip to content

Commit

Permalink
fix preci issue
Browse files Browse the repository at this point in the history
  • Loading branch information
wenhuach21 committed Oct 28, 2024
1 parent 3f2cd39 commit 2df1527
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions auto_round/auto_quantizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -402,11 +402,10 @@ def convert_model(self, model: nn.Module):
self.target_device = target_device

if hasattr(quantization_config, "backend"): # pragma: no cover
if ("hpu" == target_device or "cpu" == target_device)and model.dtype != torch.bfloat16:
if ("hpu" == target_device or "cpu" == target_device) and model.dtype != torch.bfloat16:
logger.info(f"Change the dtype to `bfloat16` as {target_device.upper()} does not support float16")
model = model.to(torch.bfloat16)


bits = quantization_config.bits
group_size = quantization_config.group_size
data_type = quantization_config.data_type if hasattr(quantization_config,
Expand Down Expand Up @@ -584,13 +583,14 @@ def cpu_post_init(self, model):
dep_check = True
message = "Repacking to CPU format"

for n, layer in tqdm(model.named_modules(), desc=message, total=len(list(model.named_modules())), leave=True): ##not exit correctly
for n, layer in tqdm(model.named_modules(), desc=message, total=len(list(model.named_modules())),
leave=True): ##not exit correctly
if isinstance(layer, (qlinear_qbits.QuantLinear, qlinear_qbits_gptq.QuantLinear)):
if dep_check:
layer.req_check()
layer.post_init()
dep_check = False
if isinstance(layer,(qlinear_ipex_gptq.QuantLinear, qlinear_ipex_awq.QuantLinear)):
if isinstance(layer, (qlinear_ipex_gptq.QuantLinear, qlinear_ipex_awq.QuantLinear)):
layer.post_init()

return model
Expand Down

0 comments on commit 2df1527

Please sign in to comment.