From 61a84ee16c914d0106c38baeb851bd4a5db47498 Mon Sep 17 00:00:00 2001 From: Aleksei Kashapov Date: Tue, 23 Jul 2024 16:15:48 +0200 Subject: [PATCH 1/2] default preset to mixed --- nncf/quantization/algorithms/min_max/algorithm.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/nncf/quantization/algorithms/min_max/algorithm.py b/nncf/quantization/algorithms/min_max/algorithm.py index 2fefb664a18..1c824ecba74 100644 --- a/nncf/quantization/algorithms/min_max/algorithm.py +++ b/nncf/quantization/algorithms/min_max/algorithm.py @@ -203,10 +203,7 @@ def __init__( # preset definition if self._preset is None: - if model_type == ModelType.TRANSFORMER: - self._preset = QuantizationPreset.MIXED - else: - self._preset = QuantizationPreset.PERFORMANCE + self._preset = QuantizationPreset.MIXED self._override_device() self._set_mode_based_defaults() From 9726541b9fcdd3015b08dd6c756f574a6bc04ea7 Mon Sep 17 00:00:00 2001 From: Aleksei Kashapov Date: Tue, 30 Jul 2024 12:06:16 +0200 Subject: [PATCH 2/2] add preset log --- tests/openvino/tools/calibrate.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/tests/openvino/tools/calibrate.py b/tests/openvino/tools/calibrate.py index a044bf8f269..38a2bac2c6e 100644 --- a/tests/openvino/tools/calibrate.py +++ b/tests/openvino/tools/calibrate.py @@ -41,6 +41,7 @@ import nncf from nncf.common.deprecation import warning_deprecated +from nncf.common.logging.logger import nncf_logger from nncf.common.logging.logger import set_log_file from nncf.common.quantization.structs import QuantizationPreset from nncf.common.quantization.structs import QuantizationScheme @@ -1076,22 +1077,29 @@ def update_nncf_algorithms_config(nncf_algorithms_config: Dict[str, Dict[str, An print(f"Updated subset_size value for {nncf_method} method to {new_subset_size} ") +def upd_preset(nncf_algorithms_config: Dict[str, Dict[str, Any]]) -> None: + for _, config in nncf_algorithms_config.items(): + upd_preset = "mixed" + config["preset"] = QuantizationPreset(upd_preset) + nncf_logger.info(f"Updated preset value to {upd_preset} ") + + def main(): args = parse_args() if args.impl is not None: print("--impl option is deprecated and will have no effect. Only native calibration allowed.") config = Config.read_config(args.config) config = filter_configuration(config) - + set_log_file(f"{args.output_dir}/log.txt") xml_path, bin_path = get_model_paths(config.model) accuracy_checker_config = get_accuracy_checker_config(config.engine) nncf_algorithms_config = get_nncf_algorithms_config(config.compression, args.output_dir) + upd_preset(nncf_algorithms_config) assert args.batch_size >= 0 if args.batch_size > 1: update_accuracy_checker_config(accuracy_checker_config, args.batch_size) update_nncf_algorithms_config(nncf_algorithms_config, args.batch_size) - set_log_file(f"{args.output_dir}/log.txt") output_dir = os.path.join(args.output_dir, "optimized") os.makedirs(output_dir, exist_ok=True)