[OpenVINO] Support MiniCPM-V-4.6 with task image-text-to-text - #1906
[OpenVINO] Support MiniCPM-V-4.6 with task image-text-to-text#1906popovaan wants to merge 2 commits into
Conversation
|
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. |
| block.attn.forward = block.attn._orig_forward | ||
|
|
||
|
|
||
| def _minicpmv4_6_vision_attention(attn, hidden_states, attention_mask): |
There was a problem hiding this comment.
@popovaan add a comment with the link to the original pytorch code of this method.
| block.attn.forward = block.attn._orig_forward | ||
|
|
||
|
|
||
| def _minicpmv4_6_vision_attention(attn, hidden_states, attention_mask): |
There was a problem hiding this comment.
@popovaan add a comment with the link to the original pytorch code of this method.
|
👀 @Mohamed-Ashraf273, review request received. |
|
🛠️ This request needs source changes and has been added to the sequential modification queue. |
|
Addressed @popovaan's request to add a comment linking to the original PyTorch code. Since no inline anchor was provided for "this method", I added upstream-source reference comments to every method in the PR that reimplements original MiniCPM-V-4.6 PyTorch logic:
Links point to Pushed commit Tests:
|
Description
Fixed the MiniCPM-V-4.6 (minicpmv4_6) end-to-end HF-vs-OpenVINO greedy divergence that the prior session mis-attributed to an unfixable qwen3_5 OV-conversion decode defect. Root cause was a Python-side patcher bug (reproducible in pure PyTorch, not OpenVINO): Qwen3_5DynamicCacheWrap.get_mask_sizes returned kv_offset=past_length instead of 0, so transformers>=5.6 create_causal_mask shifted the full-attention key positions past the query and masked every cached token during decode (mask [0,-inf,-inf,...]); prefill matched, first decode token onward diverged. Per-layer hooks isolated it to the single full-attention layer (linear layers exact ~1e-6). Fix: kv_offset=0 (canonical DynamicLayer contract). Also fixed a test bug: minicpmv4_6 was missing from test_seq2seq get_transformer_model_class AutoModelForImageTextToText branch, causing an AutoModelForCausalLM load error before inference. After fixes, patched-eager and OV decode match HF exactly, CLI export exit 0, real image-text generate() produces diverse tokens, and all targeted repo tests pass.
Conversion
optimum-cli export openvino --model openbmb/MiniCPM-V-4.6 output_dir --task image-text-to-text --trust-remote-codeReproduce generation
Validation
/home/openvino_bot/.local/share/openvino-model-agent/requests/issue-36/repository/workspace/tiny-minicpmv4_6)Related model-support PRs
Before submitting