diff --git a/optimum/commands/export/openvino.py b/optimum/commands/export/openvino.py index 088194740c..55aacd3679 100644 --- a/optimum/commands/export/openvino.py +++ b/optimum/commands/export/openvino.py @@ -13,6 +13,7 @@ # limitations under the License. """Defines the command line for the export with OpenVINO.""" +import logging import sys from pathlib import Path from typing import TYPE_CHECKING, Optional @@ -21,6 +22,9 @@ from ..base import BaseOptimumCLICommand, CommandInfo +logger = logging.getLogger(__name__) + + if TYPE_CHECKING: from argparse import ArgumentParser, Namespace, _SubParsersAction @@ -68,6 +72,8 @@ def parse_args_openvino(parser: "ArgumentParser"): "This is needed by some models, for some tasks. If not provided, will attempt to use the tokenizer to guess it." ), ) + optional_group.add_argument("--fp16", action="store_true", help="Compress weights to fp16") + optional_group.add_argument("--int8", action="store_true", help="Compress weights to int8") optional_group.add_argument( "--weight-format", type=str, @@ -81,7 +87,10 @@ def parse_args_openvino(parser: "ArgumentParser"): "--ratio", type=float, default=0.8, - help="Compression ratio between primary and backup precision (only applicable to INT4 type).", + help=( + "Compression ratio between primary and backup precision. In the case of INT4, NNCF evaluates layer sensitivity and keeps the most impactful layers in INT8" + "precision (by default 20% in INT8). This helps to achieve better accuracy after weight quantization." + ), ) @@ -108,6 +117,17 @@ def parse_args(parser: "ArgumentParser"): def run(self): from ...exporters.openvino.__main__ import main_export + if self.args.fp16: + logger.warning( + "`--fp16` option is deprecated and will be removed in a future version. Use `--weight-format` instead." + ) + self.args.weight_format = "f16" + if self.args.int8: + logger.warning( + "`--int8` option is deprecated and will be removed in a future version. Use `--weight-format` instead." + ) + self.args.weight_format = "i8" + # TODO : add input shapes main_export( model_name_or_path=self.args.model,