@@ -1026,6 +1026,25 @@ def test_exporters_cli_4bit(
10261026 "--lora-correction" not in option or b"with correction of low-rank adapters" in result .stdout
10271027 )
10281028
1029+ def test_exporters_cli_4bit_with_statistics_path (self ):
1030+ with TemporaryDirectory () as tmpdir :
1031+ statistics_path = f"{ tmpdir } /statistics"
1032+ result = subprocess .run (
1033+ f"optimum-cli export openvino --model { MODEL_NAMES ['llama' ]} --weight-format int4 --awq "
1034+ f"--dataset wikitext2 --group-size 4 --quantization-statistics-path { statistics_path } { tmpdir } " ,
1035+ shell = True ,
1036+ check = True ,
1037+ capture_output = True ,
1038+ )
1039+ self .assertTrue (
1040+ b"Statistics were successfully saved to a directory " + bytes (statistics_path , "utf-8" )
1041+ in result .stdout
1042+ )
1043+ self .assertTrue (
1044+ b"Statistics were successfully loaded from a directory " + bytes (statistics_path , "utf-8" )
1045+ in result .stdout
1046+ )
1047+
10291048 @parameterized .expand (SUPPORTED_QUANTIZATION_ARCHITECTURES )
10301049 def test_exporters_cli_full_quantization (
10311050 self ,
@@ -1069,7 +1088,7 @@ def test_exporters_cli_full_quantization(
10691088 [
10701089 (
10711090 "falcon-40b" ,
1072- "tiiuae/falcon-7b-instruct " ,
1091+ "bigscience/bloomz-560m " ,
10731092 AutoModelForCausalLM ,
10741093 OVModelForCausalLM ,
10751094 "--task text-generation-with-past --weight-format int4" ,
@@ -1112,16 +1131,20 @@ def test_exporters_cli_with_default_config(
11121131 with open (Path (tmpdir ) / "config.json" , "w" ) as wf :
11131132 json .dump (config , wf )
11141133
1134+ is_weight_compression = "--weight-format" in options
1135+ run_command = f"optimum-cli export openvino --model { tmpdir } { options } { tmpdir } "
1136+ if is_weight_compression :
1137+ # Providing quantization statistics path should not interfere with the default configuration matching
1138+ run_command += f" --quantization-statistics-path { tmpdir } /statistics"
11151139 subprocess .run (
1116- f"optimum-cli export openvino --model { tmpdir } { options } { tmpdir } " ,
1140+ run_command ,
11171141 shell = True ,
11181142 check = True ,
11191143 )
11201144
11211145 model = ov_model_cls .from_pretrained (tmpdir )
11221146 rt_info = model .model .get_rt_info ()
11231147 nncf_info = rt_info ["nncf" ]
1124- is_weight_compression = "weight_compression" in nncf_info
11251148 model_quantization_config = nncf_info ["weight_compression" if is_weight_compression else "quantization" ]
11261149
11271150 default_config = {** default_configs_collection [model_id ]}
@@ -1134,6 +1157,10 @@ def test_exporters_cli_with_default_config(
11341157 quant_method = default_config .pop ("quant_method" , None )
11351158 default_config ["awq" ] = quant_method == "awq"
11361159 default_config ["gptq" ] = quant_method == "gptq"
1160+ advanced_parameters = eval (model_quantization_config ["advanced_parameters" ].value )
1161+ model_quantization_config ["statistics_path" ] = Mock ()
1162+ model_quantization_config ["statistics_path" ].value = advanced_parameters ["statistics_path" ]
1163+ default_config ["statistics_path" ] = f"{ tmpdir } /statistics"
11371164 else :
11381165 dtype = default_config .pop ("dtype" , None )
11391166 self .assertEqual (dtype , "int8" )
0 commit comments