Skip to content

Commit 37e8504

Browse files
authored
Fix automatic task detection for phi4-multimodal during data-aware quant (#1293)
* fix automatic task detection for phi4-multimodal during data-aware quant * refactoring
1 parent 2ae6ca2 commit 37e8504

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

optimum/commands/export/openvino.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -404,6 +404,19 @@ def run(self):
404404
quantization_config = ov_config.quantization_config if ov_config else None
405405
quantize_with_dataset = quantization_config and getattr(quantization_config, "dataset", None) is not None
406406
task = infer_task(self.args.task, self.args.model, library_name=library_name)
407+
# in some cases automatic task detection for multimodal models gives incorrect results
408+
if self.args.task == "auto" and library_name == "transformers":
409+
from transformers import AutoConfig
410+
411+
from ...exporters.openvino.utils import MULTI_MODAL_TEXT_GENERATION_MODELS
412+
413+
config = AutoConfig.from_pretrained(
414+
self.args.model,
415+
cache_dir=self.args.cache_dir,
416+
trust_remote_code=self.args.trust_remote_code,
417+
)
418+
if getattr(config, "model_type", "").replace("_", "-") in MULTI_MODAL_TEXT_GENERATION_MODELS:
419+
task = "image-text-to-text"
407420

408421
if library_name == "diffusers" and quantize_with_dataset:
409422
if not is_diffusers_available():

0 commit comments

Comments
 (0)