Skip to content

Commit 5b3e5eb

Browse files
committed
reset_quantization_status
Signed-off-by: Kyle Sayers <[email protected]>
1 parent fa75986 commit 5b3e5eb

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

src/llmcompressor/modifiers/quantization/calibration.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
"initialize_quantized_kv_cache",
2727
"freeze_module_quantization",
2828
"apply_calibration_status",
29+
"reset_quantization_status",
2930
]
3031

3132

@@ -246,3 +247,9 @@ def freeze_module_quantization(module: Module):
246247
delattr(module, "kv_cache")
247248

248249
module.quantization_status = QuantizationStatus.FROZEN
250+
251+
252+
def reset_quantization_status(model: Module):
253+
for module in model.modules():
254+
if hasattr(module, "quantization_status"):
255+
delattr(module, "quantization_status")

src/llmcompressor/modifiers/quantization/quantization/mixin.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
calibrate_output_hook,
2121
initialize_observer,
2222
initialize_quantized_kv_cache,
23+
reset_quantization_status,
2324
)
2425
from llmcompressor.modifiers.utils.hooks import HooksMixin
2526

@@ -106,8 +107,11 @@ def attach_scheme_and_observers(self, model: torch.nn.Module):
106107
Apply this modifier as a quantization config to the model. Attach observers
107108
according to the schemes attached to each module
108109
"""
110+
reset_quantization_status(model) # reset any previously applied qconfigs
111+
109112
config = self.resolve_quantization_config()
110113
apply_quantization_config(model, config)
114+
111115
model.apply(self._initialize_observers)
112116

113117
def register_calibration_hooks(self, model: torch.nn.Module):

0 commit comments

Comments
 (0)