Skip to content

[Docs] Enhance SupportsMultiModal interface documentation #19701

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

russellb
Copy link
Member

  • Add comprehensive class-level documentation explaining interface purpose and V1 integration
  • Document supports_multimodal flag usage in inference engine (caching, scheduling, LoRA)
  • Enhance get_multimodal_embeddings() with implementation patterns and V1 usage contexts
  • Improve get_language_model() docs with architecture examples and V1 use cases
  • Expand get_input_embeddings() documentation with merge utility guidance and V1 integration

Signed-off-by: Russell Bryant rbryant@redhat.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.

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 focuses entirely on improving the documentation for the SupportsMultiModal interface and its associated methods within vllm/model_executor/models/interfaces.py. The goal is to provide clearer guidance for developers implementing multimodal models in vLLM, detailing the purpose, implementation patterns, and system-level interactions of these critical components.

Highlights

  • Enhanced SupportsMultiModal Interface Documentation: I've added comprehensive class-level documentation to the SupportsMultiModal protocol, explaining its purpose, integration with vLLM's V1 model runners, and recommended implementation patterns for multimodal models.
  • supports_multimodal Flag Usage Clarification: The documentation for the supports_multimodal flag has been enhanced to clearly outline its role in vLLM's inference engine, specifically for encoder cache allocation, multimodal-specific scheduling, LoRA compatibility warnings, and speculative decoding setup.
  • Detailed get_multimodal_embeddings() Documentation: I've significantly improved the docstring for get_multimodal_embeddings(), detailing its core function in processing multimodal inputs, providing common implementation patterns, and specifying its usage contexts within V1 GPU/TPU model runners, encoder cache management, and profiling.
  • Expanded get_language_model() Documentation: The documentation for get_language_model() now offers a more in-depth explanation of its purpose, common implementation examples across different model architectures (e.g., self.language_model, self.model.decoder), and its critical uses in EAGLE speculative decoding, TPU compilation, and LoRA integration.
  • Comprehensive get_input_embeddings() Documentation: I've updated the get_input_embeddings() docstring to thoroughly explain its role in converting input tokens to embeddings and merging them with multimodal embeddings. It now includes a standard implementation pattern, clarifies argument/return types, and highlights its usage in V1 model runners and TPU compilation, along with important notes on embedding ordering and the use of merge_multimodal_embeddings().
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

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

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

This pull request enhances the documentation for the SupportsMultiModal interface, detailing its purpose, usage, and implementation patterns for its methods. The changes improve clarity for developers. A suggestion regarding the return type hint for get_multimodal_embeddings has been noted for future consideration.

- Add comprehensive class-level documentation explaining interface purpose and V1 integration
- Document supports_multimodal flag usage in inference engine (caching, scheduling, LoRA)
- Enhance get_multimodal_embeddings() with implementation patterns and V1 usage contexts
- Improve get_language_model() docs with architecture examples and V1 use cases
- Expand get_input_embeddings() documentation with merge utility guidance and V1 integration

Signed-off-by: Russell Bryant <rbryant@redhat.com>
@russellb russellb force-pushed the supportsmultimodal-api-docs branch from 11ffae3 to 579eb2c Compare June 16, 2025 17:51
@russellb russellb requested a review from Copilot June 16, 2025 17:52
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR enhances the SupportsMultiModal interface documentation by detailing its purpose, usage patterns, and integration points with vLLM V1.

  • Expanded class-level doc to define workflow, usage, and implementation steps
  • Documented supports_multimodal flag usage in caching, scheduling, and LoRA
  • Enriched method-level docs (get_multimodal_embeddings, get_language_model, get_input_embeddings) with usage contexts and example patterns
Comments suppressed due to low confidence (3)

vllm/model_executor/models/interfaces.py:49

  • The Implementation Pattern section is inline and lacks code block formatting. Consider using proper code block markup or Sphinx directives (e.g., .. code-block:: python) to improve readability in generated documentation.
    1. Inherit from SupportsMultiModal in your model class

vllm/model_executor/models/interfaces.py:81

  • [nitpick] The use of **kwargs for get_multimodal_embeddings makes the API ambiguous. Consider defining explicit parameters or a structured input type for supported modalities to enhance type safety and clarity.
Common Implementation Pattern:

vllm/model_executor/models/interfaces.py:62

  • Newly documented behavior around LoRA compatibility warnings for multimodal models should be covered by tests. Add unit or integration tests to verify that warnings are emitted correctly when LoRA is applied.
    - LoRA compatibility warnings

Implementation Pattern:
1. Inherit from SupportsMultiModal in your model class
2. Implement all three required methods
3. Use utilities like merge_multimodal_embeddings() for embedding
Copy link
Member

Choose a reason for hiding this comment

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

Can we use cross-references so they link to the corresponding location in API docs?

Copy link
Member Author

Choose a reason for hiding this comment

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

Good suggestion. I'll look into how to do that properly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants