mct-nightly 2.3.0.20250604.611__py3-none-any.whl → 2.4.0.20250605.606__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.20250604.611.dist-info → mct_nightly-2.4.0.20250605.606.dist-info}/METADATA +1 -1
- {mct_nightly-2.3.0.20250604.611.dist-info → mct_nightly-2.4.0.20250605.606.dist-info}/RECORD +10 -10
- model_compression_toolkit/__init__.py +1 -1
- model_compression_toolkit/core/common/graph/base_node.py +6 -0
- model_compression_toolkit/core/common/mixed_precision/mixed_precision_quantization_config.py +9 -0
- model_compression_toolkit/core/common/model_collector.py +1 -1
- model_compression_toolkit/exporter/model_exporter/pytorch/base_pytorch_exporter.py +22 -3
- {mct_nightly-2.3.0.20250604.611.dist-info → mct_nightly-2.4.0.20250605.606.dist-info}/WHEEL +0 -0
- {mct_nightly-2.3.0.20250604.611.dist-info → mct_nightly-2.4.0.20250605.606.dist-info}/licenses/LICENSE.md +0 -0
- {mct_nightly-2.3.0.20250604.611.dist-info → mct_nightly-2.4.0.20250605.606.dist-info}/top_level.txt +0 -0
{mct_nightly-2.3.0.20250604.611.dist-info → mct_nightly-2.4.0.20250605.606.dist-info}/RECORD
RENAMED
@@ -1,5 +1,5 @@
|
|
1
|
-
mct_nightly-2.
|
2
|
-
model_compression_toolkit/__init__.py,sha256=
|
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
|
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
|
@@ -16,7 +16,7 @@ model_compression_toolkit/core/common/framework_implementation.py,sha256=JQI_eoZ
|
|
16
16
|
model_compression_toolkit/core/common/framework_info.py,sha256=5tderHT-7Cd21QrRFIJj3hH_gAcnlivOzwZ5m1ldJOs,6526
|
17
17
|
model_compression_toolkit/core/common/memory_computation.py,sha256=ixoSpV5ZYZGyzhre3kQcvR2sNA8KBsPZ3lgbkDnw9Cs,1205
|
18
18
|
model_compression_toolkit/core/common/model_builder_mode.py,sha256=jll9-59OPaE3ug7Y9-lLyV99_FoNHxkGZMgcm0Vkpss,1324
|
19
|
-
model_compression_toolkit/core/common/model_collector.py,sha256=
|
19
|
+
model_compression_toolkit/core/common/model_collector.py,sha256=ssYLdo2FPEzXoFKQonUA3ZbrIaDp-UmLhv0mWMCHH8U,13225
|
20
20
|
model_compression_toolkit/core/common/model_validation.py,sha256=LaG8wd6aZl0OJgieE3SeiVDEPxtk8IHq9-3wSnmWhY4,1214
|
21
21
|
model_compression_toolkit/core/common/node_prior_info.py,sha256=WXX_PrGVG9M9I_REG5ZzFBohwmV4yf356sZnrja_FLo,2832
|
22
22
|
model_compression_toolkit/core/common/similarity_analyzer.py,sha256=S3f6WgHyw62dGcxpX51FGKyfebe2zv9ABKbjtGyKRvY,9215
|
@@ -35,7 +35,7 @@ model_compression_toolkit/core/common/fusion/fusing_info.py,sha256=uDxF0awrjn3Sb
|
|
35
35
|
model_compression_toolkit/core/common/fusion/graph_fuser.py,sha256=yxxxuwrmQ4wLW-PlTu0MEW59LmNJEh1OWy9Li15YH-8,7520
|
36
36
|
model_compression_toolkit/core/common/graph/__init__.py,sha256=Xr-Lt_qXMdrCnnOaUS_OJP_3iTTGfPCLf8_vSrQgCs0,773
|
37
37
|
model_compression_toolkit/core/common/graph/base_graph.py,sha256=YA0c8ucaaZu9eRO-xruLqDT3QFOpxq24ViG6ILS2jqA,41403
|
38
|
-
model_compression_toolkit/core/common/graph/base_node.py,sha256=
|
38
|
+
model_compression_toolkit/core/common/graph/base_node.py,sha256=8GEqZ8VMtVvJZuiSUVdokCq6NkFosOssetcod21DwDM,33604
|
39
39
|
model_compression_toolkit/core/common/graph/edge.py,sha256=buoSEUZwilWBK3WeBKpJ-GeDaUA1SDdOHxDpxU_bGpk,3784
|
40
40
|
model_compression_toolkit/core/common/graph/functional_node.py,sha256=GH5wStmw8SoAj5IdT_-ItN1Meo_P5NUTt_5bgJC4fak,3935
|
41
41
|
model_compression_toolkit/core/common/graph/graph_matchers.py,sha256=CrDoHYq4iPaflgJWmoJ1K4ziLrRogJvFTVWg8P0UcDU,4744
|
@@ -65,7 +65,7 @@ model_compression_toolkit/core/common/mixed_precision/bit_width_setter.py,sha256
|
|
65
65
|
model_compression_toolkit/core/common/mixed_precision/configurable_quant_id.py,sha256=LLDguK7afsbN742ucLpmJr5TUfTyFpK1vbf2bpVr1v0,882
|
66
66
|
model_compression_toolkit/core/common/mixed_precision/configurable_quantizer_utils.py,sha256=7dKMi5S0zQZ16m8NWn1XIuoXsKuZUg64G4-uK8-j1PQ,5177
|
67
67
|
model_compression_toolkit/core/common/mixed_precision/mixed_precision_candidates_filter.py,sha256=6pLUEEIqRTVIlCYQC4JIvY55KAvuBHEX8uTOQ-1Ac4Q,3859
|
68
|
-
model_compression_toolkit/core/common/mixed_precision/mixed_precision_quantization_config.py,sha256=
|
68
|
+
model_compression_toolkit/core/common/mixed_precision/mixed_precision_quantization_config.py,sha256=qsFW_H3HiN3Mr1lwSg15CQb4cUBtGVfewdGzZoJVijo,6737
|
69
69
|
model_compression_toolkit/core/common/mixed_precision/mixed_precision_ru_helper.py,sha256=axgAypzsiCOw04ZOtOEjK4riuNsaEU2qU6KkWnEXtMo,4951
|
70
70
|
model_compression_toolkit/core/common/mixed_precision/mixed_precision_search_facade.py,sha256=1877xOUdgpWrXWyhdX1pJOePuopq43L71WqBFMqzyR4,6418
|
71
71
|
model_compression_toolkit/core/common/mixed_precision/mixed_precision_search_manager.py,sha256=3D_gHdcxsuINiTZqEAJXbxwYDg5qqXD51k4_smmWI9M,28553
|
@@ -334,7 +334,7 @@ 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=
|
337
|
+
model_compression_toolkit/exporter/model_exporter/pytorch/base_pytorch_exporter.py,sha256=sCfK6wXWFgMW0dUaRgWhLc0GUiCHTU-H16I17-XNJu0,6360
|
338
338
|
model_compression_toolkit/exporter/model_exporter/pytorch/export_serialization_format.py,sha256=bPevy6OBqng41PqytBR55e6cBEuyrUS0H8dWX4zgjQ4,967
|
339
339
|
model_compression_toolkit/exporter/model_exporter/pytorch/fakely_quant_onnx_pytorch_exporter.py,sha256=v6DwLNZX5RcWHUfYXfJZXNFXPfHsMm5Wl0N29o0diSc,8856
|
340
340
|
model_compression_toolkit/exporter/model_exporter/pytorch/fakely_quant_torchscript_pytorch_exporter.py,sha256=ksWV2A-Njo-wAxQ_Ye2sLIZXBWJ_WNyjT7-qFFwvV2o,2897
|
@@ -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.
|
533
|
-
mct_nightly-2.
|
534
|
-
mct_nightly-2.
|
535
|
-
mct_nightly-2.
|
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,,
|
@@ -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.
|
30
|
+
__version__ = "2.4.0.20250605.000606"
|
@@ -134,6 +134,12 @@ class BaseNode:
|
|
134
134
|
"""
|
135
135
|
return self._is_single_quant_mode(ActivationQuantizationMode.QUANT)
|
136
136
|
|
137
|
+
def is_fln_quantization(self) -> bool:
|
138
|
+
"""
|
139
|
+
Returns: Whether the node's activation quantization is FLN
|
140
|
+
"""
|
141
|
+
return self._is_single_quant_mode(ActivationQuantizationMode.FLN_QUANT)
|
142
|
+
|
137
143
|
def is_quantization_preserving(self) -> bool:
|
138
144
|
"""
|
139
145
|
Returns: Whether node activation quantization information is preserved from its inputs.
|
model_compression_toolkit/core/common/mixed_precision/mixed_precision_quantization_config.py
CHANGED
@@ -22,12 +22,17 @@ from model_compression_toolkit.constants import MP_DEFAULT_NUM_SAMPLES, ACT_HESS
|
|
22
22
|
|
23
23
|
class MpDistanceWeighting(Enum):
|
24
24
|
"""
|
25
|
+
|
25
26
|
Defines interest points distances weighting methods.
|
26
27
|
|
27
28
|
AVG - take the average distance over all interest points.
|
29
|
+
|
28
30
|
LAST_LAYER - take only the distance of the last interest point.
|
31
|
+
|
29
32
|
EXP - weighted average with weights based on exponent of negative distances between activations of the quantized and the float models.
|
33
|
+
|
30
34
|
HESSIAN - weighted average with Hessians as weights.
|
35
|
+
|
31
36
|
"""
|
32
37
|
AVG = auto()
|
33
38
|
LAST_LAYER = auto()
|
@@ -37,9 +42,13 @@ class MpDistanceWeighting(Enum):
|
|
37
42
|
|
38
43
|
class MpMetricNormalization(Enum):
|
39
44
|
"""
|
45
|
+
|
40
46
|
MAXBIT: normalize sensitivity metrics of layer candidates by max-bitwidth candidate (of that layer).
|
47
|
+
|
41
48
|
MINBIT: normalize sensitivity metrics of layer candidates by min-bitwidth candidate (of that layer).
|
49
|
+
|
42
50
|
NONE: no normalization.
|
51
|
+
|
43
52
|
"""
|
44
53
|
MAXBIT = 'MAXBIT'
|
45
54
|
MINBIT = 'MINBIT'
|
@@ -44,7 +44,7 @@ def create_stats_collector_for_node(node: common.BaseNode,
|
|
44
44
|
Statistics collector for statistics collection for the node.
|
45
45
|
"""
|
46
46
|
|
47
|
-
if node.is_activation_quantization_enabled():
|
47
|
+
if node.is_activation_quantization_enabled() or node.is_fln_quantization():
|
48
48
|
min_output = getattr(node.prior_info, 'min_output', None)
|
49
49
|
max_output = getattr(node.prior_info, 'max_output', None)
|
50
50
|
stats_collector = common.StatsCollector(out_channel_axis=fw_info.out_channel_axis_mapping.get(node.type),
|
@@ -18,7 +18,7 @@ from typing import Callable
|
|
18
18
|
import torch.nn
|
19
19
|
|
20
20
|
from mct_quantizers import PytorchQuantizationWrapper
|
21
|
-
from mct_quantizers.common.constants import LAYER, WEIGHTS_QUANTIZERS
|
21
|
+
from mct_quantizers.common.constants import LAYER, WEIGHTS_QUANTIZERS, QUANTIZED_POSITIONAL_WEIGHT
|
22
22
|
from model_compression_toolkit.logger import Logger
|
23
23
|
from model_compression_toolkit.exporter.model_exporter.fw_agonstic.exporter import Exporter
|
24
24
|
|
@@ -73,8 +73,27 @@ def _set_quantized_weights_in_wrapper(layer:PytorchQuantizationWrapper):
|
|
73
73
|
for name in layer.weights_quantizers.keys():
|
74
74
|
quantized_weight = torch.nn.Parameter(layer.get_quantized_weights()[name]).detach()
|
75
75
|
linear_layer = getattr(layer, LAYER)
|
76
|
-
|
77
|
-
|
76
|
+
|
77
|
+
# If the name is a string, we assume it's a named attribute of the linear layer
|
78
|
+
if isinstance(name, str):
|
79
|
+
# Remove the existing attribute from the linear layer
|
80
|
+
delattr(linear_layer, name)
|
81
|
+
# Replace it with the quantized version as a new parameter
|
82
|
+
setattr(linear_layer, name, torch.nn.Parameter(quantized_weight))
|
83
|
+
else:
|
84
|
+
# If the name is not a string, it must be an integer representing a positional weight
|
85
|
+
assert isinstance(name, int)
|
86
|
+
attr_name = f'{QUANTIZED_POSITIONAL_WEIGHT}_{name}'
|
87
|
+
|
88
|
+
# Note: This naming scheme is used to mimic the behavior expected in
|
89
|
+
# the PytorchQuantizationWrapper's forward method, which looks for attributes
|
90
|
+
# like 'quantized_pos_weight_0', 'quantized_pos_weight_1', etc.
|
91
|
+
|
92
|
+
if hasattr(layer, attr_name):
|
93
|
+
delattr(layer, attr_name)
|
94
|
+
|
95
|
+
# Add the quantized weight as a new attribute directly on the parent layer
|
96
|
+
setattr(layer, attr_name, quantized_weight)
|
78
97
|
|
79
98
|
# Clear the weights quantizers dictionary
|
80
99
|
layer.weights_quantizers = {}
|
File without changes
|
File without changes
|
{mct_nightly-2.3.0.20250604.611.dist-info → mct_nightly-2.4.0.20250605.606.dist-info}/top_level.txt
RENAMED
File without changes
|