Skip to content

Commit c259d4f

Browse files
Address comments
1 parent b564e7d commit c259d4f

File tree

2 files changed

+22
-9
lines changed

2 files changed

+22
-9
lines changed

optimum/intel/openvino/configuration.py

+19-4
Original file line numberDiff line numberDiff line change
@@ -444,6 +444,12 @@ def __init__(
444444
self.gptq = gptq
445445
self.lora_correction = lora_correction
446446
self.backup_precision = backup_precision
447+
if kwargs.get("weight_format") is not None:
448+
logger.warning(
449+
"The `weight_format` parameter is deprecated and will be removed in optimum-intel v1.24.0. "
450+
"Please use `dtype` instead."
451+
)
452+
dtype = kwargs.get("weight_format")
447453
self.dtype = dtype
448454
self.post_init()
449455

@@ -484,7 +490,12 @@ def post_init(self):
484490
)
485491

486492
if self.dtype in ["int4", "int8"]:
487-
self.bits = 4 if self.dtype == "int4" else 8
493+
bits = 4 if self.dtype == "int4" else 8
494+
if self.bits is not None and self.bits != bits:
495+
logger.warning(
496+
f"Overriding `bits` parameter to the value `bits`={bits} to match the given {self.dtype} `dtype`."
497+
)
498+
self.bits = bits
488499

489500
if self.bits not in [4, 8]:
490501
raise ValueError(f"Only support quantization to [4,8] bits but found {self.bits}")
@@ -690,6 +701,12 @@ def __init__(
690701
self.fast_bias_correction = fast_bias_correction
691702
self.overflow_fix = overflow_fix
692703
self.smooth_quant_alpha = smooth_quant_alpha
704+
if kwargs.get("activation_format") is not None:
705+
logger.warning(
706+
"The `activation_format` parameter is deprecated and will be removed in optimum-intel v1.24.0. "
707+
"Please use `dtype` instead."
708+
)
709+
dtype = kwargs.get("activation_format")
693710
self.dtype = dtype
694711

695712
f8_dtypes = ["f8e4m3", "f8e5m2"]
@@ -778,9 +795,7 @@ def __init__(
778795
"compression", None
779796
) # A field for backward-compatability of training-time compression parameters
780797
if self.quantization_config is not None:
781-
if isinstance(self.quantization_config, OVWeightQuantizationConfig) or isinstance(
782-
self.quantization_config, OVQuantizationConfig
783-
):
798+
if isinstance(self.quantization_config, (OVWeightQuantizationConfig, OVQuantizationConfig)):
784799
self.dtype = self.quantization_config.dtype
785800
elif isinstance(self.quantization_config, OVMixedQuantizationConfig):
786801
wc_dtype = self.quantization_config.weight_quantization_config.dtype

optimum/intel/openvino/modeling_base.py

+3-5
Original file line numberDiff line numberDiff line change
@@ -250,11 +250,9 @@ def fix_op_names_duplicates(model: openvino.runtime.Model):
250250

251251
from optimum.intel.openvino.quantization import _weight_only_quantization
252252

253-
if not isinstance(quantization_config, dict) and not isinstance(
254-
quantization_config, OVWeightQuantizationConfig
255-
):
256-
raise RuntimeError(
257-
"Expected quantization_config to be a dictionary or OVWeightQuantizationConfig object."
253+
if not isinstance(quantization_config, (dict, OVWeightQuantizationConfig)):
254+
raise TypeError(
255+
f"Expected `quantization_config` to be either a dictionary or OVWeightQuantizationConfig object, got {type(quantization_config)}."
258256
)
259257

260258
model = _weight_only_quantization(model, quantization_config)

0 commit comments

Comments
 (0)