Skip to content

Commit

Permalink
add test case
Browse files Browse the repository at this point in the history
  • Loading branch information
eaidova committed Dec 4, 2024
1 parent 973f155 commit 7af7cdc
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
4 changes: 4 additions & 0 deletions optimum/intel/openvino/modeling_visual_language.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,10 @@ def prepare_inputs(
if past_len:
position_ids = position_ids[:, -inputs_embeds.shape[1] :]

if self.config.model_type == "qwen2_vl" and position_ids.ndim != 3:
position_ids = np.expand_dims(position_ids, 0)
position_ids = np.concatenate([position_ids, position_ids, position_ids], axis=0)

inputs["position_ids"] = position_ids

if "beam_idx" in self.input_names:
Expand Down
6 changes: 5 additions & 1 deletion tests/openvino/test_modeling.py
Original file line number Diff line number Diff line change
Expand Up @@ -1976,7 +1976,7 @@ class OVModelForVisualCausalLMIntegrationTest(unittest.TestCase):
if is_transformers_version(">=", "4.40.0"):
SUPPORTED_ARCHITECTURES += ["llava_next", "nanollava"]
if is_transformers_version(">=", "4.45.0"):
SUPPORTED_ARCHITECTURES += ["minicpmv", "internvl2", "phi3_v"]
SUPPORTED_ARCHITECTURES += ["minicpmv", "internvl2", "phi3_v", "qwen2_vl"]
TASK = "image-text-to-text"
REMOTE_CODE_MODELS = ["internvl2", "minicpmv", "nanollava", "phi3_v"]

Expand All @@ -1996,6 +1996,10 @@ def get_transformer_model_class(self, model_arch):
from transformers import LlavaNextForConditionalGeneration

return LlavaNextForConditionalGeneration
if model_arch == "qwen2_vl":
from transformers import Qwen2VLForConditionalGeneration

return Qwen2VLForConditionalGeneration
return AutoModelForCausalLM

def _check_device_and_request(self, ov_model, expected_device, has_request):
Expand Down
1 change: 1 addition & 0 deletions tests/openvino/utils_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@
"qwen": "katuni4ka/tiny-random-qwen",
"qwen2": "fxmarty/tiny-dummy-qwen2",
"qwen2-moe": "katuni4ka/tiny-random-qwen1.5-moe",
"qwen2_vl": "katuni4ka/tiny-random-qwen2vl",
"resnet": "hf-internal-testing/tiny-random-resnet",
"roberta": "hf-internal-testing/tiny-random-roberta",
"roformer": "hf-internal-testing/tiny-random-roformer",
Expand Down

0 comments on commit 7af7cdc

Please sign in to comment.