From eaa496d09849fbc5501262a69b2a798984ca365a Mon Sep 17 00:00:00 2001 From: sayakpaul Date: Mon, 8 Jun 2026 11:51:31 +0530 Subject: [PATCH] small nits --- .../autoround/autoround_quantizer.py | 33 +++++-------------- 1 file changed, 9 insertions(+), 24 deletions(-) diff --git a/src/diffusers/quantizers/autoround/autoround_quantizer.py b/src/diffusers/quantizers/autoround/autoround_quantizer.py index 4ae58b91d1ff..f80563fed406 100644 --- a/src/diffusers/quantizers/autoround/autoround_quantizer.py +++ b/src/diffusers/quantizers/autoround/autoround_quantizer.py @@ -1,4 +1,4 @@ -# Copyright 2025 The HuggingFace Inc. team. All rights reserved. +# Copyright 2025 The Intel and The HuggingFace Inc. teams. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -14,11 +14,7 @@ from typing import TYPE_CHECKING -from ...utils import ( - is_auto_round_available, - is_torch_available, - logging, -) +from ...utils import is_auto_round_available, logging from ..base import DiffusersQuantizer @@ -26,9 +22,6 @@ from ...models.modeling_utils import ModelMixin -if is_torch_available(): - pass - logger = logging.get_logger(__name__) @@ -91,10 +84,9 @@ def _process_model_before_weight_loading( """ from auto_round.inference.convert_model import convert_hf_model, infer_target_device - if self.pre_quantized: - target_device = infer_target_device(self.device_map) - model, used_backends = convert_hf_model(model, target_device) - self.used_backends = used_backends + target_device = infer_target_device(self.device_map) + model, used_backends = convert_hf_model(model, target_device) + self.used_backends = used_backends def _process_model_after_weight_loading(self, model, **kwargs): """ @@ -103,22 +95,15 @@ def _process_model_after_weight_loading(self, model, **kwargs): Uses `auto_round.inference.convert_model.post_init` which: - Performs backend-specific finalization (e.g. repacking weights into the kernel's expected memory layout, - moving buffers to the correct device). + moving buffers to the correct device). - Freezes quantized parameters (requires_grad=False). - Prepares the model for inference. - Raises ValueError if the model is not pre-quantized, since AutoRound does not support on-the-fly quantization - through this loading path. """ - if self.pre_quantized: - from auto_round.inference.convert_model import post_init + from auto_round.inference.convert_model import post_init + + post_init(model, self.used_backends) - post_init(model, self.used_backends) - else: - raise ValueError( - "AutoRound quantizer in diffusers only supports pre-quantized models. " - "Please provide a model that has already been quantized with AutoRound." - ) return model @property