Skip to content

Commit

Permalink
add save logic after oneshot is carried out
Browse files Browse the repository at this point in the history
  • Loading branch information
horheynm committed Oct 9, 2024
1 parent b3c474f commit ecd0c23
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/llmcompressor/pytorch/model_load/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from typing import Any, Dict, List, Optional

import torch
from compressed_tensors.quantization.utils import is_model_quantized
from loguru import logger
from safetensors import safe_open
from torch.nn import Module
Expand Down Expand Up @@ -106,6 +107,12 @@ def save_model_and_recipe(
:param save_safetensors: whether to save as safetensors or pickle (bin)
:param save_compressed: whether to compress sparse weights on disk
"""
if is_model_quantized(model):
from llmcompressor.transformers.sparsification.compressed_tensors_utils import (
modify_save_pretrained,
)

modify_save_pretrained(model)

model.save_pretrained(
save_path, save_compressed=save_compressed, safe_serialization=save_safetensors
Expand Down

0 comments on commit ecd0c23

Please sign in to comment.