Repository: quic/aimet (language: python)

Issue:
Disable dropout quantization



Discussion / hints:

Fix patch:
diff --git a/TrainingExtensions/common/src/python/aimet_common/quantsim_config/default_config.json b/TrainingExtensions/common/src/python/aimet_common/quantsim_config/default_config.json
index a710f9e7ce..bbf14dd464 100755
--- a/TrainingExtensions/common/src/python/aimet_common/quantsim_config/default_config.json
+++ b/TrainingExtensions/common/src/python/aimet_common/quantsim_config/default_config.json
@@ -24,7 +24,12 @@
 
   "op_type":
   {
-    "Cast": {
+    "Cast":
+    {
+      "is_output_quantized": "False"
+    },
+    "Dropout":
+    {
       "is_output_quantized": "False"
     },
     "Squeeze":
diff --git a/TrainingExtensions/common/src/python/aimet_common/quantsim_config/default_config_per_channel.json b/TrainingExtensions/common/src/python/aimet_common/quantsim_config/default_config_per_channel.json
index 8790fdc2c7..b25721846d 100644
--- a/TrainingExtensions/common/src/python/aimet_common/quantsim_config/default_config_per_channel.json
+++ b/TrainingExtensions/common/src/python/aimet_common/quantsim_config/default_config_per_channel.json
@@ -24,7 +24,12 @@
 
   "op_type":
   {
-    "Cast": {
+    "Cast":
+    {
+      "is_output_quantized": "False"
+    },
+    "Dropout":
+    {
       "is_output_quantized": "False"
     },
     "Squeeze":


Test patch:
diff --git a/TrainingExtensions/torch/test/python/test_quantizer.py b/TrainingExtensions/torch/test/python/test_quantizer.py
index 0ea5c00622..faa2b64318 100644
--- a/TrainingExtensions/torch/test/python/test_quantizer.py
+++ b/TrainingExtensions/torch/test/python/test_quantizer.py
@@ -1665,7 +1665,6 @@ def test_save_and_load(self):
 
         self.check_quant_params(sim.model.conv1, loaded_model.conv1, True)
         self.check_quant_params(sim.model.conv2, loaded_model.conv2, True)
-        self.check_quant_params(sim.model.conv2_drop, loaded_model.conv2_drop, False)
         self.check_quant_params(sim.model.fc2, loaded_model.fc2, True)
 
         assert np.allclose(output_before_save.detach().numpy(),
@@ -2586,7 +2585,7 @@ def test_save_encodings_to_json(self):
         qsim.save_encodings_to_json('./data', 'saved_encodings')
         with open('./data/saved_encodings.json') as encodings_file:
             encodings = json.load(encodings_file)
-            assert len(encodings['activation_encodings']) == 14
+            assert len(encodings['activation_encodings']) == 13
             assert len(encodings['param_encodings']) == 5
 
     def test_compute_encodings_for_multiple_sims(self):
diff --git a/TrainingExtensions/torch/test/python/v2/ab_test/test_quantizer_.py b/TrainingExtensions/torch/test/python/v2/ab_test/test_quantizer_.py
index 2cfffad553..e6b81bbdb0 100644
--- a/TrainingExtensions/torch/test/python/v2/ab_test/test_quantizer_.py
+++ b/TrainingExtensions/torch/test/python/v2/ab_test/test_quantizer_.py
@@ -1645,8 +1645,10 @@ def dummy_forward_pass(model, _):
             if isinstance(module, aimet_nn.FakeQuantizationMixin):
                 if name == 'relu1':
                     assert isinstance(module.output_quantizers[0], QuantizeDequantize)
-                elif name in ['conv2', 'conv2_drop', 'relu2', 'relu3', 'dropout', 'fc2', 'log_softmax']:
+                elif name in ['conv2', 'relu2', 'relu3', 'fc2', 'log_softmax']:
                     assert not module.output_quantizers[0].is_initialized()
+                elif name in ['conv2_drop', 'dropout']:
+                    assert module.output_quantizers[0] is None
 
     def test_rnn_quantization(self):
         """ Test quantizing a model with rnn layer """
@@ -2357,7 +2359,7 @@ def test_save_encodings_to_json(self):
             qsim.save_encodings_to_json(tmp_dir, 'saved_encodings')
             with open(f'{tmp_dir}/saved_encodings.json') as encodings_file:
                 encodings = json.load(encodings_file)
-                assert len(encodings['activation_encodings']) == 14
+                assert len(encodings['activation_encodings']) == 13
                 assert len(encodings['param_encodings']) == 5
 
     @pytest.mark.skip('compute_encodings_for_sims not supported yet')