mct-nightly 2.2.0.20241030.505__py3-none-any.whl → 2.2.0.20241101.532__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.1
2
2
  Name: mct-nightly
3
- Version: 2.2.0.20241030.505
3
+ Version: 2.2.0.20241101.532
4
4
  Summary: A Model Compression Toolkit for neural networks
5
5
  Home-page: UNKNOWN
6
6
  License: UNKNOWN
@@ -1,4 +1,4 @@
1
- model_compression_toolkit/__init__.py,sha256=TIarpxVdU_SeymMap8cBKo1tIuj6XQFjDhMwO-5o8XQ,1573
1
+ model_compression_toolkit/__init__.py,sha256=LOlTR7_5Hf3TRvNgu5Y_8a2hjaVGdzEOYKxvqq4feMo,1573
2
2
  model_compression_toolkit/constants.py,sha256=i4wYheBkIdQmsQA-axIpcT3YiSO1USNc-jaNiNE8w6E,3920
3
3
  model_compression_toolkit/defaultdict.py,sha256=LSc-sbZYXENMCw3U9F4GiXuv67IKpdn0Qm7Fr11jy-4,2277
4
4
  model_compression_toolkit/logger.py,sha256=3DByV41XHRR3kLTJNbpaMmikL8icd9e1N-nkQAY9oDk,4567
@@ -62,7 +62,7 @@ model_compression_toolkit/core/common/mixed_precision/__init__.py,sha256=sw7LOPN
62
62
  model_compression_toolkit/core/common/mixed_precision/bit_width_setter.py,sha256=iPuI11f3IkroC-dStdR40vKn4jpa1VL-kskCXc5z7wk,7536
63
63
  model_compression_toolkit/core/common/mixed_precision/configurable_quant_id.py,sha256=LLDguK7afsbN742ucLpmJr5TUfTyFpK1vbf2bpVr1v0,882
64
64
  model_compression_toolkit/core/common/mixed_precision/configurable_quantizer_utils.py,sha256=7dKMi5S0zQZ16m8NWn1XIuoXsKuZUg64G4-uK8-j1PQ,5177
65
- model_compression_toolkit/core/common/mixed_precision/distance_weighting.py,sha256=H8qYkJsk88OszUJo-Zde7vTmWiypLTg9KbbzIZ-hhvM,2812
65
+ model_compression_toolkit/core/common/mixed_precision/distance_weighting.py,sha256=-x8edUyudu1EAEM66AuXPtgayLpzbxoLNubfEbFM5kU,2867
66
66
  model_compression_toolkit/core/common/mixed_precision/mixed_precision_candidates_filter.py,sha256=klmaMQDeFc3IxRLf6YX4Dw1opFksbLyN10yFHdKAtLo,4875
67
67
  model_compression_toolkit/core/common/mixed_precision/mixed_precision_quantization_config.py,sha256=r1t025_QHshyoop-PZvL7x6UuXaeplCCU3h4VNBhJHo,4309
68
68
  model_compression_toolkit/core/common/mixed_precision/mixed_precision_search_facade.py,sha256=pk8HRoShDhiUprBC4m1AFQv1SacS4hOrj0MRdbq-5gY,7556
@@ -72,7 +72,7 @@ model_compression_toolkit/core/common/mixed_precision/set_layer_to_bitwidth.py,s
72
72
  model_compression_toolkit/core/common/mixed_precision/solution_refinement_procedure.py,sha256=KifDMbm7qkSfvSl6pcZzQ82naIXzeKL6aT-VsvWZYyc,7901
73
73
  model_compression_toolkit/core/common/mixed_precision/resource_utilization_tools/__init__.py,sha256=Rf1RcYmelmdZmBV5qOKvKWF575ofc06JFQSq83Jz99A,696
74
74
  model_compression_toolkit/core/common/mixed_precision/resource_utilization_tools/resource_utilization.py,sha256=HILF7CIn-GYPvPmTFyvjWLhuLDwSGwdBcAaKFgVYrwk,4745
75
- model_compression_toolkit/core/common/mixed_precision/resource_utilization_tools/resource_utilization_data.py,sha256=3ZOI-RNp5faT-U2Og7rLW9EKwBB6ooa7-RwSsWJmquo,14022
75
+ model_compression_toolkit/core/common/mixed_precision/resource_utilization_tools/resource_utilization_data.py,sha256=1y-Uy60FKbH0B3MDX0sTD4NGqoOU3jyYUQdiF3o-cFw,14893
76
76
  model_compression_toolkit/core/common/mixed_precision/resource_utilization_tools/ru_aggregation_methods.py,sha256=ttc8wPa_9LZansutQ2f1ss-RTzgTv739wy3qsdLzyyk,4217
77
77
  model_compression_toolkit/core/common/mixed_precision/resource_utilization_tools/ru_functions_mapping.py,sha256=QhuqaECEGLnYC08iD6-2XXcU7NXbPzYf1sQcjYlGak8,1682
78
78
  model_compression_toolkit/core/common/mixed_precision/resource_utilization_tools/ru_methods.py,sha256=WC1EHoNuo_lrzy4NRhGJ1cgmJ2IsFsbmP86mrVO3AVA,21506
@@ -111,7 +111,7 @@ model_compression_toolkit/core/common/quantization/quantization_fn_selection.py,
111
111
  model_compression_toolkit/core/common/quantization/quantization_params_fn_selection.py,sha256=MwIOBZ4BlZSTIOG75PDvlI3JmZ6t8YjPc1VP9Adei60,3847
112
112
  model_compression_toolkit/core/common/quantization/quantize_graph_weights.py,sha256=N005MSvx8UypVpa7XrxNrB2G732n2wHj3RmLyjTgd3I,2728
113
113
  model_compression_toolkit/core/common/quantization/quantize_node.py,sha256=cdzGNWfT4MRogIU8ehs0tr3lVjnzAI-jeoS9b4TwVBo,2854
114
- model_compression_toolkit/core/common/quantization/set_node_quantization_config.py,sha256=IjqFX0EGk4YCTaQsJp4-UycCVc2Ec6GTbu890dkGVns,21318
114
+ model_compression_toolkit/core/common/quantization/set_node_quantization_config.py,sha256=cclpyw9uDe0rXmM6AReH0Q-7SAvft9ksumRXoB5kQUc,21149
115
115
  model_compression_toolkit/core/common/quantization/quantization_params_generation/__init__.py,sha256=eCDGwsWYLU6z7qbEVb4TozMW_nd5VEP_iCJ6PcvyEPw,1486
116
116
  model_compression_toolkit/core/common/quantization/quantization_params_generation/error_functions.py,sha256=fzUvqmXVgzp_IV5ER-20kKzl4m8U_shZsAKs-ehhjFo,23887
117
117
  model_compression_toolkit/core/common/quantization/quantization_params_generation/lut_kmeans_params.py,sha256=RL-PklAjGyC-26anSt8fU07a6pB_LBQFQy9o4e9giN0,8739
@@ -570,8 +570,8 @@ tests_pytest/pytorch/gptq/test_annealing_cfg.py,sha256=hGC7L6mp3N1ygcJ3OctgS_Fz2
570
570
  tests_pytest/pytorch/gptq/test_gradual_act_quantization.py,sha256=Dg2cg1X8u9Jxm7Y6tlZIGH81EPoW_vYorcdDExdj02w,4630
571
571
  tests_pytest/pytorch/trainable_infrastructure/__init__.py,sha256=RAe8mgIr1V8dRIQtLf_dSG5zTUCKuQzxyybYx1dzEAs,697
572
572
  tests_pytest/pytorch/trainable_infrastructure/test_linear_annealing.py,sha256=zErt9tOu7oupjpv08cvd1Cxvdk9qvP7GMUP6EhefK0c,1814
573
- mct_nightly-2.2.0.20241030.505.dist-info/LICENSE.md,sha256=aYSSIb-5AFPeITTvXm1UAoe0uYBiMmSS8flvXaaFUks,10174
574
- mct_nightly-2.2.0.20241030.505.dist-info/METADATA,sha256=qsOde1itXo-3-_7ZxVb1WRYi2y3mzNyq-ei-JidqgqM,20830
575
- mct_nightly-2.2.0.20241030.505.dist-info/WHEEL,sha256=eOLhNAGa2EW3wWl_TU484h7q1UNgy0JXjjoqKoxAAQc,92
576
- mct_nightly-2.2.0.20241030.505.dist-info/top_level.txt,sha256=csdfSXhtRnpWYRzjZ-dRLIhOmM2TEdVXUxG05A5fgb8,39
577
- mct_nightly-2.2.0.20241030.505.dist-info/RECORD,,
573
+ mct_nightly-2.2.0.20241101.532.dist-info/LICENSE.md,sha256=aYSSIb-5AFPeITTvXm1UAoe0uYBiMmSS8flvXaaFUks,10174
574
+ mct_nightly-2.2.0.20241101.532.dist-info/METADATA,sha256=-KcA4QsljqwU33XyaBeGMdZz_S4GxsfkJ2eHRkEqpWw,20830
575
+ mct_nightly-2.2.0.20241101.532.dist-info/WHEEL,sha256=eOLhNAGa2EW3wWl_TU484h7q1UNgy0JXjjoqKoxAAQc,92
576
+ mct_nightly-2.2.0.20241101.532.dist-info/top_level.txt,sha256=csdfSXhtRnpWYRzjZ-dRLIhOmM2TEdVXUxG05A5fgb8,39
577
+ mct_nightly-2.2.0.20241101.532.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.2.0.20241030.000505"
30
+ __version__ = "2.2.0.20241101.000532"
@@ -71,3 +71,6 @@ class MpDistanceWeighting(Enum):
71
71
 
72
72
  def __call__(self, distance_matrix: np.ndarray) -> np.ndarray:
73
73
  return self.value(distance_matrix)
74
+
75
+ def __deepcopy__(self, memo):
76
+ return self
@@ -12,11 +12,13 @@
12
12
  # See the License for the specific language governing permissions and
13
13
  # limitations under the License.
14
14
  # ==============================================================================
15
+ import copy
16
+
15
17
  import numpy as np
16
18
  from typing import Callable, Any, Dict, Tuple
17
19
 
18
20
  from model_compression_toolkit.constants import FLOAT_BITWIDTH, BITS_TO_BYTES
19
- from model_compression_toolkit.core import FrameworkInfo, ResourceUtilization, CoreConfig
21
+ from model_compression_toolkit.core import FrameworkInfo, ResourceUtilization, CoreConfig, QuantizationErrorMethod
20
22
  from model_compression_toolkit.core.common import Graph
21
23
  from model_compression_toolkit.core.common.framework_implementation import FrameworkImplementation
22
24
  from model_compression_toolkit.core.common.graph.edge import EDGE_SINK_INDEX
@@ -57,7 +59,7 @@ def compute_resource_utilization_data(in_model: Any,
57
59
 
58
60
 
59
61
  """
60
-
62
+ core_config = _create_core_config_for_ru(core_config)
61
63
  # We assume that the resource_utilization_data API is used to compute the model resource utilization for
62
64
  # mixed precision scenario, so we run graph preparation under the assumption of enabled mixed precision.
63
65
  if transformed_graph is None:
@@ -222,6 +224,8 @@ def requires_mixed_precision(in_model: Any,
222
224
  Returns: A boolean indicating if mixed precision is needed.
223
225
  """
224
226
  is_mixed_precision = False
227
+ core_config = _create_core_config_for_ru(core_config)
228
+
225
229
  transformed_graph = graph_preparation_runner(in_model,
226
230
  representative_data_gen,
227
231
  core_config.quantization_config,
@@ -247,3 +251,21 @@ def requires_mixed_precision(in_model: Any,
247
251
  is_mixed_precision |= target_resource_utilization.total_memory < total_weights_memory_bytes + max_activation_tensor_size_bytes
248
252
  is_mixed_precision |= target_resource_utilization.bops < bops_count
249
253
  return is_mixed_precision
254
+
255
+
256
+ def _create_core_config_for_ru(core_config: CoreConfig) -> CoreConfig:
257
+ """
258
+ Create a core config to use for resource utilization computation.
259
+
260
+ Args:
261
+ core_config: input core config
262
+
263
+ Returns:
264
+ Core config for resource utilization.
265
+ """
266
+ core_config = copy.deepcopy(core_config)
267
+ # For resource utilization graph_preparation_runner runs with gptq=False (the default value). HMSE is not supported
268
+ # without GPTQ and will raise an error later so we replace it with MSE.
269
+ if core_config.quantization_config.weights_error_method == QuantizationErrorMethod.HMSE:
270
+ core_config.quantization_config.weights_error_method = QuantizationErrorMethod.MSE
271
+ return core_config
@@ -58,13 +58,10 @@ def set_quantization_configuration_to_graph(graph: Graph,
58
58
 
59
59
  if quant_config.weights_error_method == QuantizationErrorMethod.HMSE:
60
60
  if not running_gptq:
61
- Logger.warning(f"The HMSE error method for parameters selection is only supported when running GPTQ "
62
- f"optimization due to long execution time that is not suitable for basic PTQ. "
63
- f"Using the default MSE error method instead.")
64
- quant_config.weights_error_method = QuantizationErrorMethod.MSE
65
- else:
66
- Logger.warning("Using the HMSE error method for weights quantization parameters search. "
67
- "Note: This method may significantly increase runtime during the parameter search process.")
61
+ raise ValueError(f"The HMSE error method for parameters selection is only supported when running GPTQ "
62
+ f"optimization due to long execution time that is not suitable for basic PTQ.")
63
+ Logger.warning("Using the HMSE error method for weights quantization parameters search. "
64
+ "Note: This method may significantly increase runtime during the parameter search process.")
68
65
 
69
66
  nodes_to_manipulate_bit_widths = {} if bit_width_config is None else bit_width_config.get_nodes_to_manipulate_bit_widths(graph)
70
67