[Bugfix][Model Runner V2] Restore multimodal draft capability detection (#50417)
Signed-off-by: Raphael Rialland <raphael.rialland@mistral.ai>
This commit is contained in:
@@ -110,7 +110,22 @@ _language_model_by_module = dict[nn.Module, "VllmModel"]()
|
||||
|
||||
|
||||
@runtime_checkable
|
||||
class SupportsMultiModal(Protocol):
|
||||
class SupportsMultiModalEmbeddings(Protocol):
|
||||
"""The interface for models that can merge external multimodal embeddings."""
|
||||
|
||||
supports_multimodal_embeddings: ClassVar[Literal[True]] = True
|
||||
|
||||
def embed_input_ids(
|
||||
self,
|
||||
input_ids: Tensor,
|
||||
multimodal_embeddings: MultiModalEmbeddings | None = None,
|
||||
*,
|
||||
is_multimodal: Tensor | None = None,
|
||||
) -> Tensor: ...
|
||||
|
||||
|
||||
@runtime_checkable
|
||||
class SupportsMultiModal(SupportsMultiModalEmbeddings, Protocol):
|
||||
"""The interface required for all multi-modal models."""
|
||||
|
||||
supports_multimodal: ClassVar[Literal[True]] = True
|
||||
@@ -488,6 +503,24 @@ def supports_multimodal(
|
||||
return getattr(model, "supports_multimodal", False)
|
||||
|
||||
|
||||
@overload
|
||||
def supports_multimodal_embeddings(
|
||||
model: type[object],
|
||||
) -> TypeIs[type[SupportsMultiModalEmbeddings]]: ...
|
||||
|
||||
|
||||
@overload
|
||||
def supports_multimodal_embeddings(
|
||||
model: object,
|
||||
) -> TypeIs[SupportsMultiModalEmbeddings]: ...
|
||||
|
||||
|
||||
def supports_multimodal_embeddings(
|
||||
model: type[object] | object,
|
||||
) -> TypeIs[type[SupportsMultiModalEmbeddings]] | TypeIs[SupportsMultiModalEmbeddings]:
|
||||
return getattr(model, "supports_multimodal_embeddings", False)
|
||||
|
||||
|
||||
def supports_multimodal_raw_input_only(model: type[object] | object) -> bool:
|
||||
return getattr(model, "supports_multimodal_raw_input_only", False)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user