Skip to content

Commit 1d9f2f8

Browse files
Fix automatic-speech-recognition-with-past quantization from CLI
1 parent 0652389 commit 1d9f2f8

File tree

3 files changed

+15
-3
lines changed

3 files changed

+15
-3
lines changed

optimum/commands/export/openvino.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -429,7 +429,7 @@ def run(self):
429429
maybe_convert_tokenizers(library_name, self.args.output, model, task=task)
430430
elif (
431431
quantize_with_dataset
432-
and (task.startswith("text-generation") or task == "automatic-speech-recognition")
432+
and (task.startswith("text-generation") or "automatic-speech-recognition" in task)
433433
or (task == "image-text-to-text" and quantization_config is not None)
434434
):
435435
if task.startswith("text-generation"):

optimum/intel/openvino/utils.py

+1
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@
134134
"open_clip_vision": "OVModelOpenCLIPVisual",
135135
"open_clip": "OVModelOpenCLIPForZeroShotImageClassification",
136136
"automatic-speech-recognition": "OVModelForSpeechSeq2Seq",
137+
"automatic-speech-recognition-with-past": "OVModelForSpeechSeq2Seq",
137138
}
138139

139140

tests/openvino/test_exporters_cli.py

+13-2
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,16 @@ class OVCLIExportTestCase(unittest.TestCase):
193193
if is_transformers_version("<=", "4.36.0")
194194
else [{"int8": 14}, {"int8": 22}, {"int8": 18}],
195195
),
196+
(
197+
"automatic-speech-recognition-with-past",
198+
"whisper",
199+
"int8",
200+
"--dataset librispeech --num-samples 1 --smooth-quant-alpha 0.9 --trust-remote-code",
201+
[14, 22, 21] if is_transformers_version("<=", "4.36.0") else [14, 22, 25],
202+
[{"int8": 14}, {"int8": 21}, {"int8": 17}]
203+
if is_transformers_version("<=", "4.36.0")
204+
else [{"int8": 14}, {"int8": 22}, {"int8": 18}],
205+
),
196206
(
197207
"text-generation",
198208
"llama",
@@ -694,13 +704,14 @@ def test_exporters_cli_full_quantization(
694704
):
695705
with TemporaryDirectory() as tmpdir:
696706
subprocess.run(
697-
f"optimum-cli export openvino --model {MODEL_NAMES[model_type]} --quant-mode {quant_mode} {option} {tmpdir}",
707+
f"optimum-cli export openvino --task {task} --model {MODEL_NAMES[model_type]} "
708+
f"--quant-mode {quant_mode} {option} {tmpdir}",
698709
shell=True,
699710
check=True,
700711
)
701712
model = eval(_HEAD_TO_AUTOMODELS[task]).from_pretrained(tmpdir)
702713

703-
if task == "automatic-speech-recognition":
714+
if "automatic-speech-recognition" in task:
704715
submodels = [model.encoder, model.decoder]
705716
if model.decoder_with_past is not None:
706717
submodels.append(model.decoder_with_past)

0 commit comments

Comments
 (0)