[Bugfix] Add embed_multimodal to MiniCPM-o 4.5 omni LLM class (#7384)
Signed-off-by: Guangjian <hiro20833@gmail.com>
This commit is contained in:
1 parent
dff8f8f4cf
commit
de9a133d48
2 files changed
+37
No files matched your search
@@ -0,0 +1,33 @@
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
|
||||
|
||||
import pytest
|
||||
|
||||
from vllm_omni.model_executor.models.minicpmo_4_5.minicpmo_4_5_omni_llm import (
|
||||
MiniCPMO45OmniLLMForConditionalGeneration,
|
||||
)
|
||||
|
||||
pytestmark = [pytest.mark.core_model, pytest.mark.cpu]
|
||||
|
||||
|
||||
def test_embed_multimodal_delegates_to_get_multimodal_embeddings(monkeypatch):
|
||||
"""vLLM V1 encoder profiling calls embed_multimodal; without an override the
|
||||
SupportsMultiModal protocol stub returns None and startup fails downstream."""
|
||||
sentinel = (object(),)
|
||||
seen: dict[str, object] = {}
|
||||
|
||||
def fake_get_multimodal_embeddings(self, **kwargs):
|
||||
seen.update(kwargs)
|
||||
return sentinel
|
||||
|
||||
monkeypatch.setattr(
|
||||
MiniCPMO45OmniLLMForConditionalGeneration,
|
||||
"get_multimodal_embeddings",
|
||||
fake_get_multimodal_embeddings,
|
||||
)
|
||||
model = object.__new__(MiniCPMO45OmniLLMForConditionalGeneration)
|
||||
|
||||
out = model.embed_multimodal(pixel_values="pv", audio_features="af")
|
||||
|
||||
assert out is sentinel
|
||||
assert seen == {"pixel_values": "pv", "audio_features": "af"}
|
||||
@@ -4580,6 +4580,10 @@ class MiniCPMO45OmniLLMForConditionalGeneration(nn.Module, SupportsMultiModal, S
|
||||
multimodal_embeddings += tuple(audio_embeddings)
|
||||
return multimodal_embeddings
|
||||
|
||||
def embed_multimodal(self, **kwargs: object) -> MultiModalEmbeddings:
|
||||
"""vLLM V1 encoder profiling calls this; the inherited Protocol stub returns None."""
|
||||
return self.get_multimodal_embeddings(**kwargs)
|
||||
|
||||
def get_input_embeddings(
|
||||
self,
|
||||
input_ids: torch.Tensor,
|
||||
|
||||
Reference in new issue
Block a user