Skip to content

[OpenVINO] Support jina-vlm with task image-text-to-text - #1909

Draft
popovaan wants to merge 3 commits into
huggingface:mainfrom
popovaan:model-support-jina-vlm-optimum_intel
Draft

[OpenVINO] Support jina-vlm with task image-text-to-text#1909
popovaan wants to merge 3 commits into
huggingface:mainfrom
popovaan:model-support-jina-vlm-optimum_intel

Conversation

@popovaan

@popovaan popovaan commented Aug 2, 2026

Copy link
Copy Markdown
Collaborator

Description

Added native OpenVINO export + inference support for model_type 'jvlm' (JinaVLMForConditionalGeneration) in optimum-intel. Registered a VLM export config with custom vision-embeddings, language, and text-embeddings behaviors plus OV-traceable patchers/dummy generators; added the _OVJinaVLMForCausalLM runtime class with index-based image-feature merge. optimum-cli export produces 5 IR submodels and OpenVINO greedy generation exactly matches HF token IDs on a real image+text prompt. Added a cached _create_tiny_jvlm_model() fixture and registered jvlm across test_export/test_seq2seq/test_exporters_cli/utils_tests; all targeted tests pass. Docs updated.

Conversion

optimum-cli export openvino --model jinaai/jina-vlm output_dir --task image-text-to-text --trust-remote-code

Reproduce generation

from PIL import Image
from transformers import AutoProcessor
from optimum.intel.openvino import OVModelForVisualCausalLM

model_dir = "output_dir"
processor = AutoProcessor.from_pretrained(model_dir, trust_remote_code=True)
model = OVModelForVisualCausalLM.from_pretrained(model_dir, device="CPU")
image = Image.new("RGB", (64, 64), "white")
inputs = processor(images=image, text="Describe this image.", return_tensors="pt")
output_ids = model.generate(**inputs, max_new_tokens=10)
print(processor.batch_decode(output_ids, skip_special_tokens=True)[0])

Validation

  • Validation model: Tiny model (/home/openvino_bot/.local/share/openvino-model-agent/requests/issue-40/repository/workspace/tiny_jina_vlm)
  • WWB similarity: 1.0

Final real-model validation

  • Estimated FP16 size: 4.62 GiB
  • Available RAM at validation: 122.60 GiB
  • 70% RAM limit: 85.82 GiB
  • Model: Real model (jinaai/jina-vlm)
  • WWB Optimum similarity: 1.0
  • WWB GenAI similarity: 0.95056

Related model-support PRs

Before submitting

  • Did you make sure to update the documentation with your changes?
  • Did you write any new necessary tests?

@HuggingFaceDocBuilderDev

Copy link
Copy Markdown

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

@Mohamed-Ashraf273

Copy link
Copy Markdown
Contributor

@popovaan can you please review this PR

@ma0358412

Copy link
Copy Markdown

@Mohamed-Ashraf273 Please summarize the validation performed in this PR. Do not modify any files.

@Mohamed-Ashraf273

Copy link
Copy Markdown
Contributor

👀 @ma0358412, I received this review request. A read-only response will be prepared first; source changes, if needed and permitted, will enter the sequential work queue.

@Mohamed-Ashraf273

Copy link
Copy Markdown
Contributor

❌ Review request 5165520245 failed: RuntimeError: Review agent exited with 1; see /home/mohamed-ashraf/.local/state/ov-agent/logs/review-5165520245.log.

Retry with ov-agent retry-comment 'huggingface/optimum-intel:issue_comment:5165520245'.

@ma0358412

Copy link
Copy Markdown

@Mohamed-Ashraf273 Please summarize the validation performed in this PR. Do not modify any files.

@Mohamed-Ashraf273

Copy link
Copy Markdown
Contributor

👀 @ma0358412, I received this review request. A read-only response will be prepared first; source changes, if needed and permitted, will enter the sequential work queue.

@Mohamed-Ashraf273

Copy link
Copy Markdown
Contributor

❌ Review request 5165596560 failed: RuntimeError: Review agent exited with 1; see /home/mohamed-ashraf/.local/state/ov-agent/logs/review-5165596560.log.

Retry with ov-agent retry-comment 'huggingface/optimum-intel:issue_comment:5165596560'.

@ma0358412

Copy link
Copy Markdown

@Mohamed-Ashraf273 Please summarize the validation performed in this PR. Do not modify any files.

@Mohamed-Ashraf273

Copy link
Copy Markdown
Contributor

👀 @ma0358412, review request received.

@Mohamed-Ashraf273

Copy link
Copy Markdown
Contributor

❌ Review request 5167833948 failed: RuntimeError: Review agent exited with 1; see /home/mohamed-ashraf/.local/state/ov-agent/logs/review-5167833948.log.

Retry with ov-agent retry-comment 'huggingface/optimum-intel:issue_comment:5167833948'.

@Mohamed-Ashraf273

Copy link
Copy Markdown
Contributor

@popovaan Please summarize the validation performed in this PR. Do not modify any files.

@popovaan

popovaan commented Aug 4, 2026

Copy link
Copy Markdown
Collaborator Author

👀 @Mohamed-Ashraf273, review request received.

@Mohamed-Ashraf273

Copy link
Copy Markdown
Contributor

👀 @popovaan, review request received.

@popovaan

popovaan commented Aug 4, 2026

Copy link
Copy Markdown
Collaborator Author

Validation summary

Based on the PR description and diff, the validation for jina-vlm (model_type='jvlm', task image-text-to-text) consists of:

Functional / export validation

  • optimum-cli export openvino produces 5 IR submodels for the model.
  • OpenVINO greedy generation exactly matches HF token IDs on a real image+text prompt.

Accuracy validation (WWB — who-what-benchmark similarity)

  • Tiny model (tiny_jina_vlm): WWB similarity 1.0.
  • Real model (jinaai/jina-vlm):
    • WWB Optimum similarity: 1.0
    • WWB GenAI similarity: 0.95056
  • Real-model resource context: estimated FP16 size 4.62 GiB; available RAM 122.60 GiB; 70% RAM limit 85.82 GiB (model fits within limit).

Automated tests (added/registered for jvlm)

  • tests/openvino/test_export.py — added to model mapping, GENERATIVE_MODELS, and remote-code / custom-gen-config handling.
  • tests/openvino/test_exporters_cli.py — added ("image-text-to-text", "jvlm") case and expected-submodel count.
  • tests/openvino/test_seq2seq.py — added jvlm to OVModelForVisualCausalLMIntegrationTest supported and remote-code lists.
  • tests/openvino/utils_tests.py — added cached _create_tiny_jvlm_model() fixture (synthesized locally from config + remote code, no original weights downloaded) plus expected submodel node counts (lm_model 18, text_embeddings_model 1, vision_embeddings_model 38).
  • The PR states all targeted tests pass.

Notes / caveats (not blocking, just observations)

No files were modified and no tests were run (read-only triage).

@popovaan

popovaan commented Aug 4, 2026

Copy link
Copy Markdown
Collaborator Author

👀 @Mohamed-Ashraf273, review request received.

@Mohamed-Ashraf273

Copy link
Copy Markdown
Contributor

❌ Review request 5180673544 failed: RuntimeError: Review agent exited with 1; see /home/mohamed-ashraf/.local/state/ov-agent/logs/review-5180673544.log.

Retry with ov-agent retry-comment 'huggingface/optimum-intel:issue_comment:5180673544'.

@popovaan

popovaan commented Aug 4, 2026

Copy link
Copy Markdown
Collaborator Author

Validation summary for PR #1909 (jina-vlm, model_type='jvlm', task image-text-to-text)

Based solely on the PR description and diff (read-only triage; no files modified, no tests run):

Functional / export

  • optimum-cli export openvino produces 5 IR submodels.
  • OpenVINO greedy generation exactly matches HF token IDs on a real image+text prompt.

Accuracy (WWB — who-what-benchmark similarity)

  • Tiny model (tiny_jina_vlm): 1.0
  • Real model (jinaai/jina-vlm):
    • WWB Optimum similarity: 1.0
    • WWB GenAI similarity: 0.95056
  • Resource context for the real-model run: estimated FP16 size 4.62 GiB, available RAM 122.60 GiB, 70% RAM limit 85.82 GiB (fits within limit).

Automated tests registered for jvlm (confirmed in diff)

  • tests/openvino/test_export.py: added to model mapping, GENERATIVE_MODELS, and remote-code / custom-gen-config handling.
  • tests/openvino/test_exporters_cli.py: added ("image-text-to-text", "jvlm") case with expected submodel count (2).
  • tests/openvino/test_seq2seq.py: added jvlm to OVModelForVisualCausalLMIntegrationTest supported and remote-code lists.
  • tests/openvino/utils_tests.py: added cached _create_tiny_jvlm_model() fixture (synthesized locally from config + remote code, no original weights downloaded) with expected submodel node counts (lm_model 18, text_embeddings_model 1, vision_embeddings_model 38).
  • PR states all targeted tests pass (self-reported; not re-executed here).

Observations (non-blocking)

@Mohamed-Ashraf273

Copy link
Copy Markdown
Contributor

@popovaan Please summarize the validation performed in this PR. Do not modify any files.

@popovaan

popovaan commented Aug 4, 2026

Copy link
Copy Markdown
Collaborator Author

👀 @Mohamed-Ashraf273, review request received.

@popovaan

popovaan commented Aug 4, 2026

Copy link
Copy Markdown
Collaborator Author

Validation summary — PR #1909 (jina-vlm, model_type='jvlm', task image-text-to-text)

Summarized from the PR description and diff only (read-only triage; no files modified, no tests run).

Functional / export validation

  • optimum-cli export openvino --model jinaai/jina-vlm --task image-text-to-text --trust-remote-code produces 5 IR submodels.
  • OpenVINO greedy generation exactly matches HF token IDs on a real image+text prompt.

Accuracy validation (WWB — who-what-benchmark similarity)

  • Tiny model (tiny_jina_vlm): WWB similarity 1.0.
  • Real model (jinaai/jina-vlm):
    • WWB Optimum similarity: 1.0
    • WWB GenAI similarity: 0.95056
  • Real-model resource context: estimated FP16 size 4.62 GiB; available RAM 122.60 GiB; 70% RAM limit 85.82 GiB (model fits within the limit).

Automated tests registered for jvlm (confirmed in the diff)

  • tests/openvino/test_export.py: added jvlm to the model-class mapping and to GENERATIVE_MODELS; extended remote-code and custom-gen-config handling (trust_remote_code=True on load/reload).
  • tests/openvino/test_exporters_cli.py: added the ("image-text-to-text", "jvlm") case with an expected submodel count of 2.
  • tests/openvino/test_seq2seq.py: added jvlm to OVModelForVisualCausalLMIntegrationTest supported and remote-code lists.
  • tests/openvino/utils_tests.py: added a cached _create_tiny_jvlm_model() fixture (synthesized locally from config + remote code, no original weights downloaded) and expected submodel node counts (lm_model 18, text_embeddings_model 1, vision_embeddings_model 38).
  • The PR states all targeted tests pass (self-reported).

Observations (non-blocking)

No files were modified and no commands were run.

@Mohamed-Ashraf273

Copy link
Copy Markdown
Contributor

@popovaan Please summarize the validation performed in this PR. Do not modify any files.

@popovaan

popovaan commented Aug 4, 2026

Copy link
Copy Markdown
Collaborator Author

👀 @Mohamed-Ashraf273, review request received.

@popovaan

popovaan commented Aug 4, 2026

Copy link
Copy Markdown
Collaborator Author

Validation summary — PR #1909 (jina-vlm, model_type='jvlm', task image-text-to-text)

Summarized from the PR description and diff only (read-only triage; no files modified, no commands run).

Functional / export validation

  • optimum-cli export openvino --model jinaai/jina-vlm --task image-text-to-text --trust-remote-code produces 5 IR submodels.
  • OpenVINO greedy generation exactly matches HF token IDs on a real image+text prompt.

Accuracy validation (WWB — who-what-benchmark similarity)

  • Tiny model (tiny_jina_vlm): WWB similarity 1.0.
  • Real model (jinaai/jina-vlm):
    • WWB Optimum similarity: 1.0
    • WWB GenAI similarity: 0.95056
  • Real-model resource context: estimated FP16 size 4.62 GiB; available RAM 122.60 GiB; 70% RAM limit 85.82 GiB (model fits within the limit).

Automated tests registered for jvlm (confirmed in the diff)

  • tests/openvino/test_export.py: added jvlm to the model-class mapping and to GENERATIVE_MODELS; extended remote-code / custom-gen-config handling (trust_remote_code=True on load and reload).
  • tests/openvino/test_exporters_cli.py: added the ("image-text-to-text", "jvlm") case with expected submodel count 2.
  • tests/openvino/test_seq2seq.py: added jvlm to OVModelForVisualCausalLMIntegrationTest supported and remote-code lists.
  • tests/openvino/utils_tests.py: added cached _create_tiny_jvlm_model() fixture (synthesized locally from config + remote code, no original weights downloaded) with expected submodel node counts — lm_model 18, text_embeddings_model 1, vision_embeddings_model 38; also registered jvlm in the remote-code and OVModelForVisualCausalLM class maps.
  • The PR states all targeted tests pass (self-reported).

Observations (non-blocking)

No files were modified and no commands were run.



def jina_vlm_vision_embed_forward(self, image_patches, image_masks=None):
# Runs the JinaVLM vision tower + vision-language connector and returns the flattened image

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@popovaan add a comment with the link to the original pytorch code of this method.

@popovaan

popovaan commented Aug 5, 2026

Copy link
Copy Markdown
Collaborator Author

👀 @Mohamed-Ashraf273, review request received.

@popovaan

popovaan commented Aug 5, 2026

Copy link
Copy Markdown
Collaborator Author

🛠️ This request needs source changes and has been added to the sequential modification queue.

@popovaan

popovaan commented Aug 5, 2026

Copy link
Copy Markdown
Collaborator Author

Addressed the review comment at optimum/exporters/openvino/model_patcher.py:3067. Added links to the original PyTorch remote code that jina_vlm_vision_embed_forward mirrors:

The links are pinned to the commit ddfa80b1 of jinaai/jina-vlm for stability. This is a comment-only change; python -m py_compile confirms the file still parses.

Pushed commit d6eb700344b0.

Tests:

  • python3 -m py_compile optimum/exporters/openvino/model_patcher.py: passed



def jina_vlm_language_model_forward(
self,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@popovaan add a comment with the link to the original pytorch code of this method.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👀 @Mohamed-Ashraf273, review request received.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This request needs source changes and has been added to the sequential modification queue.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed the review comment on jina_vlm_language_model_forward (optimum/exporters/openvino/model_patcher.py:3140). Added a link to the original PyTorch remote code that this method mirrors:

The link is pinned to commit ddfa80b1 of jinaai/jina-vlm for stability, matching the existing links already present on jina_vlm_vision_embed_forward (_encode_images L525, JinaVLMVisionModel.forward L223). The line number (L749) was verified by downloading modeling_jvlm.py at that pinned commit, not guessed. This is a comment-only change.

Validation:

  • python -m py_compile optimum/exporters/openvino/model_patcher.py: passed

Pushed commit b151e705813f.

Tests:

  • python -m py_compile optimum/exporters/openvino/model_patcher.py: passed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants