mct-nightly 2.4.0.20250605.606__py3-none-any.whl → 2.4.0.20250605.151156__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: mct-nightly
3
- Version: 2.4.0.20250605.606
3
+ Version: 2.4.0.20250605.151156
4
4
  Summary: A Model Compression Toolkit for neural networks
5
5
  Author-email: ssi-dnn-dev@sony.com
6
6
  Classifier: Programming Language :: Python :: 3
@@ -1,5 +1,5 @@
1
- mct_nightly-2.4.0.20250605.606.dist-info/licenses/LICENSE.md,sha256=aYSSIb-5AFPeITTvXm1UAoe0uYBiMmSS8flvXaaFUks,10174
2
- model_compression_toolkit/__init__.py,sha256=lCWC3Mfi8O78xOPtfaV5XQKWjw8T4hxVdcOiUD-CGkU,1557
1
+ mct_nightly-2.4.0.20250605.151156.dist-info/licenses/LICENSE.md,sha256=aYSSIb-5AFPeITTvXm1UAoe0uYBiMmSS8flvXaaFUks,10174
2
+ model_compression_toolkit/__init__.py,sha256=G6fQ6rBpGb4hP9184dUezrop85VHb7DUM4hqOjRCOss,1557
3
3
  model_compression_toolkit/constants.py,sha256=KNgiNLpsMgSYyXMNEbHXd4bFNerQc1D6HH3vpbUq_Gs,4086
4
4
  model_compression_toolkit/defaultdict.py,sha256=LSc-sbZYXENMCw3U9F4GiXuv67IKpdn0Qm7Fr11jy-4,2277
5
5
  model_compression_toolkit/logger.py,sha256=L3q7tn3Uht0i_7phnlOWMR2Te2zvzrt2HOz9vYEInts,4529
@@ -334,9 +334,9 @@ model_compression_toolkit/exporter/model_exporter/keras/int8_tflite_exporter.py,
334
334
  model_compression_toolkit/exporter/model_exporter/keras/keras_export_facade.py,sha256=NzcX7rxLk__Kpuim_VXaOHS4tyiRtRBoERPE00GbdfA,5862
335
335
  model_compression_toolkit/exporter/model_exporter/keras/mctq_keras_exporter.py,sha256=qXXkv3X_wb7t622EOHwXIxfGLGaDqh0T0y4UxREi4Bo,1976
336
336
  model_compression_toolkit/exporter/model_exporter/pytorch/__init__.py,sha256=uZ2RigbY9O2PJ0Il8wPpS_s7frgg9WUGd_SHeKGyl1A,699
337
- model_compression_toolkit/exporter/model_exporter/pytorch/base_pytorch_exporter.py,sha256=sCfK6wXWFgMW0dUaRgWhLc0GUiCHTU-H16I17-XNJu0,6360
337
+ model_compression_toolkit/exporter/model_exporter/pytorch/base_pytorch_exporter.py,sha256=9adOGG1nyviNzuL-1aJXyL0c_VQllSZWiG2gR-puywo,6420
338
338
  model_compression_toolkit/exporter/model_exporter/pytorch/export_serialization_format.py,sha256=bPevy6OBqng41PqytBR55e6cBEuyrUS0H8dWX4zgjQ4,967
339
- model_compression_toolkit/exporter/model_exporter/pytorch/fakely_quant_onnx_pytorch_exporter.py,sha256=v6DwLNZX5RcWHUfYXfJZXNFXPfHsMm5Wl0N29o0diSc,8856
339
+ model_compression_toolkit/exporter/model_exporter/pytorch/fakely_quant_onnx_pytorch_exporter.py,sha256=5S3lyNVc3F62mvS8Q-RTmgQXWI6GWZ5YRvjG4qFy2MM,9520
340
340
  model_compression_toolkit/exporter/model_exporter/pytorch/fakely_quant_torchscript_pytorch_exporter.py,sha256=ksWV2A-Njo-wAxQ_Ye2sLIZXBWJ_WNyjT7-qFFwvV2o,2897
341
341
  model_compression_toolkit/exporter/model_exporter/pytorch/pytorch_export_facade.py,sha256=7xuUrHPMiifn23sWfeiqR9wkYhm8EweDRL_vF-JSxMY,6642
342
342
  model_compression_toolkit/exporter/model_wrapper/__init__.py,sha256=7CF2zvpTrIEm8qnbuHnLZyTZkwBBxV24V8QA0oxGbh0,1187
@@ -529,7 +529,7 @@ model_compression_toolkit/xquant/pytorch/model_analyzer.py,sha256=b93o800yVB3Z-i
529
529
  model_compression_toolkit/xquant/pytorch/pytorch_report_utils.py,sha256=UVN_S9ULHBEldBpShCOt8-soT8YTQ5oE362y96qF_FA,3950
530
530
  model_compression_toolkit/xquant/pytorch/similarity_functions.py,sha256=CERxq5K8rqaiE-DlwhZBTUd9x69dtYJlkHOPLB54vm8,2354
531
531
  model_compression_toolkit/xquant/pytorch/tensorboard_utils.py,sha256=mkoEktLFFHtEKzzFRn_jCnxjhJolK12TZ5AQeDHzUO8,9767
532
- mct_nightly-2.4.0.20250605.606.dist-info/METADATA,sha256=lpXR9ECa1ziVfo4rUtBZsGmZPS--wjUOfVw-1emCUqg,25087
533
- mct_nightly-2.4.0.20250605.606.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
534
- mct_nightly-2.4.0.20250605.606.dist-info/top_level.txt,sha256=gsYA8juk0Z-ZmQRKULkb3JLGdOdz8jW_cMRjisn9ga4,26
535
- mct_nightly-2.4.0.20250605.606.dist-info/RECORD,,
532
+ mct_nightly-2.4.0.20250605.151156.dist-info/METADATA,sha256=mw_6NFD665X2EECv7pw8PTTnwnhNNyVh5skSnLTlmtw,25090
533
+ mct_nightly-2.4.0.20250605.151156.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
534
+ mct_nightly-2.4.0.20250605.151156.dist-info/top_level.txt,sha256=gsYA8juk0Z-ZmQRKULkb3JLGdOdz8jW_cMRjisn9ga4,26
535
+ mct_nightly-2.4.0.20250605.151156.dist-info/RECORD,,
@@ -27,4 +27,4 @@ from model_compression_toolkit import data_generation
27
27
  from model_compression_toolkit import pruning
28
28
  from model_compression_toolkit.trainable_infrastructure.keras.load_model import keras_load_quantized_model
29
29
 
30
- __version__ = "2.4.0.20250605.000606"
30
+ __version__ = "2.4.0.20250605.151156"
@@ -56,7 +56,7 @@ def find_and_assign_metadata_attr(model: torch.nn.Module, attr_name: str = 'meta
56
56
  f"Only the first one was assigned to 'model.metadata'.")
57
57
 
58
58
 
59
- def _set_quantized_weights_in_wrapper(layer:PytorchQuantizationWrapper):
59
+ def _set_quantized_weights_in_wrapper(layer: PytorchQuantizationWrapper):
60
60
  """
61
61
  Sets the quantized weights in the provided PytorchQuantizationWrapper layer.
62
62
  Replaces the original weights in the layer with the quantized weights.
@@ -124,7 +124,7 @@ class BasePyTorchExporter(Exporter):
124
124
  self.model = copy.deepcopy(self.model)
125
125
  self.repr_dataset = repr_dataset
126
126
 
127
- def _substitute_fully_quantized_model(self):
127
+ def _substitute_fully_quantized_model(self, replace_wrapped=True):
128
128
  """
129
129
  Substitution for pytorch "fully-quantized" models. It first uses the weight quantizers
130
130
  in PytorchQuantizationWrapper layers to quantize the weights and set them in the layer.
@@ -136,8 +136,9 @@ class BasePyTorchExporter(Exporter):
136
136
  if isinstance(layer, PytorchQuantizationWrapper):
137
137
  _set_quantized_weights_in_wrapper(layer)
138
138
 
139
- # Replace PytorchQuantizationWrapper layers with their internal layers
140
- self._replace_wrapped_with_unwrapped()
139
+ if replace_wrapped:
140
+ # Replace PytorchQuantizationWrapper layers with their internal layers
141
+ self._replace_wrapped_with_unwrapped()
141
142
 
142
143
  def _replace_wrapped_with_unwrapped(self):
143
144
  """
@@ -148,3 +149,4 @@ class BasePyTorchExporter(Exporter):
148
149
  for name, module in self.model.named_children():
149
150
  if isinstance(module, PytorchQuantizationWrapper):
150
151
  setattr(self.model, name, module.layer)
152
+
@@ -73,6 +73,15 @@ if FOUND_ONNX:
73
73
  Returns:
74
74
  Fake-quant PyTorch model.
75
75
  """
76
+ # List all activation quantization holders with num_bits>8 and replace them with Identity, because
77
+ # ONNX doesn't support quantization of more than 8 bits for torch.fake_quantize_per_tensor_affine.
78
+ act_holder_list = [n for n, m in self.model.named_modules()
79
+ if isinstance(m, PytorchActivationQuantizationHolder) and
80
+ m.activation_holder_quantizer.num_bits > 8]
81
+ for act_holder in act_holder_list: # pragma: no cover
82
+ delattr(self.model, act_holder)
83
+ setattr(self.model, act_holder, torch.nn.Identity())
84
+
76
85
  for layer in self.model.children():
77
86
  self.is_layer_exportable_fn(layer)
78
87
  # Set reuse for weight quantizers if quantizer is reused
@@ -89,7 +98,7 @@ if FOUND_ONNX:
89
98
  if self._use_onnx_custom_quantizer_ops:
90
99
  self._enable_onnx_custom_ops_export()
91
100
  else:
92
- self._substitute_fully_quantized_model()
101
+ self._substitute_fully_quantized_model(replace_wrapped=False)
93
102
 
94
103
  if self._use_onnx_custom_quantizer_ops:
95
104
  Logger.info(f"Exporting onnx model with MCTQ quantizers: {self.save_model_path}")
@@ -166,6 +175,6 @@ if FOUND_ONNX:
166
175
  wq.enable_custom_impl()
167
176
 
168
177
  else:
169
- def FakelyQuantONNXPyTorchExporter(*args, **kwargs):
178
+ def FakelyQuantONNXPyTorchExporter(*args, **kwargs): # pragma: no cover
170
179
  Logger.critical("ONNX must be installed to use 'FakelyQuantONNXPyTorchExporter'. "
171
- "The 'onnx' package is missing.") # pragma: no cover
180
+ "The 'onnx' package is missing.")