Skip to content

Commit

Permalink
fixtypo
Browse files Browse the repository at this point in the history
Signed-off-by: Zhang, Weiwei1 <[email protected]>
  • Loading branch information
WeiweiZhang1 committed Sep 14, 2024
1 parent 7fbf186 commit 41bfca5
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions neural_compressor/torch/algorithms/weight_only/save_load.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ def save(model, output_dir="./saved_results", format=LoadFormat.DEFAULT, **kwarg
os.makedirs(output_dir, exist_ok=True)
if format == LoadFormat.HUGGINGFACE: # # pragma: no cover
config = model.config
quantization_config = config.quantization_config if hasattr(config, "quantization_config") else None
if "backend" in quantization_config and "auto_round" in quantization_config["backend"]:
self.quantization_config = config.quantization_config if hasattr(config, "quantization_config") else None
if "backend" in self.quantization_config and 'auto_round' in self.quantization_config['backend']:
safe_serialization = kwargs.get("safe_serialization", True)
tokenizer = kwargs.get("tokenizer", None)
max_shard_size = kwargs.get("max_shard_size", "5GB")
Expand All @@ -65,7 +65,7 @@ def save(model, output_dir="./saved_results", format=LoadFormat.DEFAULT, **kwarg
del model.save
model.save_pretrained(output_dir, max_shard_size=max_shard_size, safe_serialization=safe_serialization)
return

qmodel_weight_file_path = os.path.join(os.path.abspath(os.path.expanduser(output_dir)), WEIGHT_NAME)
qconfig_file_path = os.path.join(os.path.abspath(os.path.expanduser(output_dir)), QCONFIG_NAME)
# saving process
Expand Down Expand Up @@ -140,7 +140,7 @@ def load_woq_model(self):
"""
if self.format == LoadFormat.HUGGINGFACE:
assert self.model_name_or_path is not None, "'model_name_or_path' can't be None."

model = self.load_hf_format_woq_model()
logger.info("Loading HuggingFace weight-only quantization model successfully.")
elif self.format == LoadFormat.DEFAULT:
Expand Down Expand Up @@ -213,7 +213,7 @@ def load_hf_format_woq_model(self):
"""
# check required package
from neural_compressor.torch.utils import is_package_available

if not is_package_available("transformers"):
raise ImportError("Loading huggingface model requires transformers: `pip install transformers`")
if not is_package_available("accelerate"):
Expand All @@ -225,7 +225,6 @@ def load_hf_format_woq_model(self):
if "backend" in quantization_config and "auto_round" in quantization_config["backend"]: # # pragma: no cover
# load autoround format quantized model
from auto_round import AutoRoundConfig

model = model_class.from_pretrained(self.model_name_or_path)
return model
# get loaded state_dict
Expand Down Expand Up @@ -889,3 +888,4 @@ def _use_hpu_module(self): # pragma: no cover
if os.path.exists(os.path.join(self._model_local_dir, HPU_WEIGHT_NAME)):
return True
return False

0 comments on commit 41bfca5

Please sign in to comment.