From 48eae6f4204dbdca26e6c1f0c8dc64caa0e48f08 Mon Sep 17 00:00:00 2001 From: Sayak Paul Date: Thu, 19 Jun 2025 07:45:06 +0530 Subject: [PATCH] [Quantizers] add `is_compileable` property to quantizers. (#11736) add is_compileable property to quantizers. --- src/diffusers/quantizers/base.py | 5 +++++ src/diffusers/quantizers/bitsandbytes/bnb_quantizer.py | 4 ++++ src/diffusers/quantizers/gguf/gguf_quantizer.py | 4 ++++ src/diffusers/quantizers/quanto/quanto_quantizer.py | 4 ++++ src/diffusers/quantizers/torchao/torchao_quantizer.py | 4 ++++ 5 files changed, 21 insertions(+) diff --git a/src/diffusers/quantizers/base.py b/src/diffusers/quantizers/base.py index ffa654c98c..357d920d29 100644 --- a/src/diffusers/quantizers/base.py +++ b/src/diffusers/quantizers/base.py @@ -227,3 +227,8 @@ class DiffusersQuantizer(ABC): @property @abstractmethod def is_trainable(self): ... + + @property + def is_compileable(self) -> bool: + """Flag indicating whether the quantized model can be compiled""" + return False diff --git a/src/diffusers/quantizers/bitsandbytes/bnb_quantizer.py b/src/diffusers/quantizers/bitsandbytes/bnb_quantizer.py index 689d8e4256..0dfdff019b 100644 --- a/src/diffusers/quantizers/bitsandbytes/bnb_quantizer.py +++ b/src/diffusers/quantizers/bitsandbytes/bnb_quantizer.py @@ -564,6 +564,10 @@ class BnB8BitDiffusersQuantizer(DiffusersQuantizer): # Because we're mandating `bitsandbytes` 0.43.3. return True + @property + def is_compileable(self) -> bool: + return True + def _dequantize(self, model): from .utils import dequantize_and_replace diff --git a/src/diffusers/quantizers/gguf/gguf_quantizer.py b/src/diffusers/quantizers/gguf/gguf_quantizer.py index b3e10b1c32..aa5ebf5711 100644 --- a/src/diffusers/quantizers/gguf/gguf_quantizer.py +++ b/src/diffusers/quantizers/gguf/gguf_quantizer.py @@ -146,6 +146,10 @@ class GGUFQuantizer(DiffusersQuantizer): def is_trainable(self) -> bool: return False + @property + def is_compileable(self) -> bool: + return True + def _dequantize(self, model): is_model_on_cpu = model.device.type == "cpu" if is_model_on_cpu: diff --git a/src/diffusers/quantizers/quanto/quanto_quantizer.py b/src/diffusers/quantizers/quanto/quanto_quantizer.py index 0120163804..c5f71f816f 100644 --- a/src/diffusers/quantizers/quanto/quanto_quantizer.py +++ b/src/diffusers/quantizers/quanto/quanto_quantizer.py @@ -175,3 +175,7 @@ class QuantoQuantizer(DiffusersQuantizer): @property def is_serializable(self): return True + + @property + def is_compileable(self) -> bool: + return True diff --git a/src/diffusers/quantizers/torchao/torchao_quantizer.py b/src/diffusers/quantizers/torchao/torchao_quantizer.py index def7ee33e3..c12513f061 100644 --- a/src/diffusers/quantizers/torchao/torchao_quantizer.py +++ b/src/diffusers/quantizers/torchao/torchao_quantizer.py @@ -335,3 +335,7 @@ class TorchAoHfQuantizer(DiffusersQuantizer): @property def is_trainable(self): return self.quantization_config.quant_type.startswith("int8") + + @property + def is_compileable(self) -> bool: + return True