From 6fffbd7af83e7b69cb2e43137e4ed70644096c77 Mon Sep 17 00:00:00 2001 From: Rahul Tuli Date: Fri, 10 Jan 2025 10:51:23 -0500 Subject: [PATCH] Fix: Disable Sparse Decompression for Dense Compressors (#237) * Turn off sparse decompression when sparse compressor is dense * Update: Condiition to use enum instead of raw string * Remove unnecesarry style change --- .../compressors/model_compressors/model_compressor.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/compressed_tensors/compressors/model_compressors/model_compressor.py b/src/compressed_tensors/compressors/model_compressors/model_compressor.py index 5ea26705..951eef1f 100644 --- a/src/compressed_tensors/compressors/model_compressors/model_compressor.py +++ b/src/compressed_tensors/compressors/model_compressors/model_compressor.py @@ -310,7 +310,10 @@ def decompress(self, model_path: str, model: Module): model_path = get_safetensors_folder(model_path) sparse_decompressed = False - if self.sparsity_compressor is not None: + if ( + self.sparsity_compressor is not None + and self.sparsity_config.format != CompressionFormat.dense.value + ): # Sparse decompression is applied on the model_path dense_gen = self.sparsity_compressor.decompress(model_path) self._replace_weights(dense_gen, model)