Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
chenpangpang
transformers
Commits
6b39470b
Unverified
Commit
6b39470b
authored
Nov 16, 2023
by
Marc Sun
Committed by
GitHub
Nov 16, 2023
Browse files
Raise error when quantizing a quantized model (#27500)
add error msg
parent
fd65aa98
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
1 deletion
+6
-1
src/transformers/modeling_utils.py
src/transformers/modeling_utils.py
+6
-1
No files found.
src/transformers/modeling_utils.py
View file @
6b39470b
...
...
@@ -2781,7 +2781,12 @@ class PreTrainedModel(nn.Module, ModuleUtilsMixin, GenerationMixin, PushToHubMix
quantization_method_from_config
=
config
.
quantization_config
.
get
(
"quant_method"
,
QuantizationMethod
.
BITS_AND_BYTES
)
if
quantization_method_from_config
is
not
None
and
quantization_method_from_args
is
not
None
:
if
quantization_method_from_config
!=
quantization_method_from_args
:
raise
ValueError
(
f
"The model is already quantized with
{
quantization_method_from_config
}
. "
f
"You can't quantize it again with
{
quantization_method_from_args
}
"
)
if
quantization_method_from_config
==
QuantizationMethod
.
GPTQ
and
quantization_method_from_args
is
not
None
:
loading_attr_dict
=
quantization_config
.
get_loading_attributes
()
for
attr
,
val
in
loading_attr_dict
.
items
():
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment