46
46
logging .basicConfig (level = logging .INFO , format = FORMAT )
47
47
48
48
pkg_name = __name__
49
+ verbosity_setting = None
49
50
50
51
51
52
def set_pkg_name (name : str ) -> None :
@@ -57,6 +58,15 @@ def get_resource_path(resource_name) -> str:
57
58
return pkg_resources .resource_filename (pkg_name , resource_name )
58
59
59
60
61
+ def set_verbosity (val ):
62
+ global verbosity_setting
63
+ verbosity_setting = val
64
+
65
+
66
+ def verbose_export ():
67
+ return verbosity_setting
68
+
69
+
60
70
@dataclass
61
71
class EmbeddingQuantOptions :
62
72
is_per_channel : bool = True
@@ -240,7 +250,8 @@ def quantize(
240
250
from torchao .quantization .quant_api import Int8DynActInt4WeightQuantizer
241
251
242
252
model = Int8DynActInt4WeightQuantizer (precision = torch_dtype ).quantize (model )
243
- print ("quantized model:" , model )
253
+ if verbose_export ():
254
+ print ("quantized model:" , model )
244
255
return model
245
256
elif qmode == "8da4w-gptq" :
246
257
from torchao .quantization .quant_api import Int8DynActInt4WeightGPTQQuantizer
@@ -448,7 +459,9 @@ def build_args_parser() -> argparse.ArgumentParser:
448
459
449
460
def canonical_path (path : str , * , dir : bool = False ) -> str :
450
461
451
- print (f"creating canonical path for { path } " )
462
+ if verbose_export ():
463
+ print (f"creating canonical path for { path } " )
464
+
452
465
if not path .startswith ("par:" ):
453
466
return path
454
467
@@ -457,7 +470,8 @@ def canonical_path(path: str, *, dir: bool = False) -> str:
457
470
return path [4 :]
458
471
else :
459
472
return_val = pkg_resources .resource_filename (pkg_name , path [4 :])
460
- print (f"canonical name is: { return_val } " )
473
+ if verbose_export ():
474
+ print (f"canonical name is: { return_val } " )
461
475
return return_val
462
476
463
477
0 commit comments