Skip to content

Commit

Permalink
Turn off sparse decompression when sparse compressor is dense
Browse files Browse the repository at this point in the history
  • Loading branch information
rahul-tuli committed Jan 10, 2025
1 parent f0c369a commit 90beee8
Showing 1 changed file with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -269,9 +269,9 @@ def compress(

compressed_state_dict = state_dict

quantized_modules_to_args: Dict[
str, QuantizationArgs
] = map_modules_to_quant_args(model)
quantized_modules_to_args: Dict[str, QuantizationArgs] = (
map_modules_to_quant_args(model)
)

if self.quantization_compressor is not None:
compressed_state_dict = self.quantization_compressor.compress(
Expand Down Expand Up @@ -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 != "dense"
):
# Sparse decompression is applied on the model_path
dense_gen = self.sparsity_compressor.decompress(model_path)
self._replace_weights(dense_gen, model)
Expand Down

0 comments on commit 90beee8

Please sign in to comment.