Skip to content

Commit 40194a0

Browse files
Deprecate export parameters (huggingface#886)
1 parent b51ca3f commit 40194a0

File tree

3 files changed

+1
-46
lines changed

3 files changed

+1
-46
lines changed

optimum/exporters/openvino/__main__.py

-38
Original file line numberDiff line numberDiff line change
@@ -49,15 +49,6 @@
4949
import torch
5050

5151

52-
_COMPRESSION_OPTIONS = {
53-
"int8": {"bits": 8},
54-
"int4_sym_g128": {"bits": 4, "sym": True, "group_size": 128},
55-
"int4_asym_g128": {"bits": 4, "sym": False, "group_size": 128},
56-
"int4_sym_g64": {"bits": 4, "sym": True, "group_size": 64},
57-
"int4_asym_g64": {"bits": 4, "sym": False, "group_size": 64},
58-
}
59-
60-
6152
logger = logging.getLogger(__name__)
6253

6354

@@ -108,8 +99,6 @@ def main_export(
10899
model_kwargs: Optional[Dict[str, Any]] = None,
109100
custom_export_configs: Optional[Dict[str, "OnnxConfig"]] = None,
110101
fn_get_submodels: Optional[Callable] = None,
111-
compression_option: Optional[str] = None,
112-
compression_ratio: Optional[float] = None,
113102
ov_config: "OVConfig" = None,
114103
stateful: bool = True,
115104
convert_tokenizer: bool = False,
@@ -171,11 +160,6 @@ def main_export(
171160
fn_get_submodels (`Optional[Callable]`, defaults to `None`):
172161
Experimental usage: Override the default submodels that are used at the export. This is
173162
especially useful when exporting a custom architecture that needs to split the ONNX (e.g. encoder-decoder). If unspecified with custom models, optimum will try to use the default submodels used for the given task, with no guarantee of success.
174-
compression_option (`Optional[str]`, defaults to `None`):
175-
The weight compression option, e.g. `f16` stands for float16 weights, `i8` - INT8 weights, `int4_sym_g128` - INT4 symmetric weights w/ group size 128, `int4_asym_g128` - as previous but asymmetric w/ zero-point,
176-
`int4_sym_g64` - INT4 symmetric weights w/ group size 64, "int4_asym_g64" - as previous but asymmetric w/ zero-point, `f32` - means no compression.
177-
compression_ratio (`Optional[float]`, defaults to `None`):
178-
Compression ratio between primary and backup precision (only relevant to INT4).
179163
stateful (`bool`, defaults to `True`):
180164
Produce stateful model where all kv-cache inputs and outputs are hidden in the model and are not exposed as model inputs and outputs. Applicable only for decoder models.
181165
**kwargs_shapes (`Dict`):
@@ -198,28 +182,6 @@ def main_export(
198182
raise ValueError("You cannot use both `use_auth_token` and `token` arguments at the same time.")
199183
token = use_auth_token
200184

201-
if compression_option is not None:
202-
logger.warning(
203-
"The `compression_option` argument is deprecated and will be removed in optimum-intel v1.17.0. "
204-
"Please, pass an `ov_config` argument instead `OVConfig(..., quantization_config=quantization_config)`."
205-
)
206-
207-
if compression_ratio is not None:
208-
logger.warning(
209-
"The `compression_ratio` argument is deprecated and will be removed in optimum-intel v1.17.0. "
210-
"Please, pass an `ov_config` argument instead `OVConfig(quantization_config={ratio=compression_ratio})`."
211-
)
212-
213-
if ov_config is None and compression_option is not None:
214-
from ...intel.openvino.configuration import OVConfig
215-
216-
if compression_option == "fp16":
217-
ov_config = OVConfig(dtype="fp16")
218-
elif compression_option != "fp32":
219-
q_config = _COMPRESSION_OPTIONS[compression_option] if compression_option in _COMPRESSION_OPTIONS else {}
220-
q_config["ratio"] = compression_ratio or 1.0
221-
ov_config = OVConfig(quantization_config=q_config)
222-
223185
original_task = task
224186
task = infer_task(
225187
task, model_name_or_path, subfolder=subfolder, revision=revision, cache_dir=cache_dir, token=token

tests/openvino/test_export.py

-3
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
import unittest
1717
from pathlib import Path
1818
from tempfile import TemporaryDirectory
19-
from typing import Optional
2019

2120
import torch
2221
from parameterized import parameterized
@@ -76,7 +75,6 @@ class ExportModelTest(unittest.TestCase):
7675
def _openvino_export(
7776
self,
7877
model_type: str,
79-
compression_option: Optional[str] = None,
8078
stateful: bool = True,
8179
patch_16bit_model: bool = False,
8280
):
@@ -106,7 +104,6 @@ def _openvino_export(
106104
output=Path(tmpdirname),
107105
task=supported_task,
108106
preprocessors=preprocessors,
109-
compression_option=compression_option,
110107
stateful=stateful,
111108
)
112109

tests/openvino/test_exporters_cli.py

+1-5
Original file line numberDiff line numberDiff line change
@@ -108,16 +108,12 @@ class OVCLIExportTestCase(unittest.TestCase):
108108
),
109109
]
110110

111-
def _openvino_export(
112-
self, model_name: str, task: str, compression_option: str = None, compression_ratio: float = None
113-
):
111+
def _openvino_export(self, model_name: str, task: str):
114112
with TemporaryDirectory() as tmpdir:
115113
main_export(
116114
model_name_or_path=model_name,
117115
output=tmpdir,
118116
task=task,
119-
compression_option=compression_option,
120-
compression_ratio=compression_ratio,
121117
)
122118

123119
@parameterized.expand(SUPPORTED_ARCHITECTURES)

0 commit comments

Comments
 (0)