Skip to content
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

[V1] Refactor model executable interface for multimodal models #10570

Merged
merged 33 commits into from
Nov 26, 2024
Merged
Changes from 1 commit
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions vllm/model_executor/models/interfaces.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from typing import (TYPE_CHECKING, ClassVar, Dict, List, Literal, Optional,
Protocol, Tuple, Type, Union, overload, runtime_checkable)
Protocol, Type, TypeVar, Union, overload,
runtime_checkable)

import torch
from typing_extensions import TypeIs
Expand All @@ -11,11 +12,12 @@

if TYPE_CHECKING:
from vllm.attention import AttentionMetadata
from vllm.multimodal.inputs import NestedTensors
from vllm.sequence import IntermediateTensors

logger = init_logger(__name__)

T = TypeVar("T")
DarkLight1337 marked this conversation as resolved.
Show resolved Hide resolved


@runtime_checkable
class SupportsMultiModal(Protocol):
Expand All @@ -30,9 +32,7 @@ class SupportsMultiModal(Protocol):
MRO of your model class.
"""

def get_multimodal_embeddings(
self, **kwargs
) -> Optional[Union["NestedTensors", List[Tuple["NestedTensors", str]]]]:
def get_multimodal_embeddings(self, **kwargs) -> Optional[T]:
"""
Returns multimodal embeddings generated from multimodal kwargs
to be merged with text embeddings.
Expand All @@ -45,15 +45,15 @@ def get_multimodal_embeddings(
def get_input_embeddings(
self,
input_ids: torch.Tensor,
multimodal_embeddings: Optional["NestedTensors"] = None,
multimodal_embeddings: Optional[T] = None,
attn_metadata: Optional["AttentionMetadata"] = None,
) -> torch.Tensor:
...

def get_input_embeddings(
self,
input_ids: torch.Tensor,
multimodal_embeddings: Optional["NestedTensors"] = None,
multimodal_embeddings: Optional[T] = None,
) -> torch.Tensor:
"""
Returns the input embeddings merged from the text embeddings from
Expand Down