Skip to content

Commit 258cc55

Browse files
Added a warning when some compression parameters were provided, but --weight-format was not
1 parent 12438c4 commit 258cc55

File tree

2 files changed

+26
-14
lines changed

2 files changed

+26
-14
lines changed

optimum/commands/export/openvino.py

+24-12
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,24 @@ def parse_args_openvino(parser: "ArgumentParser"):
190190
)
191191

192192

193+
def no_compression_parameter_provided(args):
194+
return all(
195+
map(
196+
lambda x: x is None,
197+
(
198+
args.ratio,
199+
args.group_size,
200+
args.sym,
201+
args.all_layers,
202+
args.dataset,
203+
args.num_samples,
204+
args.awq,
205+
args.sensitivity_metric,
206+
),
207+
)
208+
)
209+
210+
193211
class OVExportCommand(BaseOptimumCLICommand):
194212
COMMAND = CommandInfo(name="openvino", help="Export PyTorch models to OpenVINO IR.")
195213

@@ -230,23 +248,17 @@ def run(self):
230248

231249
if self.args.weight_format is None:
232250
ov_config = None
251+
if not no_compression_parameter_provided(self.args):
252+
logger.warning(
253+
"The provided compression parameters will not affect conversion because of the missing --weight-format argument."
254+
)
233255
elif self.args.weight_format in {"fp16", "fp32"}:
234256
ov_config = OVConfig(dtype=self.args.weight_format)
235257
else:
236258
is_int8 = self.args.weight_format == "int8"
237259

238-
# For int4 quantization if not parameter is provided, then use the default config if exist
239-
if (
240-
not is_int8
241-
and self.args.ratio is None
242-
and self.args.group_size is None
243-
and self.args.sym is None
244-
and self.args.all_layers is None
245-
and self.args.dataset is None
246-
and self.args.num_samples is None
247-
and self.args.awq is None
248-
and self.args.sensitivity_metric is None
249-
):
260+
# For int4 quantization if no parameter is provided, then use the default config if exist
261+
if no_compression_parameter_provided(self.args) and not is_int8:
250262
quantization_config = get_default_int4_config(self.args.model)
251263
else:
252264
quantization_config = {

optimum/exporters/openvino/convert.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -635,9 +635,9 @@ def export_from_model(
635635
if is_nncf_available():
636636
from ...intel.openvino.configuration import OVConfig
637637

638-
ov_config = OVConfig(quantization_config={"bits": 8})
638+
ov_config = OVConfig(quantization_config={"bits": 8, "sym": False})
639639

640-
logger.info("The model weights will be quantized to int8.")
640+
logger.info("The model weights will be quantized to int8_asym.")
641641
else:
642642
logger.warning(
643643
"The model will be converted with no weights quantization. Quantization of the weights to int8 requires nncf."

0 commit comments

Comments
 (0)