mct-nightly 2.3.0.20250424.534__py3-none-any.whl → 2.3.0.20250426.524__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.
- {mct_nightly-2.3.0.20250424.534.dist-info → mct_nightly-2.3.0.20250426.524.dist-info}/METADATA +1 -1
- {mct_nightly-2.3.0.20250424.534.dist-info → mct_nightly-2.3.0.20250426.524.dist-info}/RECORD +9 -9
- model_compression_toolkit/__init__.py +1 -1
- model_compression_toolkit/core/common/quantization/set_node_quantization_config.py +10 -5
- model_compression_toolkit/core/common/substitutions/shift_negative_activation.py +7 -7
- model_compression_toolkit/core/pytorch/back2framework/pytorch_model_builder.py +29 -7
- {mct_nightly-2.3.0.20250424.534.dist-info → mct_nightly-2.3.0.20250426.524.dist-info}/WHEEL +0 -0
- {mct_nightly-2.3.0.20250424.534.dist-info → mct_nightly-2.3.0.20250426.524.dist-info}/licenses/LICENSE.md +0 -0
- {mct_nightly-2.3.0.20250424.534.dist-info → mct_nightly-2.3.0.20250426.524.dist-info}/top_level.txt +0 -0
{mct_nightly-2.3.0.20250424.534.dist-info → mct_nightly-2.3.0.20250426.524.dist-info}/METADATA
RENAMED
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: mct-nightly
|
3
|
-
Version: 2.3.0.
|
3
|
+
Version: 2.3.0.20250426.524
|
4
4
|
Summary: A Model Compression Toolkit for neural networks
|
5
5
|
Classifier: Programming Language :: Python :: 3
|
6
6
|
Classifier: License :: OSI Approved :: Apache Software License
|
{mct_nightly-2.3.0.20250424.534.dist-info → mct_nightly-2.3.0.20250426.524.dist-info}/RECORD
RENAMED
@@ -1,5 +1,5 @@
|
|
1
|
-
mct_nightly-2.3.0.
|
2
|
-
model_compression_toolkit/__init__.py,sha256=
|
1
|
+
mct_nightly-2.3.0.20250426.524.dist-info/licenses/LICENSE.md,sha256=aYSSIb-5AFPeITTvXm1UAoe0uYBiMmSS8flvXaaFUks,10174
|
2
|
+
model_compression_toolkit/__init__.py,sha256=u4NAaox4mWCLO1P2VUBGICSwqHFGboDDlwkRKJJADa8,1557
|
3
3
|
model_compression_toolkit/constants.py,sha256=iJ6vfTjC2oFIZWt8wvHoxEw5YJi3yl0Hd4q30_8q0Zc,3958
|
4
4
|
model_compression_toolkit/defaultdict.py,sha256=LSc-sbZYXENMCw3U9F4GiXuv67IKpdn0Qm7Fr11jy-4,2277
|
5
5
|
model_compression_toolkit/logger.py,sha256=L3q7tn3Uht0i_7phnlOWMR2Te2zvzrt2HOz9vYEInts,4529
|
@@ -112,7 +112,7 @@ model_compression_toolkit/core/common/quantization/quantization_fn_selection.py,
|
|
112
112
|
model_compression_toolkit/core/common/quantization/quantization_params_fn_selection.py,sha256=7eG7dl1TcbdnHwgmvyjarxLs0o6Lw_9VAjXAm4rsiBk,3791
|
113
113
|
model_compression_toolkit/core/common/quantization/quantize_graph_weights.py,sha256=N005MSvx8UypVpa7XrxNrB2G732n2wHj3RmLyjTgd3I,2728
|
114
114
|
model_compression_toolkit/core/common/quantization/quantize_node.py,sha256=cdzGNWfT4MRogIU8ehs0tr3lVjnzAI-jeoS9b4TwVBo,2854
|
115
|
-
model_compression_toolkit/core/common/quantization/set_node_quantization_config.py,sha256=
|
115
|
+
model_compression_toolkit/core/common/quantization/set_node_quantization_config.py,sha256=76BjqZbeRz7zIblKxGp-AUkHOt-KZMlYjsXP8Ph-1jc,30943
|
116
116
|
model_compression_toolkit/core/common/quantization/quantization_params_generation/__init__.py,sha256=eCDGwsWYLU6z7qbEVb4TozMW_nd5VEP_iCJ6PcvyEPw,1486
|
117
117
|
model_compression_toolkit/core/common/quantization/quantization_params_generation/error_functions.py,sha256=_m-XkEMJMHf0gYwVIXAoHVjdRa2NXt_gYdwBlw76ZR8,24031
|
118
118
|
model_compression_toolkit/core/common/quantization/quantization_params_generation/lut_kmeans_params.py,sha256=RL-PklAjGyC-26anSt8fU07a6pB_LBQFQy9o4e9giN0,8739
|
@@ -145,7 +145,7 @@ model_compression_toolkit/core/common/substitutions/linear_collapsing_substituti
|
|
145
145
|
model_compression_toolkit/core/common/substitutions/remove_identity.py,sha256=TKU1TIU52UIkVnl0EZvWnDhLV9nIVZ4hqi-w1i4NXMk,2637
|
146
146
|
model_compression_toolkit/core/common/substitutions/residual_collapsing.py,sha256=N82mso5j3EJQlKt9EMHjjEJ67FmdGQeCfN8U5grOFXo,4830
|
147
147
|
model_compression_toolkit/core/common/substitutions/scale_equalization.py,sha256=p57u25qdW2pimxzGwgMXEBV4S-LzXuTVAlIM7830WfU,10966
|
148
|
-
model_compression_toolkit/core/common/substitutions/shift_negative_activation.py,sha256=
|
148
|
+
model_compression_toolkit/core/common/substitutions/shift_negative_activation.py,sha256=zCkdyZHEkbxkORmd071_XWajkpIhnDq9D6FyeE4TQjc,30057
|
149
149
|
model_compression_toolkit/core/common/substitutions/softmax_shift.py,sha256=R-0ZqhYAuZLEFWHvB2UTPm52L6gWHGdRdEnwGxKSeGI,2625
|
150
150
|
model_compression_toolkit/core/common/substitutions/virtual_activation_weights_composition.py,sha256=w43dRmaG96a8SNECgghxoFCTSoZ-vUb33dXGm2PbomE,4251
|
151
151
|
model_compression_toolkit/core/common/substitutions/weights_activation_split.py,sha256=gt07lXRUvYunJKiwv_w20zfXhcplSW4oT2C1dqiNNXc,4719
|
@@ -233,7 +233,7 @@ model_compression_toolkit/core/pytorch/back2framework/factory_model_builder.py,s
|
|
233
233
|
model_compression_toolkit/core/pytorch/back2framework/float_model_builder.py,sha256=tLrlUyYhxVKVjkad1ZAtbRra0HedB3iVfIkZ_dYnQ-4,3419
|
234
234
|
model_compression_toolkit/core/pytorch/back2framework/instance_builder.py,sha256=BBHBfTqeWm7L3iDyPBpk0jxvj-rBg1QWI23imkjfIl0,1467
|
235
235
|
model_compression_toolkit/core/pytorch/back2framework/mixed_precision_model_builder.py,sha256=K4L8FzJFM8_Ge2MHYkSqzCtoZe-ejEhVq8C1RgecyOc,14531
|
236
|
-
model_compression_toolkit/core/pytorch/back2framework/pytorch_model_builder.py,sha256=
|
236
|
+
model_compression_toolkit/core/pytorch/back2framework/pytorch_model_builder.py,sha256=9l5ZsEd4lwCSzT6VNItj5rw996BI_eH71x_uV-4gIRM,21101
|
237
237
|
model_compression_toolkit/core/pytorch/back2framework/quantized_model_builder.py,sha256=qZNNOlNTTV4ZKPG3q5GDXkIVTPUEr8dvxAS_YiMORmg,3456
|
238
238
|
model_compression_toolkit/core/pytorch/back2framework/quantization_wrapper/__init__.py,sha256=cco4TmeIDIh32nj9ZZXVkws4dd9F2UDrmjKzTN8G0V0,697
|
239
239
|
model_compression_toolkit/core/pytorch/back2framework/quantization_wrapper/quantized_layer_wrapper.py,sha256=q2JDw10NKng50ee2i9faGzWZ-IydnR2aOMGSn9RoZmc,5773
|
@@ -528,7 +528,7 @@ model_compression_toolkit/xquant/pytorch/model_analyzer.py,sha256=b93o800yVB3Z-i
|
|
528
528
|
model_compression_toolkit/xquant/pytorch/pytorch_report_utils.py,sha256=UVN_S9ULHBEldBpShCOt8-soT8YTQ5oE362y96qF_FA,3950
|
529
529
|
model_compression_toolkit/xquant/pytorch/similarity_functions.py,sha256=CERxq5K8rqaiE-DlwhZBTUd9x69dtYJlkHOPLB54vm8,2354
|
530
530
|
model_compression_toolkit/xquant/pytorch/tensorboard_utils.py,sha256=mkoEktLFFHtEKzzFRn_jCnxjhJolK12TZ5AQeDHzUO8,9767
|
531
|
-
mct_nightly-2.3.0.
|
532
|
-
mct_nightly-2.3.0.
|
533
|
-
mct_nightly-2.3.0.
|
534
|
-
mct_nightly-2.3.0.
|
531
|
+
mct_nightly-2.3.0.20250426.524.dist-info/METADATA,sha256=iIA-rsewTrMqkLA5MRDESRmAWOwkY25inok3LAYZvWM,25560
|
532
|
+
mct_nightly-2.3.0.20250426.524.dist-info/WHEEL,sha256=SmOxYU7pzNKBqASvQJ7DjX3XGUF92lrGhMb3R6_iiqI,91
|
533
|
+
mct_nightly-2.3.0.20250426.524.dist-info/top_level.txt,sha256=gsYA8juk0Z-ZmQRKULkb3JLGdOdz8jW_cMRjisn9ga4,26
|
534
|
+
mct_nightly-2.3.0.20250426.524.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.3.0.
|
30
|
+
__version__ = "2.3.0.20250426.000524"
|
@@ -119,11 +119,16 @@ def filter_node_qco_by_graph(node: BaseNode,
|
|
119
119
|
_next_nodes.extend(graph.get_next_nodes(n))
|
120
120
|
next_nodes.append(n)
|
121
121
|
|
122
|
-
if len(next_nodes):
|
123
|
-
|
124
|
-
|
122
|
+
if len(next_nodes) == 0:
|
123
|
+
return _base_config, _node_qc_options
|
124
|
+
next_nodes_qc_options = [_node.get_qco(fqc) for _node in next_nodes]
|
125
|
+
all_next_nodes_supported_input_bitwidth = [max_input_activation_n_bits(op_cfg)
|
125
126
|
for qc_opts in next_nodes_qc_options
|
126
|
-
for op_cfg in qc_opts.quantization_configurations
|
127
|
+
for op_cfg in qc_opts.quantization_configurations
|
128
|
+
if op_cfg.enable_activation_quantization or op_cfg.quantization_preserving
|
129
|
+
]
|
130
|
+
if len(all_next_nodes_supported_input_bitwidth):
|
131
|
+
next_nodes_supported_input_bitwidth = min(all_next_nodes_supported_input_bitwidth)
|
127
132
|
|
128
133
|
# Filter node's QC options that match next nodes input bit-width.
|
129
134
|
_node_qc_options = [_option for _option in _node_qc_options
|
@@ -205,7 +210,7 @@ def set_quantization_configs_to_node(node: BaseNode,
|
|
205
210
|
# Preserving the quantization of more than 1 previous node is ambiguous, so disable it.
|
206
211
|
Logger.info(f"Disabling Quantization-Preserving for node {node.name} because it has more than 1 input activations.")
|
207
212
|
candidate_qc.activation_quantization_cfg.quant_mode = ActivationQuantizationMode.NO_QUANT
|
208
|
-
elif not prev_nodes[0].is_quantization_preserving()
|
213
|
+
elif not prev_nodes[0].is_quantization_preserving() and not prev_nodes[0].is_activation_quantization_enabled():
|
209
214
|
# Preserving the quantization of an unquantized node isn't possible, so disable it.
|
210
215
|
Logger.info(f"Disabling Quantization-Preserving for node {node.name} because previous node activation quantization is disabled.")
|
211
216
|
candidate_qc.activation_quantization_cfg.quant_mode = ActivationQuantizationMode.NO_QUANT
|
@@ -343,6 +343,13 @@ def shift_negative_function(graph: Graph,
|
|
343
343
|
graph.set_out_stats_collector_to_node(add_node, add_node_stats_collector)
|
344
344
|
graph.shift_stats_collector(add_node, np.array(shift_value))
|
345
345
|
|
346
|
+
set_quantization_configs_to_node(fw_info=fw_info,
|
347
|
+
node=add_node,
|
348
|
+
graph=graph,
|
349
|
+
quant_config=core_config.quantization_config,
|
350
|
+
fqc=graph.fqc,
|
351
|
+
mixed_precision_enable=core_config.is_mixed_precision_enabled)
|
352
|
+
|
346
353
|
if padding is not None:
|
347
354
|
pad_node = create_pad_node(op2d_node.name,
|
348
355
|
add_node.name,
|
@@ -373,13 +380,6 @@ def shift_negative_function(graph: Graph,
|
|
373
380
|
|
374
381
|
op2d_node.input_shape = pad_node.output_shape
|
375
382
|
|
376
|
-
set_quantization_configs_to_node(fw_info=fw_info,
|
377
|
-
node=add_node,
|
378
|
-
graph=graph,
|
379
|
-
quant_config=core_config.quantization_config,
|
380
|
-
fqc=graph.fqc,
|
381
|
-
mixed_precision_enable=core_config.is_mixed_precision_enabled)
|
382
|
-
|
383
383
|
original_non_linear_activation_nbits = non_linear_node_cfg_candidate.activation_n_bits
|
384
384
|
# The non-linear node's output should be float, so we approximate it by using 16bits quantization.
|
385
385
|
for candidate_qc in non_linear_node.candidates_quantization_cfg:
|
@@ -234,7 +234,9 @@ class PytorchModel(torch.nn.Module):
|
|
234
234
|
self.wrapper = wrapper
|
235
235
|
self.get_activation_quantizer_holder = get_activation_quantizer_holder_fn
|
236
236
|
self.reuse_groups = {}
|
237
|
-
self.
|
237
|
+
self._reused_nodes = []
|
238
|
+
|
239
|
+
self._add_all_modules()
|
238
240
|
|
239
241
|
# todo: Move to parent class BaseModelBuilder
|
240
242
|
@property
|
@@ -286,17 +288,37 @@ class PytorchModel(torch.nn.Module):
|
|
286
288
|
node_op = self.wrapper(node, node_builder(node))
|
287
289
|
return node_op
|
288
290
|
|
289
|
-
def
|
291
|
+
def _add_all_modules(self):
|
292
|
+
"""
|
293
|
+
Build and add the modules and functional nodes from node_sort list as attributes to PytorchModel.
|
294
|
+
To assure all required nodes for the reused nodes are already initialized, adds none-reused nodes first,
|
295
|
+
then adds the reused nodes.
|
296
|
+
"""
|
297
|
+
self._add_modules(reused_nodes_only=False) # add none-reused nodes
|
298
|
+
self._add_modules(reused_nodes_only=True) # add reused nodes
|
299
|
+
|
300
|
+
def _add_modules(self, reused_nodes_only=False):
|
290
301
|
"""
|
291
302
|
Build and add the modules and functional nodes from node_sort list as attributes to PytorchModel
|
303
|
+
Args:
|
304
|
+
reused_nodes_only: whether to go over the reuse nodes list or not.
|
305
|
+
In case reuse_nodes_only is False - will go over all nodes, and add reused nodes to self._reused_nodes
|
306
|
+
In case reuse_nodes_only is True - will go over self._reused_nodes only.
|
307
|
+
|
292
308
|
"""
|
293
|
-
|
294
|
-
|
295
|
-
|
309
|
+
nodes = self._reused_nodes if reused_nodes_only else self.node_sort
|
310
|
+
for node in nodes:
|
311
|
+
if node.reuse and reused_nodes_only:
|
296
312
|
if node.reuse_group not in self.reuse_groups:
|
297
|
-
|
313
|
+
raise Exception(f"Reuse group {node.reuse_group} not found for node {node.name}. "
|
314
|
+
f"Make sure you first call the method with reused_nodes_only=False")
|
315
|
+
else:
|
316
|
+
node_op = self.reuse_groups[node.reuse_group] # retrieve the original module
|
317
|
+
|
318
|
+
elif node.reuse: # add node to reused list, and go over the list after all other nodes were created
|
319
|
+
self._reused_nodes.append(node)
|
320
|
+
continue
|
298
321
|
|
299
|
-
node_op = self.reuse_groups[node.reuse_group]
|
300
322
|
else:
|
301
323
|
# If it's not reused, create a new module
|
302
324
|
node_op = self.wrap(node)
|
File without changes
|
File without changes
|
{mct_nightly-2.3.0.20250424.534.dist-info → mct_nightly-2.3.0.20250426.524.dist-info}/top_level.txt
RENAMED
File without changes
|