compressed-tensors-nightly 0.6.0.20241004__py3-none-any.whl → 0.6.0.20241006__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.
- compressed_tensors/compressors/model_compressors/model_compressor.py +0 -4
- compressed_tensors/quantization/lifecycle/helpers.py +0 -47
- {compressed_tensors_nightly-0.6.0.20241004.dist-info → compressed_tensors_nightly-0.6.0.20241006.dist-info}/METADATA +1 -1
- {compressed_tensors_nightly-0.6.0.20241004.dist-info → compressed_tensors_nightly-0.6.0.20241006.dist-info}/RECORD +7 -7
- {compressed_tensors_nightly-0.6.0.20241004.dist-info → compressed_tensors_nightly-0.6.0.20241006.dist-info}/LICENSE +0 -0
- {compressed_tensors_nightly-0.6.0.20241004.dist-info → compressed_tensors_nightly-0.6.0.20241006.dist-info}/WHEEL +0 -0
- {compressed_tensors_nightly-0.6.0.20241004.dist-info → compressed_tensors_nightly-0.6.0.20241006.dist-info}/top_level.txt +0 -0
@@ -242,10 +242,6 @@ class ModelCompressor:
|
|
242
242
|
self.sparsity_compressor = None
|
243
243
|
self.quantization_compressor = None
|
244
244
|
|
245
|
-
if sparsity_config and sparsity_config.format == CompressionFormat.dense.value:
|
246
|
-
# ignore dense sparsity config
|
247
|
-
self.sparsity_config = None
|
248
|
-
|
249
245
|
if sparsity_config is not None:
|
250
246
|
self.sparsity_compressor = BaseCompressor.load_from_registry(
|
251
247
|
sparsity_config.format, config=sparsity_config
|
@@ -16,62 +16,15 @@
|
|
16
16
|
Miscelaneous helpers for the quantization lifecycle
|
17
17
|
"""
|
18
18
|
|
19
|
-
from typing import Optional
|
20
|
-
|
21
|
-
import torch
|
22
19
|
from torch.nn import Module
|
23
20
|
|
24
21
|
|
25
22
|
__all__ = [
|
26
|
-
"update_layer_weight_quant_params",
|
27
23
|
"enable_quantization",
|
28
24
|
"disable_quantization",
|
29
25
|
]
|
30
26
|
|
31
27
|
|
32
|
-
def update_layer_weight_quant_params(
|
33
|
-
layer: Module,
|
34
|
-
weight: Optional[torch.Tensor] = None,
|
35
|
-
g_idx: Optional[torch.Tensor] = None,
|
36
|
-
reset_obs: bool = False,
|
37
|
-
):
|
38
|
-
"""
|
39
|
-
Update quantization parameters on layer
|
40
|
-
|
41
|
-
:param layer: input layer
|
42
|
-
:param weight: weight to update quant params with, defaults to layer weight
|
43
|
-
:param g_idx: optional mapping from column index to group index
|
44
|
-
:param reset_obs: reset the observer before calculating quant params,
|
45
|
-
defaults to False
|
46
|
-
"""
|
47
|
-
attached_weight = getattr(layer, "weight", None)
|
48
|
-
|
49
|
-
if weight is None:
|
50
|
-
weight = attached_weight
|
51
|
-
scale = getattr(layer, "weight_scale", None)
|
52
|
-
zero_point = getattr(layer, "weight_zero_point", None)
|
53
|
-
if g_idx is None:
|
54
|
-
g_idx = getattr(layer, "weight_g_idx", None)
|
55
|
-
observer = getattr(layer, "weight_observer", None)
|
56
|
-
|
57
|
-
if weight is None or observer is None or scale is None or zero_point is None:
|
58
|
-
# scale, zp, or observer not calibratable or weight not available
|
59
|
-
return
|
60
|
-
|
61
|
-
if reset_obs:
|
62
|
-
observer.reset()
|
63
|
-
|
64
|
-
if attached_weight is not None:
|
65
|
-
weight = weight.to(attached_weight.dtype)
|
66
|
-
|
67
|
-
updated_scale, updated_zero_point = observer(weight)
|
68
|
-
|
69
|
-
# update scale and zero point
|
70
|
-
device = next(layer.parameters()).device
|
71
|
-
scale.data = updated_scale.to(device)
|
72
|
-
zero_point.data = updated_zero_point.to(device)
|
73
|
-
|
74
|
-
|
75
28
|
def enable_quantization(module: Module):
|
76
29
|
module.quantization_enabled = True
|
77
30
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: compressed-tensors-nightly
|
3
|
-
Version: 0.6.0.
|
3
|
+
Version: 0.6.0.20241006
|
4
4
|
Summary: Library for utilization of compressed safetensors of neural network models
|
5
5
|
Home-page: https://github.com/neuralmagic/compressed-tensors
|
6
6
|
Author: Neuralmagic, Inc.
|
@@ -5,7 +5,7 @@ compressed_tensors/compressors/__init__.py,sha256=smSygTSfcfuujRrAXDc6uZm4L_ccV1
|
|
5
5
|
compressed_tensors/compressors/base.py,sha256=D9TNwQcjanDiAHODPbg8JUqc66e3j50rctY7A708NEs,6743
|
6
6
|
compressed_tensors/compressors/helpers.py,sha256=OK6qxX9j3bHwF9JfIYSGMgBJe2PWjlTA3byXKCJaTIQ,5431
|
7
7
|
compressed_tensors/compressors/model_compressors/__init__.py,sha256=5RGGPFu4YqEt_aOdFSQYFYFDjcZFJN0CsMqRtDZz3Js,666
|
8
|
-
compressed_tensors/compressors/model_compressors/model_compressor.py,sha256=
|
8
|
+
compressed_tensors/compressors/model_compressors/model_compressor.py,sha256=XJgPsq8KiDfiR4e8bSI38lmoOd2ApqRk1aPcXS2obqY,15600
|
9
9
|
compressed_tensors/compressors/quantized_compressors/__init__.py,sha256=09UJq68Pht6Bf-4iP9xYl3tetKsncNPHD8IAGbePsr4,714
|
10
10
|
compressed_tensors/compressors/quantized_compressors/base.py,sha256=K1KOnS6Y8nUA1-HN7VhyfsDc01nilW0WfXMUhuD-l8w,5954
|
11
11
|
compressed_tensors/compressors/quantized_compressors/naive_quantized.py,sha256=Mmfr-hap-4zw7CzE1mXi0UirknqGidNxw38GGWVgTqM,4916
|
@@ -33,7 +33,7 @@ compressed_tensors/quantization/lifecycle/calibration.py,sha256=IuLeRkVQPrMxkMcI
|
|
33
33
|
compressed_tensors/quantization/lifecycle/compressed.py,sha256=Fj9n66IN0EWsOAkBHg3O0GlOQpxstqjCcs0ttzMXrJ0,2296
|
34
34
|
compressed_tensors/quantization/lifecycle/forward.py,sha256=eLup6QDRUUp_Ozcas7RDRLIXBWjFbxn5gWbcAIJEGlw,15715
|
35
35
|
compressed_tensors/quantization/lifecycle/frozen.py,sha256=NiJw7NP7pcT6idWFa8vksgiLoT8oQ975e57S4QfD2QQ,1874
|
36
|
-
compressed_tensors/quantization/lifecycle/helpers.py,sha256=
|
36
|
+
compressed_tensors/quantization/lifecycle/helpers.py,sha256=C0mhy2vJ0fCjVeN4kFNhw8Eq1wkteBGHiZ36RVLThRY,944
|
37
37
|
compressed_tensors/quantization/lifecycle/initialize.py,sha256=4_YG7jKl7d2-Cy58pOkMtInFRhvYahxYchesWMPxPVM,8862
|
38
38
|
compressed_tensors/quantization/observers/__init__.py,sha256=4Sa7rqi5RB_S5bPO8KmncETiqDsoMBhwP37arlQym8s,764
|
39
39
|
compressed_tensors/quantization/observers/base.py,sha256=5ovQicWPYHjIxr6-EkQ4lgOX0PpI9g23iSzKpxjM1Zg,8420
|
@@ -52,8 +52,8 @@ compressed_tensors/utils/permutations_24.py,sha256=kx6fsfDHebx94zsSzhXGyCyuC9sVy
|
|
52
52
|
compressed_tensors/utils/permute.py,sha256=V6tJLKo3Syccj-viv4F7ZKZgJeCB-hl-dK8RKI_kBwI,2355
|
53
53
|
compressed_tensors/utils/safetensors_load.py,sha256=m08ANVuTBxQdoa6LufDgcNJ7wCLDJolyZljB8VEybAU,8578
|
54
54
|
compressed_tensors/utils/semi_structured_conversions.py,sha256=XKNffPum54kPASgqKzgKvyeqWPAkair2XEQXjkp7ho8,13489
|
55
|
-
compressed_tensors_nightly-0.6.0.
|
56
|
-
compressed_tensors_nightly-0.6.0.
|
57
|
-
compressed_tensors_nightly-0.6.0.
|
58
|
-
compressed_tensors_nightly-0.6.0.
|
59
|
-
compressed_tensors_nightly-0.6.0.
|
55
|
+
compressed_tensors_nightly-0.6.0.20241006.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
56
|
+
compressed_tensors_nightly-0.6.0.20241006.dist-info/METADATA,sha256=H0Labw7XqjeDUBAlX6iLBOY0N4Afm5dH5pBwLnHgJc8,6799
|
57
|
+
compressed_tensors_nightly-0.6.0.20241006.dist-info/WHEEL,sha256=eOLhNAGa2EW3wWl_TU484h7q1UNgy0JXjjoqKoxAAQc,92
|
58
|
+
compressed_tensors_nightly-0.6.0.20241006.dist-info/top_level.txt,sha256=w2i-GyPs2s1UwVxvutSvN_lM22SXC2hQFBmoMcPnV7Y,19
|
59
|
+
compressed_tensors_nightly-0.6.0.20241006.dist-info/RECORD,,
|
File without changes
|
File without changes
|