Repository: openvinotoolkit/nncf

Issue:
Revise mixed-precision related content
I have 3 comments/proposal:
- Please add `compression_ratio` into the template file inside the Quantization readme
- Create a separate folder for the samples of configs on the same level as quantization, pruning, etc. Let's call it `mixed_precision`
- Move all the hawq-related configs into this folder and minimize the scope of parameters in this config removing as much as possible and let them be the defaults ones.


Discussion:

Resolving patch:
diff --git a/nncf/quantization/precision_init/hawq_init.py b/nncf/quantization/precision_init/hawq_init.py
--- a/nncf/quantization/precision_init/hawq_init.py
+++ b/nncf/quantization/precision_init/hawq_init.py
@@ -59,9 +59,9 @@ def __init__(self, algo: 'QuantizationController', config: 'NNCFConfig',
         self._criterion = init_args.criterion
         self._data_loader = init_args.data_loader
         self._traces_per_layer_path = config.get('traces_per_layer_path', None)
-        self._num_data_points = config.get('num_data_points', 1000)
-        self._iter_number = config.get('iter_number', 500)
-        self._tolerance = config.get('tolerance', 1e-5)
+        self._num_data_points = config.get('num_data_points', 100)
+        self._iter_number = config.get('iter_number', 200)
+        self._tolerance = config.get('tolerance', 1e-4)
         self._compression_ratio = config.get('compression_ratio', 1.5)
         self._bits = self._hw_precision_constraints.get_all_unique_bits() \
             if self._hw_precision_constraints else config.get('bits', [4, 8])


Test patch:
diff --git a/tests/quantization/test_precision_init.py b/tests/quantization/test_precision_init.py
--- a/tests/quantization/test_precision_init.py
+++ b/tests/quantization/test_precision_init.py
@@ -562,12 +562,6 @@ def test_hawq_broadcast_avg_traces_in_distributed_mode(tmp_path):
 
 ManualConfigTestParams = namedtuple('ManualConfigTestParams', ('config_name', 'bit_stats'))
 MANUAL_CONFIG_TEST_PARAMS = [
-    ManualConfigTestParams(config_name="mobilenet_v2_cifar100_mixed_int_manual.json",
-                           bit_stats=[['8', '23.077', '33.333', '56.410'],
-                                      ['4', '22.222', '21.368', '43.590']]),
-    ManualConfigTestParams(config_name="mobilenet_v2_cifar100_mixed_int_manual_staged.json",
-                           bit_stats=[['8', '23.077', '33.333', '56.410'],
-                                      ['4', '22.222', '21.368', '43.590']]),
     ManualConfigTestParams(config_name="mobilenet_v2_imagenet_mixed_int_manual.json",
                            bit_stats=[['8', '23.077', '23.932', '47.009'],
                                       ['4', '22.222', '30.769', '52.991']]),
@@ -587,7 +581,8 @@ def test_hawq_broadcast_avg_traces_in_distributed_mode(tmp_path):
                          ids=[pair[0] for pair in MANUAL_CONFIG_TEST_PARAMS])
 def test_hawq_manual_configs(manual_config_params):
     config_name, bit_stats = manual_config_params
-    config = NNCFConfig.from_json(str(EXAMPLES_DIR.joinpath('classification', 'configs', 'quantization') / config_name))
+    config_path = EXAMPLES_DIR.joinpath('classification', 'configs', 'mixed_precision') / config_name
+    config = NNCFConfig.from_json(str(config_path))
     config['quantizer_setup_type'] = 'pattern_based'
     config = register_default_init_args(config, train_loader=create_mock_dataloader(config), criterion=None)
     model = load_model(config['model'], pretrained=False)