Skip to content

[Model] Fix a check for None but the return value was empty list in Gemma3 MM vision_embeddings #21479

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 25, 2025

Conversation

hfan
Copy link
Contributor

@hfan hfan commented Jul 23, 2025

Purpose

No functional change.

It is best practice to check properly for empty list if the value can be an empty list.

Also in tpu_commons when we try to trace the graph without MM inputs, this check fails and causes the graph for text-only input still tries to trace the MM code path.

Test Plan

Existing CI should still pass

Test Result

Signed-off-by: Hongmin Fan <fanhongmin@google.com>
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
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

The code change adds a check for an empty list of vision embeddings before calling prepare_attn_masks. This prevents a potential error and improves the robustness of the code. The change is approved.

@@ -627,7 +627,7 @@ def forward(self,

inputs_embeds = self.get_input_embeddings(input_ids,
vision_embeddings)
if vision_embeddings is not None:
if (vision_embeddings is not None) and len(vision_embeddings) != 0:
Copy link
Contributor

Choose a reason for hiding this comment

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

high

Checking the length of vision_embeddings prevents a potential error when prepare_attn_masks is called with an empty list. This condition ensures that attention masks are only prepared when there are actual vision embeddings to process, improving code robustness.

if vision_embeddings and len(vision_embeddings) != 0:

@yaochengji yaochengji added the ready ONLY add when PR is ready to merge/full CI is needed label Jul 23, 2025
@hfan hfan changed the title Fix a check for None but the return value was empty list in Gemma3 MM. [Model] Fix a check for None but the return value was empty list in Gemma3 MM vision_embeddings Jul 23, 2025
@DarkLight1337 DarkLight1337 merged commit fde60ee into vllm-project:main Jul 25, 2025
82 of 84 checks passed
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.

3 participants