compressed-tensors 0.10.3a20250814__py3-none-any.whl → 0.11.0__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.
@@ -57,6 +57,7 @@ class QuantizationScheme(BaseModel):
57
57
  inputs = model.input_activations
58
58
  outputs = model.output_activations
59
59
  weights = model.weights
60
+ format = model.format
60
61
 
61
62
  if inputs is not None:
62
63
  if inputs.actorder is not None:
@@ -66,6 +67,11 @@ class QuantizationScheme(BaseModel):
66
67
  if outputs.actorder is not None:
67
68
  raise ValueError("Cannot apply actorder to output activations")
68
69
 
70
+ if format == CompressionFormat.mixed_precision.value:
71
+ raise ValueError(
72
+ "mixed-precision cannot be set as a format for a QuantizationScheme"
73
+ )
74
+
69
75
  if (
70
76
  inputs
71
77
  and weights
@@ -15,7 +15,7 @@
15
15
  import logging
16
16
  import re
17
17
  from collections.abc import Generator
18
- from typing import Iterable, Mapping, Optional, Tuple
18
+ from typing import Iterable, List, Mapping, Optional, Tuple, Union
19
19
 
20
20
  import torch
21
21
  from compressed_tensors.utils.internal import InternalModule
@@ -57,10 +57,10 @@ def match_named_modules(
57
57
  unmatched_targets = set(targets)
58
58
  for name, module in model.named_modules():
59
59
  for target in targets:
60
- if is_match(name, module, target, fused):
60
+ if is_match(name, module, target, fused=fused):
61
61
  unmatched_targets -= {target}
62
62
 
63
- if not any(is_match(name, module, ign, fused) for ign in ignore):
63
+ if not is_match(name, module, ignore, fused=fused):
64
64
  yield name, module
65
65
 
66
66
  if warn_on_fail:
@@ -155,9 +155,7 @@ def match_modules_set(
155
155
  for name, module in model.named_modules():
156
156
  # match until we get a full set
157
157
  for target in targets:
158
- if is_match(name, module, target) and not any(
159
- is_match(name, module, ign) for ign in ignore
160
- ):
158
+ if is_match(name, module, target, ignore):
161
159
  if matches[target] is not None:
162
160
  raise ValueError(f"Matched a {target} twice before completing set")
163
161
  matches[target] = module
@@ -176,7 +174,8 @@ def match_modules_set(
176
174
  def is_match(
177
175
  name: str,
178
176
  module: torch.nn.Module,
179
- target: str,
177
+ targets: Union[str, Iterable[str]],
178
+ ignore: Union[str, Iterable[str]] = tuple(),
180
179
  fused: Optional[FusedMappping] = None,
181
180
  ) -> bool:
182
181
  """
@@ -198,8 +197,17 @@ def is_match(
198
197
  :fused: optional mapping from suffixes of fused modules to the suffixes of their
199
198
  corresponding shards
200
199
  """
200
+ targets = [targets] if isinstance(targets, str) else targets
201
+ ignore = [ignore] if isinstance(ignore, str) else ignore
202
+
201
203
  return not isinstance(module, InternalModule) and (
202
- _match_name(name, target, fused) or _match_class(module, target)
204
+ any(
205
+ _match_name(name, target, fused) or _match_class(module, target)
206
+ for target in targets
207
+ )
208
+ and not any(
209
+ _match_name(name, ign, fused) or _match_class(module, ign) for ign in ignore
210
+ )
203
211
  )
204
212
 
205
213
 
@@ -579,6 +579,7 @@ def remove_dispatch(module: torch.nn.Module) -> torch.nn.Module:
579
579
  remove_hook_from_module(module, recurse=True)
580
580
  if hasattr(module, "hf_device_map"):
581
581
  delattr(module, "hf_device_map")
582
+ module.to("cpu")
582
583
 
583
584
  return module
584
585
 
@@ -17,5 +17,5 @@ __version__: str
17
17
  __version_tuple__: VERSION_TUPLE
18
18
  version_tuple: VERSION_TUPLE
19
19
 
20
- __version__ = version = '0.10.3.a20250814'
21
- __version_tuple__ = version_tuple = (0, 10, 3)
20
+ __version__ = version = '0.11.0'
21
+ __version_tuple__ = version_tuple = (0, 11, 0)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: compressed-tensors
3
- Version: 0.10.3a20250814
3
+ Version: 0.11.0
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.
@@ -1,6 +1,6 @@
1
1
  compressed_tensors/__init__.py,sha256=UtKmifNeBCSE2TZSAfduVNNzHY-3V7bLjZ7n7RuXLOE,812
2
2
  compressed_tensors/base.py,sha256=-gxWvDF4LCkyeDP8YlGzvBBKxo4Dk9h4NINPD61drFU,921
3
- compressed_tensors/version.py,sha256=fAUC53w9XJ-gbZ3V6UhPrss4y7OIGxsBJ0rFa1T--zA,523
3
+ compressed_tensors/version.py,sha256=h33CazvO6X2vAgSb_I-BIOLNm7W5MVFnfSYRgLiRpMA,513
4
4
  compressed_tensors/compressors/__init__.py,sha256=smSygTSfcfuujRrAXDc6uZm4L_ccV1tWZewqVnOb4lM,825
5
5
  compressed_tensors/compressors/base.py,sha256=nvWsv4xEw1Tkxkxth6TmHplDYXfBeP22xWxOsZERyDY,7204
6
6
  compressed_tensors/compressors/helpers.py,sha256=OK6qxX9j3bHwF9JfIYSGMgBJe2PWjlTA3byXKCJaTIQ,5431
@@ -28,7 +28,7 @@ compressed_tensors/linear/compressed_linear.py,sha256=1yo9RyjA0aQ--iuIknFfcSorJn
28
28
  compressed_tensors/quantization/__init__.py,sha256=83J5bPB7PavN2TfCoW7_vEDhfYpm4TDrqYO9vdSQ5bk,760
29
29
  compressed_tensors/quantization/quant_args.py,sha256=PMoaa6hpyJLGGSeCWefGmzGVxbOtxAdDunHJi_L5gNs,12894
30
30
  compressed_tensors/quantization/quant_config.py,sha256=2NgDwKuQn0f-ojiHC8c6tXtYX_zQlk26Rj-bU71QKvA,10598
31
- compressed_tensors/quantization/quant_scheme.py,sha256=k25Cdx7BZCvLlRlENu4BVoFxquqcErP58P3Y_1HsKB4,8661
31
+ compressed_tensors/quantization/quant_scheme.py,sha256=aTdGWz_JenLlTqCeNFcujCJjgWQYkXEq2FXoN0YSNqI,8883
32
32
  compressed_tensors/quantization/lifecycle/__init__.py,sha256=_uItzFWusyV74Zco_pHLOTdE9a83cL-R-ZdyQrBkIyw,772
33
33
  compressed_tensors/quantization/lifecycle/apply.py,sha256=wM8mVcbKvZjBo18pSXMp28i30YWwUXJPSS7_HCakH9U,17892
34
34
  compressed_tensors/quantization/lifecycle/compressed.py,sha256=Fj9n66IN0EWsOAkBHg3O0GlOQpxstqjCcs0ttzMXrJ0,2296
@@ -56,15 +56,15 @@ compressed_tensors/transform/utils/matrix.py,sha256=FIHCUlpWVIIhdr3c6EbQec41JeiP
56
56
  compressed_tensors/utils/__init__.py,sha256=spzbjUO4-hZ2jXGST27r3MIt2yzIXsjdbEaYyaMcizo,873
57
57
  compressed_tensors/utils/helpers.py,sha256=Q3iRAa2XSdmmn4vSpUplnvKOmWwn4Clao9ZkPBHXtpI,12604
58
58
  compressed_tensors/utils/internal.py,sha256=7SSWgDoNFRnlfadwkoFhLW-T2jOc7Po_WzWv5h32Sa8,982
59
- compressed_tensors/utils/match.py,sha256=9x-yZIlq7ndSLf2aQwNT7IpBQDe-8H6utiJkji8wPrQ,9397
60
- compressed_tensors/utils/offload.py,sha256=gFoEDaissHsLM5-JDbgPxh5hiE9VFN4HFxvszYvReos,24446
59
+ compressed_tensors/utils/match.py,sha256=wXzcfUWlVE5Wc_OAvN7oUFqLhVHJ83oSt1Nhzw01igg,9701
60
+ compressed_tensors/utils/offload.py,sha256=7EDCtRbnw5gZQlZxTAICrc7ONeNW0pKdQFqOeqGlF6g,24467
61
61
  compressed_tensors/utils/permutations_24.py,sha256=kx6fsfDHebx94zsSzhXGyCyuC9sVyah6BUUir_StT28,2530
62
62
  compressed_tensors/utils/permute.py,sha256=V6tJLKo3Syccj-viv4F7ZKZgJeCB-hl-dK8RKI_kBwI,2355
63
63
  compressed_tensors/utils/safetensors_load.py,sha256=DMfZBuUbA6qp_BG_zIWT3ckiEE33K9ob34s-OgzReO4,12057
64
64
  compressed_tensors/utils/semi_structured_conversions.py,sha256=XKNffPum54kPASgqKzgKvyeqWPAkair2XEQXjkp7ho8,13489
65
65
  compressed_tensors/utils/type.py,sha256=bNwoo_FWlvLuDpYAGGzZJITRg0JA_Ngk9LGPo-kvjeU,2554
66
- compressed_tensors-0.10.3a20250814.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
67
- compressed_tensors-0.10.3a20250814.dist-info/METADATA,sha256=-7voWXyJPB13WkMJADa57hDE4euKxrCjnQfYdHROjKg,7031
68
- compressed_tensors-0.10.3a20250814.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
69
- compressed_tensors-0.10.3a20250814.dist-info/top_level.txt,sha256=w2i-GyPs2s1UwVxvutSvN_lM22SXC2hQFBmoMcPnV7Y,19
70
- compressed_tensors-0.10.3a20250814.dist-info/RECORD,,
66
+ compressed_tensors-0.11.0.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
67
+ compressed_tensors-0.11.0.dist-info/METADATA,sha256=RBt5uf5--bJvf_NPxjaOCX0HoHgHVUN9a8fmaIyXCAM,7022
68
+ compressed_tensors-0.11.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
69
+ compressed_tensors-0.11.0.dist-info/top_level.txt,sha256=w2i-GyPs2s1UwVxvutSvN_lM22SXC2hQFBmoMcPnV7Y,19
70
+ compressed_tensors-0.11.0.dist-info/RECORD,,