From 25b42c5499ca6ee59a00e392eceb1b02cde5a953 Mon Sep 17 00:00:00 2001 From: eaidova Date: Thu, 24 Oct 2024 14:43:40 +0400 Subject: [PATCH] fix device selection for compilation language model in vlm --- .../openvino/modeling_visual_language.py | 23 ++++++++++++++----- 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/optimum/intel/openvino/modeling_visual_language.py b/optimum/intel/openvino/modeling_visual_language.py index 74d7c88d6..e0c203d8f 100644 --- a/optimum/intel/openvino/modeling_visual_language.py +++ b/optimum/intel/openvino/modeling_visual_language.py @@ -54,14 +54,25 @@ def __init__( def compile(self): if self.request is None: - logger.info(f"Compiling the Language model to {self._device} ...") - self.request = core.compile_model(self.model, self._device, self.ov_config).create_infer_request() + if self._compile_only: + self.request = self.model.create_infer_request() + else: + logger.info(f"Compiling the Language model to {self._device} ...") + self.request = self._compile_model( + self.model, self._device, self.ov_config, self.model_save_dir + ).create_infer_request() self._compile_text_emb() def _compile_text_emb(self): if self.text_emb_request is None: logger.info(f"Compiling the Text embeddings model to {self._device} ...") - self.text_emb_request = core.compile_model(self.text_emb_model, self._device, self.ov_config) + if self._compile_only: + self.text_emb_request = self.text_emb_model + else: + logger.info(f"Compiling the Text embeddings model to {self._device} ...") + self.text_emb_request = self._compile_model( + self.text_emb_model, self._device, self.ov_config, self.model_save_dir + ) def clear_requests(self): if self._compile_only: @@ -263,11 +274,11 @@ def __init__( self.lm_model, self.text_embdings_model, config=config, - deivce=device, + device=device, ov_config=ov_config, model_save_dir=model_save_dir, quantization_config=quantization_config, - compile=not self._compile_only, + compile=self._compile_only, compile_only=self._compile_only, ) self.vision_embeddings = OVVisionEmbedding(self.vision_embeddings_model, self) @@ -308,7 +319,7 @@ def _save_pretrained(self, save_directory: Union[str, Path]): dst_file_names = [ "openvino_language_model.xml", "openvino_text_embeddings_model.xml", - "openvino_vision_embeddings.xml", + "openvino_vision_embeddings_model.xml", ] for part in self.additional_parts: model = getattr(self, f"{part}_model", None)