Skip to content

Commit

Permalink
fix device selection for compilation language model in vlm
Browse files Browse the repository at this point in the history
  • Loading branch information
eaidova committed Nov 5, 2024
1 parent f08e8b7 commit 25b42c5
Showing 1 changed file with 17 additions and 6 deletions.
23 changes: 17 additions & 6 deletions optimum/intel/openvino/modeling_visual_language.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 25b42c5

Please sign in to comment.