[V1] Change return type on get_multimodal_embeddings()#19446
[V1] Change return type on get_multimodal_embeddings()#19446russellb merged 1 commit intovllm-project:mainfrom
Conversation
|
👋 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 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 🚀 |
There was a problem hiding this comment.
Summary of Changes
Hello @russellb, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!
This pull request addresses type hint inaccuracies related to multimodal embeddings. The get_multimodal_embeddings method was incorrectly marked as potentially returning None, while downstream code expected a MultiModalEmbeddings object. This change updates the type hints to accurately reflect the code's behavior and improves type safety.
Highlights
- Type Hint Correction: Corrected the return type hint for the
get_multimodal_embeddingsmethod across various model implementations and theSupportsMultiModalinterface fromOptional[MultiModalEmbeddings]toMultiModalEmbeddings. - Sanity Check Type Update: Updated the type hint for the
mm_embeddingsparameter in thesanity_check_mm_encoder_outputsfunction toMultiModalEmbeddings, aligning it with the expected input type.
Using Gemini Code Assist
The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.
Invoking Gemini
You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.
| Feature | Command | Description |
|---|---|---|
| Code Review | /gemini review |
Performs a code review for the current pull request in its current state. |
| Pull Request Summary | /gemini summary |
Provides a summary of the current pull request in its current state. |
| Comment | @gemini-code-assist | Responds in comments when explicitly tagged, both in issue comments and review comments. |
| Help | /gemini help |
Displays a list of available commands. |
Customization
To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.
Limitations & Feedback
Gemini Code Assist is currently in preview and may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments to provide feedback.
You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.
Footnotes
-
Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configureGemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩
There was a problem hiding this comment.
Code Review
This pull request correctly identifies and addresses an inconsistency in the return type of get_multimodal_embeddings. By removing Optional from the return type and updating the sanity_check_mm_encoder_outputs function to expect MultiModalEmbeddings, the type hints become more precise and align better with the actual usage.
The primary feedback is to ensure that all implementations of get_multimodal_embeddings that previously returned None are updated to return an empty list ([]) to conform to the new non-optional type hint, as implied by the PR description. This will prevent potential type errors and ensure consistency across all multimodal models.
There was a problem hiding this comment.
Thanks for fixing! The code change makes sense to me. cc @DarkLight1337 if you want to take a look too.
|
It looks like this broke some multi-modal tests. I'll take a look. |
The return type implied that `None` was a valid return value, but the code does not treat it that way. `sanity_check_mm_encoder_outputs()` in `vllm.v1.worker.utils` is called on the output and does not allow None. While we're at it, also change the input parameter type to the sanity check function. Previously, it was specified as `object`, but it should be `MultiModalEmbeddings`. Implementations of the method can still return an empty list if necessary. Signed-off-by: Russell Bryant <rbryant@redhat.com>
36c2c10 to
f13bf8f
Compare
|
@russellb, this commit is breaking tests like None.
|
I guess these tests aren't running in CI always since CI was green here? Sorry for the trouble. |
|
I'm working on fixes. |
This is a follow up to PR vllm-project#19446. In that PR, get_multimodal_embeddings() was changed to return `MultiModalEmbeddings` instead of `Optional[MultiModalEmbeddings]` because code in the model runner was requiring that the result was not `None`. Several models needed tweaks to account for this. Many were missed because they were not tested in CI. This should fix the rest of the common changes needed that weren't caught by CI. Signed-off-by: Russell Bryant <rbryant@redhat.com>
|
follow up here: #19715 |
This is a follow up to PR vllm-project#19446. In that PR, get_multimodal_embeddings() was changed to return `MultiModalEmbeddings` instead of `Optional[MultiModalEmbeddings]` because code in the model runner was requiring that the result was not `None`. Several models needed tweaks to account for this. Many were missed because they were not tested in CI. This should fix the rest of the common changes needed that weren't caught by CI. Signed-off-by: Russell Bryant <rbryant@redhat.com>
The return type implied that
Nonewas a valid return value, but thecode does not treat it that way.
sanity_check_mm_encoder_outputs()invllm.v1.worker.utilsis called on the output and does not allow None.While we're at it, also change the input parameter type to the sanity
check function. Previously, it was specified as
object, but it shouldbe
MultiModalEmbeddings.Implementations of the method can still return an empty list if
necessary.
Signed-off-by: Russell Bryant rbryant@redhat.com