From 81d2417c57d72928cd3f97308cb61c22623c53e1 Mon Sep 17 00:00:00 2001 From: Mengwei Liu Date: Wed, 3 Jul 2024 14:07:08 -0700 Subject: [PATCH 1/2] Change print() to logging in Quantizer so that the caller can have control --- torchao/quantization/GPTQ.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/torchao/quantization/GPTQ.py b/torchao/quantization/GPTQ.py index 018688a678..154158f0ad 100644 --- a/torchao/quantization/GPTQ.py +++ b/torchao/quantization/GPTQ.py @@ -621,7 +621,7 @@ def _create_quantized_state_dict( out_features = mod.out_features in_features = mod.in_features # assert out_features % 8 == 0, "require out_features % 8 == 0" - print(f"linear: {fqn}, in={in_features}, out={out_features}") + logging.info(f"linear: {fqn}, in={in_features}, out={out_features}") assert ( in_features % self.groupsize == 0 @@ -634,11 +634,11 @@ def _create_quantized_state_dict( if self.padding_allowed: from .utils import find_multiple import torch.nn.functional as F - print(f"warning: {fqn} is padded to satisfy in_features % 1024 == 0") + logging.warn(f"warning: {fqn} is padded to satisfy in_features % 1024 == 0") padded_in_features = find_multiple(in_features, 1024) weight = F.pad(weight, pad=(0, padded_in_features - in_features)) else: - print(f"warning: {fqn} is skipped, int4 requires that in_features is 32, 64, or is divisible by 1024, " + + logging.warn(f"warning: {fqn} is skipped, int4 requires that in_features is 32, 64, or is divisible by 1024, " + "and that groupsize and inner_k_tiles*16 evenly divide into it") continue ( From f187931f2cb2b39d78f7a4b3b59ec32f6f466381 Mon Sep 17 00:00:00 2001 From: Mengwei Liu Date: Wed, 3 Jul 2024 14:41:10 -0700 Subject: [PATCH 2/2] Change Int8DynActInt4WeightQuantizer as well --- torchao/quantization/GPTQ.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/torchao/quantization/GPTQ.py b/torchao/quantization/GPTQ.py index 154158f0ad..218cc74621 100644 --- a/torchao/quantization/GPTQ.py +++ b/torchao/quantization/GPTQ.py @@ -960,7 +960,7 @@ def _create_quantized_state_dict( out_features = mod.out_features in_features = mod.in_features # assert out_features % 8 == 0, "require out_features % 8 == 0" - print(f"linear: {fqn}, in={in_features}, out={out_features}") + logging.info(f"linear: {fqn}, in={in_features}, out={out_features}") assert ( in_features % self.groupsize == 0 @@ -971,11 +971,11 @@ def _create_quantized_state_dict( if self.padding_allowed: from .utils import find_multiple import torch.nn.functional as F - print(f"warning: {fqn} is padded to satisfy in_features % 1024 == 0") + logging.warn(f"warning: {fqn} is padded to satisfy in_features % 1024 == 0") padded_in_features = find_multiple(in_features, 1024) weight = F.pad(weight, pad=(0, padded_in_features - in_features)) else: - print(f"warning: {fqn} is skipped, int4 requires that in_features is 32, 64, or is divisible by 1024, " + + logging.warn(f"warning: {fqn} is skipped, int4 requires that in_features is 32, 64, or is divisible by 1024, " + "and that groupsize and inner_k_tiles*16 evenly divide into it") continue (