From 0e67735bcdcfee8d1c203af76d0f0b0af525fbda Mon Sep 17 00:00:00 2001 From: eaidova Date: Tue, 12 Nov 2024 12:05:36 +0400 Subject: [PATCH] update tests --- .../intel/openvino/modeling_visual_language.py | 3 ++- tests/openvino/test_modeling.py | 17 +++++++++++++---- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/optimum/intel/openvino/modeling_visual_language.py b/optimum/intel/openvino/modeling_visual_language.py index 8bd6257b54..d6987b2a39 100644 --- a/optimum/intel/openvino/modeling_visual_language.py +++ b/optimum/intel/openvino/modeling_visual_language.py @@ -16,6 +16,7 @@ from transformers import ( AutoConfig, AutoImageProcessor, + AutoModelForCausalLM, GenerationConfig, GenerationMixin, PretrainedConfig, @@ -360,7 +361,7 @@ def _save_pretrained(self, save_directory: Union[str, Path]): save_directory (`str` or `Path`): The directory where to save the model files. """ - src_files = [self.lm_model, self.text_embdings_model, self.vision_embeddings_model] + src_files = [self.lm_model, self.text_embeddings_model, self.vision_embeddings_model] dst_file_names = [OV_LANGUAGE_MODEL_NAME, OV_TEXT_EMBEDDINGS_MODEL_NAME, OV_VISION_EMBEDDINGS_MODEL_NAME] for part in self.additional_parts: model = getattr(self, f"{part}_model", None) diff --git a/tests/openvino/test_modeling.py b/tests/openvino/test_modeling.py index 70891cf6d2..f2acf464db 100644 --- a/tests/openvino/test_modeling.py +++ b/tests/openvino/test_modeling.py @@ -2018,10 +2018,19 @@ def test_compare_to_transformers(self, model_arch): for additional_part in ov_model.additional_parts: self.assertTrue("CPU" in getattr(ov_model, additional_part)._device) self.assertTrue(getattr(ov_model, additional_part).request is not None) - # pytorch minicpmv and internvl are not designed to be used via forward - if model_arch not in ["minicpmv", "internvl2"]: - set_seed(SEED) - ov_outputs = ov_model(**inputs) + ov_model.clear_requests() + self.assertTrue("CPU" in ov_model._device) + self.assertTrue("CPU" in ov_model.vision_embeddings._device) + self.assertTrue(ov_model.vision_embeddings.request is None) + self.assertTrue("CPU" in ov_model.language_model._device) + self.assertTrue(ov_model.language_model.request is None) + self.assertTrue(ov_model.language_model.text_emb_request is None) + for additional_part in ov_model.additional_parts: + self.assertTrue("CPU" in getattr(ov_model, additional_part)._device) + self.assertTrue(getattr(ov_model, additional_part).request is None) + + # pytorch minicpmv is not designed to be used via forward + if model_arch in ["minicpmv", "internvl2"]: set_seed(SEED) with torch.no_grad(): transformers_outputs = transformers_model(**inputs)