Skip to content

Conversation

@ameyanjarlekar
Copy link
Contributor

@ameyanjarlekar ameyanjarlekar commented Mar 11, 2025

If num_patches evaluate to 1 for the input image prompt, the existing code does not generate any image token leading to the error "Unable to allocate 256 multimodal tokens to 0 placeholders". For images of particular dimensions eg. 220x229 or 200x229, I received this error.

The code currently breaks the input image prompt into multiple images by cropping certain parts of the image. It then appends all these cropped images plus a thumbnail image which is the resized version of the original image into a list. The number of elements in this list is dependent on the num_patches variable which is calculated based on the size of the original image.

If the num_patches variable is 1, then the code currently does not crop the image and also doesn't add the thumbnail image, therefore adding 0 image placeholders. Therefore, to consider the thumbnail image, which is the original image when num_patches==1 we need to remove the condition num_patches != 1.

To reproduce the bug you can try giving a prompt with this image (https://github.com/user-attachments/assets/7cd2df26-c765-43d8-bab2-9783d33c792f).

@github-actions
Copy link

👋 Hi! Thank you for contributing to the vLLM project.

💬 Join our developer Slack at https://slack.vllm.ai to discuss your PR in #pr-reviews, coordinate on features in #feat- channels, or join special interest groups in #sig- channels.

Just a reminder: PRs would not trigger full CI run by default. Instead, it would only run fastcheck CI which starts running only a small and essential subset of CI tests to quickly catch errors. You can run other CI tests on top of those by going to your fastcheck build on Buildkite UI (linked in the PR checks section) and unblock them. If you do not have permission to unblock, ping simon-mo or khluu to add you in our Buildkite org.

Once the PR is approved and ready to go, your PR reviewer(s) can run CI to test the changes comprehensively before merging.

To run CI, PR reviewers can either: Add ready label to the PR or enable auto-merge.

🚀

Copy link
Member

@DarkLight1337 DarkLight1337 left a comment

Choose a reason for hiding this comment

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

Thanks for fixing! @kylehh can you confirm this fix since I don't have the means to run this model locally right now.

@DarkLight1337 DarkLight1337 changed the title Fixing a bug in image-tokenization [Bugfix] Missing thumbnail from NVLM-D processor Mar 12, 2025
@DarkLight1337 DarkLight1337 added the ready ONLY add when PR is ready to merge/full CI is needed label Mar 12, 2025
@kylehh
Copy link
Contributor

kylehh commented Mar 12, 2025

I can reprod the issue w the shared image and the inference can run through w the bug fix. ( I didn't go through the whole logic of how num_patches works though )

@vllm-bot vllm-bot merged commit 4a754fc into vllm-project:main Mar 12, 2025
45 of 47 checks passed
@DarkLight1337
Copy link
Member

Merged

richardsliu pushed a commit to richardsliu/vllm that referenced this pull request Mar 14, 2025
lulmer pushed a commit to lulmer/vllm that referenced this pull request Apr 7, 2025
shreyankg pushed a commit to shreyankg/vllm that referenced this pull request May 3, 2025
RichardoMrMu pushed a commit to RichardoMrMu/vllm that referenced this pull request May 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready ONLY add when PR is ready to merge/full CI is needed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants