Skip to content

Commit d6d823c

Browse files
authored
Workaround HF Quantizer apply_quantization_config misuse (#180)
* workaround hf quantizer apply none * Add usage comment
1 parent c2455b7 commit d6d823c

File tree

1 file changed

+6
-2
lines changed
  • src/compressed_tensors/quantization/lifecycle

1 file changed

+6
-2
lines changed

src/compressed_tensors/quantization/lifecycle/apply.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,8 @@ def load_pretrained_quantization(model: Module, model_name_or_path: str):
107107

108108

109109
def apply_quantization_config(
110-
model: Module, config: QuantizationConfig, run_compressed: bool = False
111-
) -> Dict:
110+
model: Module, config: Union[QuantizationConfig, None], run_compressed: bool = False
111+
) -> OrderedDict:
112112
"""
113113
Initializes the model for quantization in-place based on the given config
114114
@@ -117,6 +117,10 @@ def apply_quantization_config(
117117
:param run_compressed: Whether the model will be run in compressed mode or
118118
decompressed fully on load
119119
"""
120+
# Workaround for when HF Quantizer passes None, see PR #180
121+
if config is None:
122+
return OrderedDict()
123+
120124
# remove reference to the original `config`
121125
# argument. This function can mutate it, and we'd
122126
# like to keep the original `config` as it is.

0 commit comments

Comments
 (0)