compressed-tensors 0.12.0__py3-none-any.whl → 0.12.1__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.
@@ -344,6 +344,55 @@ class ModelCompressor:
344
344
  format, config=quantization_config
345
345
  )
346
346
 
347
+ def get_missing_module_keys(self, model: Module) -> List[str]:
348
+ """
349
+ Identifies the expected missing weight keys in the compressed state_dict.
350
+
351
+ When a model undergoes sparsity or quantization compression, certain
352
+ weight tensors may be absent from the checkpoint by virtue of compression.
353
+ This function determines which weight keys are missing based on the
354
+ applied compression techniques.
355
+
356
+ :param model: The PyTorch model to check for missing keys.
357
+ :return: A list of missing keys expected in the compressed state_dict.
358
+ """
359
+ missing_keys = set()
360
+
361
+ # Determine missing keys due to sparsity compression
362
+ if (
363
+ self.sparsity_compressor
364
+ and self.sparsity_config.format != CompressionFormat.dense.value
365
+ ):
366
+ sparse_targets = match_named_modules(
367
+ model=model,
368
+ targets=self.sparsity_config.targets,
369
+ ignore=self.sparsity_config.ignore,
370
+ )
371
+
372
+ missing_keys.update(
373
+ merge_names(target_name, "weight")
374
+ for target_name, _module in sparse_targets
375
+ )
376
+
377
+ # Determine missing keys due to pack quantization
378
+ if (
379
+ self.quantization_compressor
380
+ and self.quantization_config.format
381
+ == CompressionFormat.pack_quantized.value
382
+ ):
383
+ for scheme in self.quantization_config.config_groups.values():
384
+ quant_targets = match_named_modules(
385
+ model=model,
386
+ targets=scheme.targets,
387
+ ignore=self.quantization_config.ignore,
388
+ )
389
+ missing_keys.update(
390
+ merge_names(target_name, "weight")
391
+ for target_name, _module in quant_targets
392
+ )
393
+
394
+ return list(missing_keys)
395
+
347
396
  def get_unexpected_file_keys(self, model: Module) -> List[str]:
348
397
  """
349
398
  Identifies extra keys introduced by the compression process in the
@@ -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.0'
21
- __version_tuple__ = version_tuple = (0, 12, 0)
20
+ __version__ = version = '0.12.1'
21
+ __version_tuple__ = version_tuple = (0, 12, 1)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: compressed-tensors
3
- Version: 0.12.0
3
+ Version: 0.12.1
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,12 +1,12 @@
1
1
  compressed_tensors/__init__.py,sha256=SRqNYFVvxAaLa4SImhoiIBKfoOSj7EUdx0CxXjGC2PA,884
2
2
  compressed_tensors/base.py,sha256=-gxWvDF4LCkyeDP8YlGzvBBKxo4Dk9h4NINPD61drFU,921
3
3
  compressed_tensors/logger.py,sha256=sTm1Od1cV0aDxBm3YN-PPvsOATxY_2tBV62TQE4HiPw,4032
4
- compressed_tensors/version.py,sha256=MzIo18wy7DMt4bO6hDNzASQ2GwerF91Xd0bFMTS3VKA,513
4
+ compressed_tensors/version.py,sha256=DzB47l1iPNTY8yuA60VuZvneNqNdRBd1svEjKxC37o4,513
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
8
8
  compressed_tensors/compressors/model_compressors/__init__.py,sha256=5RGGPFu4YqEt_aOdFSQYFYFDjcZFJN0CsMqRtDZz3Js,666
9
- compressed_tensors/compressors/model_compressors/model_compressor.py,sha256=xoQzV660vjjqwo_kek_xHJYIeqtt2hsD-QNAlqLHDvo,36144
9
+ compressed_tensors/compressors/model_compressors/model_compressor.py,sha256=zPe3T0hyHuvIzSXHBWHPiqJ3sQcdVY3tgwF1aBeG7oo,38044
10
10
  compressed_tensors/compressors/quantized_compressors/__init__.py,sha256=KvaFBL_Q84LxRGJOV035M8OBoCkAx8kOkfphswgkKWk,745
11
11
  compressed_tensors/compressors/quantized_compressors/base.py,sha256=6GXhc2E5qFHnkcE3H2mx5CD2YtwfPXKUsvmsakzkkfA,10088
12
12
  compressed_tensors/compressors/quantized_compressors/naive_quantized.py,sha256=0ANDcuD8aXPqTYNPY6GnX9iS6eXJw6P0TzNV_rYS2l8,5369
@@ -66,8 +66,8 @@ compressed_tensors/utils/permute.py,sha256=wB8LCvQxmI7xnm67S8pbHzM5CDFgG8t4D8ema
66
66
  compressed_tensors/utils/safetensors_load.py,sha256=Vql34aCTDHwmTZXJHzCyBISJo7iA7EQ78LdTlMjdpZo,12023
67
67
  compressed_tensors/utils/semi_structured_conversions.py,sha256=XKNffPum54kPASgqKzgKvyeqWPAkair2XEQXjkp7ho8,13489
68
68
  compressed_tensors/utils/type.py,sha256=bNwoo_FWlvLuDpYAGGzZJITRg0JA_Ngk9LGPo-kvjeU,2554
69
- compressed_tensors-0.12.0.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
70
- compressed_tensors-0.12.0.dist-info/METADATA,sha256=xkQNnAskcLKSmMJFK2xOqazsnAu1_P0pagW-p00L7Wo,7018
71
- compressed_tensors-0.12.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
72
- compressed_tensors-0.12.0.dist-info/top_level.txt,sha256=w2i-GyPs2s1UwVxvutSvN_lM22SXC2hQFBmoMcPnV7Y,19
73
- compressed_tensors-0.12.0.dist-info/RECORD,,
69
+ compressed_tensors-0.12.1.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
70
+ compressed_tensors-0.12.1.dist-info/METADATA,sha256=rGHOzy2FZFRUNCuiBKb99tnWtlks5mAIBrR76QltFkM,7018
71
+ compressed_tensors-0.12.1.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
72
+ compressed_tensors-0.12.1.dist-info/top_level.txt,sha256=w2i-GyPs2s1UwVxvutSvN_lM22SXC2hQFBmoMcPnV7Y,19
73
+ compressed_tensors-0.12.1.dist-info/RECORD,,