Skip to content

Commit

Permalink
ENH: Do not pass warning message in case quantization_config is in …
Browse files Browse the repository at this point in the history
…config but not passed as an arg (#28988)

* Update auto.py

* Update auto.py

* Update src/transformers/quantizers/auto.py

Co-authored-by: amyeroberts <22614925+amyeroberts@users.noreply.github.com>

* Update src/transformers/quantizers/auto.py

Co-authored-by: amyeroberts <22614925+amyeroberts@users.noreply.github.com>

---------

Co-authored-by: amyeroberts <22614925+amyeroberts@users.noreply.github.com>
  • Loading branch information
younesbelkada and amyeroberts authored Feb 14, 2024
1 parent bd4b83e commit 1d12b8b
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions src/transformers/quantizers/auto.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,10 +129,13 @@ def merge_quantization_configs(
"""
handles situations where both quantization_config from args and quantization_config from model config are present.
"""
warning_msg = (
"You passed `quantization_config` or equivalent parameters to `from_pretrained` but the model you're loading"
" already has a `quantization_config` attribute. The `quantization_config` from the model will be prevail."
)
if quantization_config_from_args is not None:
warning_msg = (
"You passed `quantization_config` or equivalent parameters to `from_pretrained` but the model you're loading"
" already has a `quantization_config` attribute. The `quantization_config` from the model will be used."
)
else:
warning_msg = ""

if isinstance(quantization_config, dict):
quantization_config = AutoQuantizationConfig.from_dict(quantization_config)
Expand All @@ -144,5 +147,7 @@ def merge_quantization_configs(
setattr(quantization_config, attr, val)
warning_msg += f"However, loading attributes (e.g. {list(loading_attr_dict.keys())}) will be overwritten with the one you passed to `from_pretrained`. The rest will be ignored."

warnings.warn(warning_msg)
if warning_msg != "":
warnings.warn(warning_msg)

return quantization_config

0 comments on commit 1d12b8b

Please sign in to comment.