mct-nightly 2.3.0.20250405.519__py3-none-any.whl → 2.3.0.20250407.1120__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.20250405.519.dist-info → mct_nightly-2.3.0.20250407.1120.dist-info}/METADATA +1 -1
- {mct_nightly-2.3.0.20250405.519.dist-info → mct_nightly-2.3.0.20250407.1120.dist-info}/RECORD +11 -11
- model_compression_toolkit/__init__.py +1 -1
- model_compression_toolkit/core/common/quantization/filter_nodes_candidates.py +2 -0
- model_compression_toolkit/core/common/quantization/node_quantization_config.py +33 -5
- model_compression_toolkit/exporter/model_exporter/pytorch/fakely_quant_onnx_pytorch_exporter.py +12 -0
- model_compression_toolkit/exporter/model_wrapper/pytorch/builder/fully_quantized_model_builder.py +1 -1
- model_compression_toolkit/target_platform_capabilities/constants.py +1 -0
- {mct_nightly-2.3.0.20250405.519.dist-info → mct_nightly-2.3.0.20250407.1120.dist-info}/WHEEL +0 -0
- {mct_nightly-2.3.0.20250405.519.dist-info → mct_nightly-2.3.0.20250407.1120.dist-info}/licenses/LICENSE.md +0 -0
- {mct_nightly-2.3.0.20250405.519.dist-info → mct_nightly-2.3.0.20250407.1120.dist-info}/top_level.txt +0 -0
{mct_nightly-2.3.0.20250405.519.dist-info → mct_nightly-2.3.0.20250407.1120.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.20250407.1120
|
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.20250405.519.dist-info → mct_nightly-2.3.0.20250407.1120.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.20250407.1120.dist-info/licenses/LICENSE.md,sha256=aYSSIb-5AFPeITTvXm1UAoe0uYBiMmSS8flvXaaFUks,10174
|
2
|
+
model_compression_toolkit/__init__.py,sha256=rbCx-x__4DNITXM-m79qge3vAJYMLHqI9ym62xr6BTE,1557
|
3
3
|
model_compression_toolkit/constants.py,sha256=2ltuH-gdaLZoZV4CPUgKjC3S9ojz2z4OTVdenyVEypU,3912
|
4
4
|
model_compression_toolkit/defaultdict.py,sha256=LSc-sbZYXENMCw3U9F4GiXuv67IKpdn0Qm7Fr11jy-4,2277
|
5
5
|
model_compression_toolkit/logger.py,sha256=L3q7tn3Uht0i_7phnlOWMR2Te2zvzrt2HOz9vYEInts,4529
|
@@ -105,8 +105,8 @@ model_compression_toolkit/core/common/quantization/bit_width_config.py,sha256=0H
|
|
105
105
|
model_compression_toolkit/core/common/quantization/candidate_node_quantization_config.py,sha256=lyWPvnoX8BmulhLKR20r5gT2_Yan7P40d8EcgDhErPk,4905
|
106
106
|
model_compression_toolkit/core/common/quantization/core_config.py,sha256=yxCzWqldcHoe8GGxrH0tp99bhrc5jDT7SgZftnMUUBE,2374
|
107
107
|
model_compression_toolkit/core/common/quantization/debug_config.py,sha256=zJP2W9apUPX9RstpPWWK71wr9xJsg7j-s7lGV4_bQdc,1510
|
108
|
-
model_compression_toolkit/core/common/quantization/filter_nodes_candidates.py,sha256=
|
109
|
-
model_compression_toolkit/core/common/quantization/node_quantization_config.py,sha256=
|
108
|
+
model_compression_toolkit/core/common/quantization/filter_nodes_candidates.py,sha256=n2A8pO7_DMMae4o69U0I00iW6mzeRlRfKHDxlQUBBuI,7204
|
109
|
+
model_compression_toolkit/core/common/quantization/node_quantization_config.py,sha256=bRK8c3iH64RGBZ8jZb0i4vVjcEvCxgKX5CdTEmIMtZ4,29077
|
110
110
|
model_compression_toolkit/core/common/quantization/quantization_config.py,sha256=UkSVW7d1OF_Px9gAjsqqK65aYhIBFWaBO-_IH6_AFfg,4403
|
111
111
|
model_compression_toolkit/core/common/quantization/quantization_fn_selection.py,sha256=HfBkSiRTOf9mNF-TNQHTCCs3xSg66F20no0O6vl5v1Y,2154
|
112
112
|
model_compression_toolkit/core/common/quantization/quantization_params_fn_selection.py,sha256=7eG7dl1TcbdnHwgmvyjarxLs0o6Lw_9VAjXAm4rsiBk,3791
|
@@ -335,7 +335,7 @@ model_compression_toolkit/exporter/model_exporter/keras/mctq_keras_exporter.py,s
|
|
335
335
|
model_compression_toolkit/exporter/model_exporter/pytorch/__init__.py,sha256=uZ2RigbY9O2PJ0Il8wPpS_s7frgg9WUGd_SHeKGyl1A,699
|
336
336
|
model_compression_toolkit/exporter/model_exporter/pytorch/base_pytorch_exporter.py,sha256=UPVkEUQCMZ4Lld6CRnEOPEmlfe5vcQZG0Q3FwRBodD4,4021
|
337
337
|
model_compression_toolkit/exporter/model_exporter/pytorch/export_serialization_format.py,sha256=bPevy6OBqng41PqytBR55e6cBEuyrUS0H8dWX4zgjQ4,967
|
338
|
-
model_compression_toolkit/exporter/model_exporter/pytorch/fakely_quant_onnx_pytorch_exporter.py,sha256=
|
338
|
+
model_compression_toolkit/exporter/model_exporter/pytorch/fakely_quant_onnx_pytorch_exporter.py,sha256=G2X_lDx6u12U4ErEuEHCdNczh0qSGWObySw3upEys6Q,7506
|
339
339
|
model_compression_toolkit/exporter/model_exporter/pytorch/fakely_quant_torchscript_pytorch_exporter.py,sha256=ksWV2A-Njo-wAxQ_Ye2sLIZXBWJ_WNyjT7-qFFwvV2o,2897
|
340
340
|
model_compression_toolkit/exporter/model_exporter/pytorch/pytorch_export_facade.py,sha256=8vYGKa58BkasvoHejYaPwubOJPcW0s-RY79_Kkw0Hy8,6236
|
341
341
|
model_compression_toolkit/exporter/model_wrapper/__init__.py,sha256=7CF2zvpTrIEm8qnbuHnLZyTZkwBBxV24V8QA0oxGbh0,1187
|
@@ -349,7 +349,7 @@ model_compression_toolkit/exporter/model_wrapper/keras/builder/node_to_quantizer
|
|
349
349
|
model_compression_toolkit/exporter/model_wrapper/pytorch/__init__.py,sha256=Rf1RcYmelmdZmBV5qOKvKWF575ofc06JFQSq83Jz99A,696
|
350
350
|
model_compression_toolkit/exporter/model_wrapper/pytorch/validate_layer.py,sha256=vQUGbCi8_pGoN8DwQ0IblSeN6L9t6Cr0reZNuCbBpkM,3469
|
351
351
|
model_compression_toolkit/exporter/model_wrapper/pytorch/builder/__init__.py,sha256=cco4TmeIDIh32nj9ZZXVkws4dd9F2UDrmjKzTN8G0V0,697
|
352
|
-
model_compression_toolkit/exporter/model_wrapper/pytorch/builder/fully_quantized_model_builder.py,sha256=
|
352
|
+
model_compression_toolkit/exporter/model_wrapper/pytorch/builder/fully_quantized_model_builder.py,sha256=bkcuNcbPwdB6pAvQhaBaCfk0qGaiJHMJdKYG5A1XdHE,6458
|
353
353
|
model_compression_toolkit/exporter/model_wrapper/pytorch/builder/node_to_quantizer.py,sha256=Pl8a8MSZMzNbm5vngujFjCt_iSMbSmKjlcL1DvN9nTM,9292
|
354
354
|
model_compression_toolkit/gptq/__init__.py,sha256=pEgkJvmf05KSw70iLDTz_6LI_2Oi5L8sTN0JsEUpnpk,1445
|
355
355
|
model_compression_toolkit/gptq/runner.py,sha256=La12JTYjWyJW0YW4Al4TP1_Xi4JWBCEKw6FR_JQsxe0,5982
|
@@ -431,7 +431,7 @@ model_compression_toolkit/qat/pytorch/quantizer/ste_rounding/__init__.py,sha256=
|
|
431
431
|
model_compression_toolkit/qat/pytorch/quantizer/ste_rounding/symmetric_ste.py,sha256=p1JqtBZZVHTV5caR1U0d1t2UcTz0ACNyLcJTBFUEq98,6173
|
432
432
|
model_compression_toolkit/qat/pytorch/quantizer/ste_rounding/uniform_ste.py,sha256=wWehe5R0xVHSm3ruMrUc8RzW5UVAVCMgUTUMPDsvy9g,5487
|
433
433
|
model_compression_toolkit/target_platform_capabilities/__init__.py,sha256=8RVOriZg-XNjSt53h_4Yum0oRgOe2gp5H45dfG_lZxE,1415
|
434
|
-
model_compression_toolkit/target_platform_capabilities/constants.py,sha256=
|
434
|
+
model_compression_toolkit/target_platform_capabilities/constants.py,sha256=JRz9DoxLRpkqvu532TFkIvv0595Bfb9NtU4pRp4urDY,1540
|
435
435
|
model_compression_toolkit/target_platform_capabilities/immutable.py,sha256=YhROBiXEIB3TU-bAFrnL3qbAsb1yuWPBAQ_CLOJbYUU,1827
|
436
436
|
model_compression_toolkit/target_platform_capabilities/tpc_io_handler.py,sha256=4ydTWWKv_PEOAFok2JtxFNj8rav-0IlqcXKF6lnhHNE,4157
|
437
437
|
model_compression_toolkit/target_platform_capabilities/schema/__init__.py,sha256=pKAdbTCFM_2BrZXUtTIw0ouKotrWwUDF_hP3rPwCM2k,696
|
@@ -527,7 +527,7 @@ model_compression_toolkit/xquant/pytorch/model_analyzer.py,sha256=b93o800yVB3Z-i
|
|
527
527
|
model_compression_toolkit/xquant/pytorch/pytorch_report_utils.py,sha256=UVN_S9ULHBEldBpShCOt8-soT8YTQ5oE362y96qF_FA,3950
|
528
528
|
model_compression_toolkit/xquant/pytorch/similarity_functions.py,sha256=CERxq5K8rqaiE-DlwhZBTUd9x69dtYJlkHOPLB54vm8,2354
|
529
529
|
model_compression_toolkit/xquant/pytorch/tensorboard_utils.py,sha256=mkoEktLFFHtEKzzFRn_jCnxjhJolK12TZ5AQeDHzUO8,9767
|
530
|
-
mct_nightly-2.3.0.
|
531
|
-
mct_nightly-2.3.0.
|
532
|
-
mct_nightly-2.3.0.
|
533
|
-
mct_nightly-2.3.0.
|
530
|
+
mct_nightly-2.3.0.20250407.1120.dist-info/METADATA,sha256=3FbL_LGv5kbK8httRgRpIX64Ff6HElqC7NSH2BU5WDQ,27099
|
531
|
+
mct_nightly-2.3.0.20250407.1120.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
|
532
|
+
mct_nightly-2.3.0.20250407.1120.dist-info/top_level.txt,sha256=gsYA8juk0Z-ZmQRKULkb3JLGdOdz8jW_cMRjisn9ga4,26
|
533
|
+
mct_nightly-2.3.0.20250407.1120.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.20250407.001120"
|
@@ -119,6 +119,8 @@ def filter_node_candidates(node: BaseNode, fw_info) -> List[CandidateNodeQuantiz
|
|
119
119
|
final_candidates = _filter_bit_method_dups(filtered_candidates, kernel_attr)
|
120
120
|
|
121
121
|
elif kernel_attr is None or not node.is_weights_quantization_enabled(kernel_attr):
|
122
|
+
# TODO:
|
123
|
+
# To allow MP on positional weights we need to modify this to consider all weights not only kernel.
|
122
124
|
# Remove candidates that have duplicated activation candidates for node with disabled weights quantization.
|
123
125
|
# Replacing the weights n_bits in the remained configurations with default value to prevent confusion.
|
124
126
|
seen_candidates = set()
|
@@ -25,7 +25,9 @@ from model_compression_toolkit.core.common.quantization.quantization_params_fn_s
|
|
25
25
|
|
26
26
|
from model_compression_toolkit.core.common.quantization.quantization_config import QuantizationConfig, \
|
27
27
|
QuantizationErrorMethod
|
28
|
-
from model_compression_toolkit.target_platform_capabilities.
|
28
|
+
from model_compression_toolkit.target_platform_capabilities.constants import POS_ATTR
|
29
|
+
from model_compression_toolkit.target_platform_capabilities.schema.mct_current_schema import \
|
30
|
+
AttributeQuantizationConfig, \
|
29
31
|
OpQuantizationConfig
|
30
32
|
|
31
33
|
if TYPE_CHECKING:
|
@@ -209,7 +211,7 @@ class NodeActivationQuantizationConfig(BaseNodeQuantizationConfig):
|
|
209
211
|
self.shift_negative_activation_correction == other.shift_negative_activation_correction and \
|
210
212
|
self.z_threshold == other.z_threshold and \
|
211
213
|
self.shift_negative_ratio == other.shift_negative_ratio and \
|
212
|
-
self.shift_negative_threshold_recalculation == other.shift_negative_threshold_recalculation
|
214
|
+
self.shift_negative_threshold_recalculation == other.shift_negative_threshold_recalculation
|
213
215
|
|
214
216
|
def __hash__(self):
|
215
217
|
return hash((self.activation_quantization_fn,
|
@@ -395,9 +397,35 @@ class NodeWeightsQuantizationConfig(BaseNodeQuantizationConfig):
|
|
395
397
|
for attr in node_attrs_list:
|
396
398
|
if isinstance(attr, int):
|
397
399
|
# this is a positional attribute, so it needs to be handled separately.
|
398
|
-
|
399
|
-
|
400
|
-
|
400
|
+
# Search for any keys in the op config's attribute weight config mapping that contain the
|
401
|
+
# POS_ATTR string. If none are found, it indicates that no specific quantization config is defined for
|
402
|
+
# positional weights, so the default config will be used instead.
|
403
|
+
attrs_included_in_name = {k: v for k, v in op_cfg.attr_weights_configs_mapping.items() if
|
404
|
+
POS_ATTR in k}
|
405
|
+
|
406
|
+
if len(attrs_included_in_name) > 1: # pragma: no cover
|
407
|
+
raise ValueError(f"Found multiple attribute in FQC OpConfig that are contained "
|
408
|
+
f"in the attribute name '{attr}'."
|
409
|
+
f"Please fix the FQC attribute names mapping such that each operator's attribute"
|
410
|
+
f" would have a unique matching name.")
|
411
|
+
|
412
|
+
# If no specific positional attribute config is found, fall back to the default weight attribute config.
|
413
|
+
if len(attrs_included_in_name) == 0:
|
414
|
+
attr_cfg = op_cfg.default_weight_attr_config
|
415
|
+
# Register this attribute under the positional attributes config mapping.
|
416
|
+
self.pos_attributes_config_mapping[attr] = WeightsAttrQuantizationConfig(qc=qc,
|
417
|
+
weights_attr_cfg=attr_cfg,
|
418
|
+
weights_channels_axis=
|
419
|
+
weights_channels_axis)
|
420
|
+
else:
|
421
|
+
# If a specific config was found using POS_ATTR, use it.
|
422
|
+
attr_cfg = list(attrs_included_in_name.values())[0]
|
423
|
+
|
424
|
+
# Register this attribute under the regular attributes config mapping.
|
425
|
+
self.attributes_config_mapping[attr] = WeightsAttrQuantizationConfig(qc=qc,
|
426
|
+
weights_attr_cfg=attr_cfg,
|
427
|
+
weights_channels_axis=
|
428
|
+
weights_channels_axis)
|
401
429
|
else:
|
402
430
|
# In Tensorflow, the attribute name is composed of the framework attribute name and the layer name,
|
403
431
|
# therefore, we need to look for the attribute in the op_cfg that is contained in the node attribute's name.
|
model_compression_toolkit/exporter/model_exporter/pytorch/fakely_quant_onnx_pytorch_exporter.py
CHANGED
@@ -73,6 +73,11 @@ if FOUND_ONNX:
|
|
73
73
|
"""
|
74
74
|
for layer in self.model.children():
|
75
75
|
self.is_layer_exportable_fn(layer)
|
76
|
+
# Set reuse for weight quantizers if quantizer is reused
|
77
|
+
if isinstance(layer, PytorchQuantizationWrapper):
|
78
|
+
for _, quantizer in layer.weights_quantizers.items():
|
79
|
+
if quantizer.reuse:
|
80
|
+
quantizer.enable_reuse_quantizer()
|
76
81
|
|
77
82
|
# Set forward that is used during onnx export.
|
78
83
|
# If _use_onnx_custom_quantizer_ops is set to True, the quantizer forward function will use
|
@@ -116,6 +121,13 @@ if FOUND_ONNX:
|
|
116
121
|
dynamic_axes={'input': {0: 'batch_size'},
|
117
122
|
'output': {0: 'batch_size'}})
|
118
123
|
|
124
|
+
for layer in self.model.children():
|
125
|
+
# Set disable for reuse for weight quantizers if quantizer was reused
|
126
|
+
if isinstance(layer, PytorchQuantizationWrapper):
|
127
|
+
for _, quantizer in layer.weights_quantizers.items():
|
128
|
+
if quantizer.reuse:
|
129
|
+
quantizer.disable_reuse_quantizer()
|
130
|
+
|
119
131
|
def _enable_onnx_custom_ops_export(self):
|
120
132
|
"""
|
121
133
|
Enable the custom implementation forward in quantizers, so it is exported
|
model_compression_toolkit/exporter/model_wrapper/pytorch/builder/fully_quantized_model_builder.py
CHANGED
@@ -48,7 +48,7 @@ if FOUND_TORCH:
|
|
48
48
|
# Set reuse for weight quantizers if node is reused
|
49
49
|
for _, quantizer in weight_quantizers.items():
|
50
50
|
if node.reuse_group:
|
51
|
-
quantizer.
|
51
|
+
quantizer.reuse = True
|
52
52
|
# for positional weights we need to extract the weight's value.
|
53
53
|
weights_values = {attr: fw_impl.to_tensor(node.get_weights_by_keys(attr))
|
54
54
|
for attr in weight_quantizers if isinstance(attr, int)}
|
@@ -29,6 +29,7 @@ QNNPACK_TP_MODEL = 'qnnpack'
|
|
29
29
|
# TP Attributes
|
30
30
|
KERNEL_ATTR = "kernel_attr"
|
31
31
|
BIAS_ATTR = "bias_attr"
|
32
|
+
POS_ATTR = "pos_attr"
|
32
33
|
|
33
34
|
# TODO: this is duplicated from the core frameworks constants files, because the original consts can't be used here
|
34
35
|
# duo to circular dependency. It might be best to extract the constants from the core file and put them here (in a
|
{mct_nightly-2.3.0.20250405.519.dist-info → mct_nightly-2.3.0.20250407.1120.dist-info}/WHEEL
RENAMED
File without changes
|
File without changes
|
{mct_nightly-2.3.0.20250405.519.dist-info → mct_nightly-2.3.0.20250407.1120.dist-info}/top_level.txt
RENAMED
File without changes
|