minicpmv4_6: fix ImageSize (W,H) order for placeholder token calculation#45244
Merged
DarkLight1337 merged 2 commits intoJun 11, 2026
Merged
Conversation
Assisted-by: Claude Signed-off-by: tc-mb <tianchi_cai@icloud.com>
Contributor
Author
|
@DarkLight1337 This is a minor fix, and it might be easy to merge in. Could you please take a look? |
DarkLight1337
approved these changes
Jun 11, 2026
Saddss
pushed a commit
to Saddss/vllm
that referenced
this pull request
Jun 14, 2026
…ion (vllm-project#45244) Signed-off-by: tc-mb <tianchi_cai@icloud.com>
divineearthly
pushed a commit
to divineearthly/vllm
that referenced
this pull request
Jun 19, 2026
…ion (vllm-project#45244) Signed-off-by: tc-mb <tianchi_cai@icloud.com> Signed-off-by: divineearthly <divineearthly@gmail.com>
tunglinwood
pushed a commit
to tunglinwood/vllm
that referenced
this pull request
Jun 22, 2026
…ion (vllm-project#45244) Signed-off-by: tc-mb <tianchi_cai@icloud.com>
nkzhenhua
pushed a commit
to nkzhenhua/vllm
that referenced
this pull request
Jun 24, 2026
…ion (vllm-project#45244) Signed-off-by: tc-mb <tianchi_cai@icloud.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fix a bug where
_compute_visual_tokenspassesImageSize(width, height)directly to transformers image processor methods (
get_sliced_grid,find_best_resize,get_refine_size) that expect(height, width)order.For certain aspect ratios (e.g. 365x211) this causes the text-side
placeholder count to mismatch the actual vision embedding count, triggering
a ValueError crash.
minicpmv4_6.py: convertImageSizeto(H, W)tuple before callingHF image processor methods
minicpmv.py: remove deadversion == (4, 6)branches that are fullyoverridden by
MiniCPMV4_6ProcessingInfoWhy this was not caught earlier
The actual pixel processing goes through
image_processor._preprocess,which reads image size directly from tensor shape
(H, W)— always correct.The placeholder text side goes through
_compute_visual_tokens, whichpasses vLLM's
ImageSize(W, H)to the same HF methods. Both sides call thesame
find_best_resizebut with different input order.For most common sizes (e.g. 1280x720, 448x448),
ensure_divideroundinghappens to produce the same result regardless of W/H ordering, making the
bug invisible. Only extreme aspect ratios like 365x211 (1.73:1) or
153x174 (0.88:1) cause the rounding to diverge, surfacing the mismatch.
Test plan
Manually verified token count for edge-case sizes before/after fix: