Skip to content

Commit aa3ee74

Browse files
Remove explicit init_kwargs
1 parent 65679a5 commit aa3ee74

File tree

1 file changed

+9
-12
lines changed

1 file changed

+9
-12
lines changed

optimum/intel/openvino/configuration.py

+9-12
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,6 @@ def __init__(
295295
tokenizer: Optional[str] = None,
296296
processor: Optional[str] = None,
297297
trust_remote_code: Optional[bool] = False,
298-
init_kwargs: Optional[dict] = None,
299298
**kwargs,
300299
):
301300
"""
@@ -315,8 +314,6 @@ def __init__(
315314
Allows to use custom code for the modeling hosted in the model repository. This option should only be
316315
set for repositories you trust and in which you have read the code, as it will execute on your local
317316
machine arbitrary code present in the model repository.
318-
init_kwargs ('dict', *optional*):
319-
Additional parameters for NNCF calls. This explicit argument is needed for deserialization from dict.
320317
"""
321318
self.num_samples = num_samples
322319
self.dataset = dataset
@@ -326,7 +323,7 @@ def __init__(
326323
if isinstance(ignored_scope, nncf.IgnoredScope):
327324
ignored_scope = ignored_scope.__dict__
328325
self.ignored_scope = ignored_scope
329-
self.init_kwargs = (init_kwargs or {}) | kwargs
326+
self.init_kwargs = kwargs
330327

331328
def post_init(self):
332329
try:
@@ -346,6 +343,12 @@ def get_ignored_scope_instance(self) -> "nncf.IgnoredScope":
346343
def clone(self):
347344
return copy.deepcopy(self)
348345

346+
def to_dict(self) -> Dict[str, Any]:
347+
# Unpack init kwargs back into kwargs
348+
result = super().to_dict()
349+
result = result | result.pop("init_kwargs", {})
350+
return result
351+
349352

350353
@dataclass
351354
class OVWeightQuantizationConfig(OVQuantizationConfigBase):
@@ -431,8 +434,6 @@ class OVWeightQuantizationConfig(OVQuantizationConfigBase):
431434
retained in their original precision without any quantization.
432435
- "int8_sym" stands for 8-bit integer symmetric quantization without zero point.
433436
- "int8_asym" stands for 8-bit integer asymmetric quantization with zero points per each quantization group.
434-
init_kwargs ('dict', *optional*):
435-
Additional parameters for nncf.compress_weights() call. This explicit argument is needed for deserialization from dict.
436437
kwargs: Additional parameters for nncf.compress_weights() call.
437438
"""
438439

@@ -456,7 +457,6 @@ def __init__(
456457
processor: Optional[str] = None,
457458
lora_correction: bool = None,
458459
backup_precision: Optional[str] = None,
459-
init_kwargs: Optional[dict] = None,
460460
**kwargs,
461461
):
462462
weight_format = kwargs.pop("weight_format", None)
@@ -473,7 +473,6 @@ def __init__(
473473
tokenizer=tokenizer,
474474
processor=processor,
475475
trust_remote_code=trust_remote_code,
476-
init_kwargs=init_kwargs,
477476
**kwargs,
478477
)
479478
self.bits = bits
@@ -678,7 +677,6 @@ def __init__(
678677
trust_remote_code: bool = False,
679678
smooth_quant_alpha: Optional[float] = None,
680679
dtype: Optional[str] = "int8",
681-
init_kwargs: Optional[dict] = None,
682680
**kwargs,
683681
):
684682
"""
@@ -725,8 +723,6 @@ def __init__(
725723
reduces quantization error.
726724
dtype (`str`, defaults to "int8"):
727725
Data type activations are compressed to. Possible values: ['int8', 'f8e4m3', 'f8e5m2'].
728-
init_kwargs ('dict', *optional*):
729-
Additional parameters for nncf.quantize() call. This explicit argument is needed for deserialization from dict.
730726
kwargs: Additional parameters for nncf.quantize() call.
731727
"""
732728
activation_format = kwargs.pop("activation_format", None)
@@ -743,7 +739,6 @@ def __init__(
743739
tokenizer=tokenizer,
744740
processor=processor,
745741
trust_remote_code=trust_remote_code,
746-
init_kwargs=init_kwargs,
747742
**kwargs,
748743
)
749744
self.bits = bits
@@ -946,6 +941,7 @@ def __init__(
946941
Allows to use custom code for the modeling hosted in the model repository. This option should only be
947942
set for repositories you trust and in which you have read the code, as it will execute on your local
948943
machine arbitrary code present in the model repository.
944+
**kwargs:
949945
"""
950946
self.weight_quantization_config = self._initialize_quantization_config(
951947
weight_quantization_config, OVWeightQuantizationConfig
@@ -980,6 +976,7 @@ def __init__(
980976
tokenizer=tokenizer,
981977
processor=processor,
982978
trust_remote_code=trust_remote_code,
979+
**kwargs,
983980
)
984981

985982
self.post_init()

0 commit comments

Comments
 (0)