Skip to content

Commit abc8607

Browse files
committed
make the unused kwargs warning friendlier.
1 parent 330fa0a commit abc8607

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/diffusers/quantizers/quantization_config.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ class QuantizationConfigMixin:
5050
"""
5151

5252
quant_method: QuantizationMethod
53+
_exclude_attributes_at_init = []
5354

5455
@classmethod
5556
def from_dict(cls, config_dict, return_unused_kwargs=False, **kwargs):
@@ -210,6 +211,8 @@ class BitsAndBytesConfig(QuantizationConfigMixin):
210211
Additional parameters from which to initialize the configuration object.
211212
"""
212213

214+
_exclude_attributes_at_init = ["_load_in_4bit", "_load_in_8bit", "quant_method"]
215+
213216
def __init__(
214217
self,
215218
load_in_8bit=False,
@@ -260,7 +263,7 @@ def __init__(
260263
else:
261264
raise ValueError("bnb_4bit_quant_storage must be a string or a torch.dtype")
262265

263-
if kwargs:
266+
if kwargs and not all(k in self._exclude_attributes_at_init for k in kwargs):
264267
logger.warning(f"Unused kwargs: {list(kwargs.keys())}. These kwargs are not used in {self.__class__}.")
265268

266269
self.post_init()

0 commit comments

Comments
 (0)