compressed-tensors 0.12.3a20251110__py3-none-any.whl → 0.12.3a20251114__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.
@@ -16,7 +16,17 @@ import contextlib
16
16
  import warnings
17
17
  from functools import wraps
18
18
  from types import MappingProxyType
19
- from typing import TYPE_CHECKING, Any, Callable, Dict, List, Mapping, Optional, TypeVar
19
+ from typing import (
20
+ TYPE_CHECKING,
21
+ Any,
22
+ Callable,
23
+ Dict,
24
+ Iterable,
25
+ List,
26
+ Mapping,
27
+ Optional,
28
+ TypeVar,
29
+ )
20
30
 
21
31
  import numpy
22
32
  import torch
@@ -44,6 +54,7 @@ __all__ = [
44
54
  "pack_bitmasks",
45
55
  "unpack_bitmasks",
46
56
  "patch_attr",
57
+ "patch_attrs",
47
58
  "ParameterizedDefaultDict",
48
59
  "get_num_attn_heads",
49
60
  "get_num_kv_heads",
@@ -368,6 +379,34 @@ def patch_attr(base: object, attr: str, value: Any):
368
379
  delattr(base, attr)
369
380
 
370
381
 
382
+ @contextlib.contextmanager
383
+ def patch_attrs(bases: Iterable[Any], attr: str, values: Iterable[Any]):
384
+ """
385
+ Same as `patch_attr` but for a list of objects to patch
386
+ Patch attribute for a list of objects with list of values.
387
+ Original values are restored upon exit
388
+
389
+ :param bases: objects which has the attribute to patch
390
+ :param attr: name of the the attribute to patch
391
+ :param values: used to replace original values. Must be same
392
+ length as bases
393
+
394
+ Usage:
395
+ >>> from types import SimpleNamespace
396
+ >>> obj1 = SimpleNamespace()
397
+ >>> obj2 = SimpleNamespace()
398
+ >>> with patch_attr([obj1, obj2], "attribute", ["value1", "value2"]):
399
+ ... assert obj1.attribute == "value1"
400
+ ... assert obj2.attribute == "value2"
401
+ >>> assert not hasattr(obj1, "attribute")
402
+ >>> assert not hasattr(obj2, "attribute")
403
+ """
404
+ with contextlib.ExitStack() as stack:
405
+ for base, value in zip(bases, values):
406
+ stack.enter_context(patch_attr(base, attr, value))
407
+ yield
408
+
409
+
371
410
  class ParameterizedDefaultDict(dict):
372
411
  """
373
412
  Similar to `collections.DefaultDict`, but upon fetching a key which is missing,
@@ -17,5 +17,5 @@ __version__: str
17
17
  __version_tuple__: VERSION_TUPLE
18
18
  version_tuple: VERSION_TUPLE
19
19
 
20
- __version__ = version = '0.12.3.a20251110'
20
+ __version__ = version = '0.12.3.a20251114'
21
21
  __version_tuple__ = version_tuple = (0, 12, 3)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: compressed-tensors
3
- Version: 0.12.3a20251110
3
+ Version: 0.12.3a20251114
4
4
  Summary: Library for utilization of compressed safetensors of neural network models
5
5
  Home-page: https://github.com/vllm-project/compressed-tensors
6
6
  Author: Neuralmagic, Inc.
@@ -1,7 +1,7 @@
1
1
  compressed_tensors/__init__.py,sha256=SRqNYFVvxAaLa4SImhoiIBKfoOSj7EUdx0CxXjGC2PA,884
2
2
  compressed_tensors/base.py,sha256=dKAVgQAp9GPH6YspvF_cbGXCrbiqAeLEIPydYAO40WE,859
3
3
  compressed_tensors/logger.py,sha256=sTm1Od1cV0aDxBm3YN-PPvsOATxY_2tBV62TQE4HiPw,4032
4
- compressed_tensors/version.py,sha256=udhHPnFgWqdtOMIxsimVDxoII8PIDOuK5cAfA4716VM,523
4
+ compressed_tensors/version.py,sha256=_76JjfEalYtLnwlx_1vHVRHYO4_7nPpez11U9pkUbyk,523
5
5
  compressed_tensors/compressors/__init__.py,sha256=smSygTSfcfuujRrAXDc6uZm4L_ccV1tWZewqVnOb4lM,825
6
6
  compressed_tensors/compressors/base.py,sha256=nvWsv4xEw1Tkxkxth6TmHplDYXfBeP22xWxOsZERyDY,7204
7
7
  compressed_tensors/compressors/helpers.py,sha256=OK6qxX9j3bHwF9JfIYSGMgBJe2PWjlTA3byXKCJaTIQ,5431
@@ -61,7 +61,7 @@ compressed_tensors/transform/utils/hadamard.py,sha256=9JMJPtlYI2HwJ2Y2I6uyVCBhKj
61
61
  compressed_tensors/transform/utils/hadamards.safetensors,sha256=mFd1GzNodGG-ifA1IoH-0nHYzfraCOvrq_dX2zFI1B4,1436901
62
62
  compressed_tensors/transform/utils/matrix.py,sha256=BapkVu1763cN1VPP0ukvSzmG0dHodiMYoPcUnU9C4RI,5864
63
63
  compressed_tensors/utils/__init__.py,sha256=eXvtlJEUiV4XPcfsxVrOwL7DyY8r-L0XG_Rr5qmZrmU,850
64
- compressed_tensors/utils/helpers.py,sha256=3GaIcRntTK60lB_JiOvS3gpldfRduGfj6a9KCkpc0JU,14463
64
+ compressed_tensors/utils/helpers.py,sha256=WHYh8yxMsmG2HxcfNVzcMLC-dtgWroRZaLcreADmUYE,15562
65
65
  compressed_tensors/utils/internal.py,sha256=7SSWgDoNFRnlfadwkoFhLW-T2jOc7Po_WzWv5h32Sa8,982
66
66
  compressed_tensors/utils/match.py,sha256=g1K6x56LoCGVR_sA25MOpja_U_V6_MZ-6cSY_Q_IauY,12320
67
67
  compressed_tensors/utils/offload.py,sha256=eXqLzl8kUkVDlNtcO5sn_4QoDcbAaxbCAS3tyZ-aGr8,23538
@@ -69,8 +69,8 @@ compressed_tensors/utils/permutations_24.py,sha256=kx6fsfDHebx94zsSzhXGyCyuC9sVy
69
69
  compressed_tensors/utils/safetensors_load.py,sha256=Vql34aCTDHwmTZXJHzCyBISJo7iA7EQ78LdTlMjdpZo,12023
70
70
  compressed_tensors/utils/semi_structured_conversions.py,sha256=XKNffPum54kPASgqKzgKvyeqWPAkair2XEQXjkp7ho8,13489
71
71
  compressed_tensors/utils/type.py,sha256=bNwoo_FWlvLuDpYAGGzZJITRg0JA_Ngk9LGPo-kvjeU,2554
72
- compressed_tensors-0.12.3a20251110.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
73
- compressed_tensors-0.12.3a20251110.dist-info/METADATA,sha256=mlIyNQwhwI7ef-hVEit_O-WgKGNAyb8jEIcFkgf7pX4,7027
74
- compressed_tensors-0.12.3a20251110.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
75
- compressed_tensors-0.12.3a20251110.dist-info/top_level.txt,sha256=w2i-GyPs2s1UwVxvutSvN_lM22SXC2hQFBmoMcPnV7Y,19
76
- compressed_tensors-0.12.3a20251110.dist-info/RECORD,,
72
+ compressed_tensors-0.12.3a20251114.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
73
+ compressed_tensors-0.12.3a20251114.dist-info/METADATA,sha256=_GmxiVbPvm29hVkbhLwcHbFVKEnTq8RJPLVRIuFKyQQ,7027
74
+ compressed_tensors-0.12.3a20251114.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
75
+ compressed_tensors-0.12.3a20251114.dist-info/top_level.txt,sha256=w2i-GyPs2s1UwVxvutSvN_lM22SXC2hQFBmoMcPnV7Y,19
76
+ compressed_tensors-0.12.3a20251114.dist-info/RECORD,,