compressed-tensors-nightly 0.7.1.20241024__py3-none-any.whl → 0.7.1.20241026__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.
@@ -12,16 +12,17 @@
12
12
  # See the License for the specific language governing permissions and
13
13
  # limitations under the License.
14
14
 
15
- from enum import Enum
15
+ from enum import Enum, unique
16
16
  from typing import List, Optional
17
17
 
18
18
  from compressed_tensors.registry import RegistryMixin
19
19
  from pydantic import BaseModel
20
20
 
21
21
 
22
- __all__ = ["SparsityCompressionConfig", "CompressionFormat"]
22
+ __all__ = ["SparsityCompressionConfig", "CompressionFormat", "SparsityStructure"]
23
23
 
24
24
 
25
+ @unique
25
26
  class CompressionFormat(Enum):
26
27
  dense = "dense"
27
28
  sparse_bitmask = "sparse-bitmask"
@@ -32,6 +33,63 @@ class CompressionFormat(Enum):
32
33
  marlin_24 = "marlin-24"
33
34
 
34
35
 
36
+ @unique
37
+ class SparsityStructure(Enum):
38
+ """
39
+ An enumeration to represent different sparsity structures.
40
+
41
+ Attributes
42
+ ----------
43
+ TWO_FOUR : str
44
+ Represents a 2:4 sparsity structure.
45
+ ZERO_ZERO : str
46
+ Represents a 0:0 sparsity structure.
47
+ UNSTRUCTURED : str
48
+ Represents an unstructured sparsity structure.
49
+
50
+ Examples
51
+ --------
52
+ >>> SparsityStructure('2:4')
53
+ <SparsityStructure.TWO_FOUR: '2:4'>
54
+
55
+ >>> SparsityStructure('unstructured')
56
+ <SparsityStructure.UNSTRUCTURED: 'unstructured'>
57
+
58
+ >>> SparsityStructure('2:4') == SparsityStructure.TWO_FOUR
59
+ True
60
+
61
+ >>> SparsityStructure('UNSTRUCTURED') == SparsityStructure.UNSTRUCTURED
62
+ True
63
+
64
+ >>> SparsityStructure(None) == SparsityStructure.UNSTRUCTURED
65
+ True
66
+
67
+ >>> SparsityStructure('invalid')
68
+ Traceback (most recent call last):
69
+ ...
70
+ ValueError: invalid is not a valid SparsityStructure
71
+ """
72
+
73
+ TWO_FOUR = "2:4"
74
+ UNSTRUCTURED = "unstructured"
75
+ ZERO_ZERO = "0:0"
76
+
77
+ def __new__(cls, value):
78
+ obj = object.__new__(cls)
79
+ obj._value_ = value.lower() if value is not None else value
80
+ return obj
81
+
82
+ @classmethod
83
+ def _missing_(cls, value):
84
+ # Handle None and case-insensitive values
85
+ if value is None:
86
+ return cls.UNSTRUCTURED
87
+ for member in cls:
88
+ if member.value == value.lower():
89
+ return member
90
+ raise ValueError(f"{value} is not a valid {cls.__name__}")
91
+
92
+
35
93
  class SparsityCompressionConfig(RegistryMixin, BaseModel):
36
94
  """
37
95
  Base data class for storing sparsity compression parameters
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: compressed-tensors-nightly
3
- Version: 0.7.1.20241024
3
+ Version: 0.7.1.20241026
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.
@@ -17,7 +17,7 @@ compressed_tensors/compressors/sparse_compressors/sparse_bitmask.py,sha256=4fKwC
17
17
  compressed_tensors/compressors/sparse_quantized_compressors/__init__.py,sha256=4f_cwcKXB1nVVMoiKgTFAc8jAPjPLElo-Df_EDm1_xw,675
18
18
  compressed_tensors/compressors/sparse_quantized_compressors/marlin_24.py,sha256=akqE7eW8CLTslpWRxERaZ8R0TSm1lS7D1bgZXKL0xi8,9427
19
19
  compressed_tensors/config/__init__.py,sha256=ZBqWn3r6ku1qfmlHHYp0mQueY0i7Pwhr9rbQk9dDlMc,704
20
- compressed_tensors/config/base.py,sha256=BNTFKy12isY7qblwxdi_R1f00EzgrNOXLrfxqLCPT8w,1903
20
+ compressed_tensors/config/base.py,sha256=3bFAdwDZjOt-U3fneOeL8dRci-PS8DqstnXuQVtkfiQ,3435
21
21
  compressed_tensors/config/dense.py,sha256=NgSxnFCnckU9-iunxEaqiFwqgdO7YYxlWKR74jNbjks,1317
22
22
  compressed_tensors/config/sparse_bitmask.py,sha256=pZUboRNZTu6NajGOQEFExoPknak5ynVAUeiiYpS1Gt8,1308
23
23
  compressed_tensors/linear/__init__.py,sha256=fH6rjBYAxuwrTzBTlTjTgCYNyh6TCvCqajCz4Im4YrA,617
@@ -51,8 +51,8 @@ compressed_tensors/utils/permutations_24.py,sha256=kx6fsfDHebx94zsSzhXGyCyuC9sVy
51
51
  compressed_tensors/utils/permute.py,sha256=V6tJLKo3Syccj-viv4F7ZKZgJeCB-hl-dK8RKI_kBwI,2355
52
52
  compressed_tensors/utils/safetensors_load.py,sha256=m08ANVuTBxQdoa6LufDgcNJ7wCLDJolyZljB8VEybAU,8578
53
53
  compressed_tensors/utils/semi_structured_conversions.py,sha256=XKNffPum54kPASgqKzgKvyeqWPAkair2XEQXjkp7ho8,13489
54
- compressed_tensors_nightly-0.7.1.20241024.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
55
- compressed_tensors_nightly-0.7.1.20241024.dist-info/METADATA,sha256=-Xf19M04eOlSXjbE9plgrWpGGXCv1B6H_ehjopS6CLs,6799
56
- compressed_tensors_nightly-0.7.1.20241024.dist-info/WHEEL,sha256=eOLhNAGa2EW3wWl_TU484h7q1UNgy0JXjjoqKoxAAQc,92
57
- compressed_tensors_nightly-0.7.1.20241024.dist-info/top_level.txt,sha256=w2i-GyPs2s1UwVxvutSvN_lM22SXC2hQFBmoMcPnV7Y,19
58
- compressed_tensors_nightly-0.7.1.20241024.dist-info/RECORD,,
54
+ compressed_tensors_nightly-0.7.1.20241026.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
55
+ compressed_tensors_nightly-0.7.1.20241026.dist-info/METADATA,sha256=__U7Av51V4RwixvjaNOpS9kuAZ6Cgyv6ddwKyZ7H74U,6799
56
+ compressed_tensors_nightly-0.7.1.20241026.dist-info/WHEEL,sha256=eOLhNAGa2EW3wWl_TU484h7q1UNgy0JXjjoqKoxAAQc,92
57
+ compressed_tensors_nightly-0.7.1.20241026.dist-info/top_level.txt,sha256=w2i-GyPs2s1UwVxvutSvN_lM22SXC2hQFBmoMcPnV7Y,19
58
+ compressed_tensors_nightly-0.7.1.20241026.dist-info/RECORD,,