Repair MiniCPM-o and InternVLA scoped E2E paths
This commit is contained in:
1 parent
2d8b1d4583
commit
c0deaa76ba
36 files changed
+3498
-83
No files matched your search
@@ -0,0 +1,43 @@
|
||||
"""Regression for text requests sharing the Omni preprocess embedding buffer."""
|
||||
|
||||
from types import SimpleNamespace
|
||||
|
||||
import torch
|
||||
|
||||
from vllm_omni.model_executor.models.minicpmo_4_5.minicpmo_4_5_omni import (
|
||||
MiniCPMO45OmniForConditionalGeneration,
|
||||
)
|
||||
|
||||
|
||||
def test_text_preprocess_replaces_uninitialized_embedding_buffer() -> None:
|
||||
ids = torch.tensor([4, 7])
|
||||
scratch = torch.zeros((2, 3))
|
||||
expected = torch.tensor([[4.0, 4.0, 4.0], [7.0, 7.0, 7.0]])
|
||||
model = SimpleNamespace(model_stage="llm", get_input_embeddings=lambda input_ids: input_ids[:, None].expand(-1, 3).float())
|
||||
|
||||
_, embeds, _ = MiniCPMO45OmniForConditionalGeneration.preprocess(
|
||||
model,
|
||||
ids,
|
||||
input_embeds=scratch,
|
||||
_omni_input_embeds_precomputed=False,
|
||||
)
|
||||
|
||||
torch.testing.assert_close(embeds, expected)
|
||||
|
||||
|
||||
def test_text_preprocess_preserves_precomputed_multimodal_embeddings() -> None:
|
||||
ids = torch.tensor([4, 7])
|
||||
prepared = torch.tensor([[1.0, 2.0, 3.0], [4.0, 5.0, 6.0]])
|
||||
model = SimpleNamespace(
|
||||
model_stage="llm",
|
||||
get_input_embeddings=lambda _input_ids: (_ for _ in ()).throw(AssertionError("must reuse embeddings")),
|
||||
)
|
||||
|
||||
_, embeds, _ = MiniCPMO45OmniForConditionalGeneration.preprocess(
|
||||
model,
|
||||
ids,
|
||||
input_embeds=prepared,
|
||||
_omni_input_embeds_precomputed=True,
|
||||
)
|
||||
|
||||
assert embeds is prepared
|
||||
@@ -1756,6 +1756,7 @@ class TestPreferModelSamplerNoneFallback:
|
||||
runner._sampling_metadata_for_model_sampler = lambda smd: smd
|
||||
runner._resolve_duplex_sampling_hook = lambda: None
|
||||
runner.sampler = lambda logits, sampling_metadata: default_result
|
||||
runner.device = torch.device("cpu")
|
||||
return runner
|
||||
|
||||
def test_none_falls_back_to_default_sampler_and_warns_once(self):
|
||||
@@ -1801,6 +1802,27 @@ class TestPreferModelSamplerNoneFallback:
|
||||
|
||||
assert out is model_out
|
||||
|
||||
def test_declining_model_cannot_mutate_default_sampler_logits(self):
|
||||
runner = self._runner(model_sample_result=None, default_result=None)
|
||||
original = torch.tensor([[0.1, 0.2, 0.3]])
|
||||
seen = []
|
||||
|
||||
def decline_after_mutation(logits, _metadata):
|
||||
logits[:, :] = float("-inf")
|
||||
logits[:, 0] = 0.0
|
||||
return None
|
||||
|
||||
def default_sampler(*, logits, sampling_metadata):
|
||||
seen.append(logits.clone())
|
||||
return torch.argmax(logits, dim=-1).item()
|
||||
|
||||
runner.model.sample = decline_after_mutation
|
||||
runner.sampler = default_sampler
|
||||
runner.device = torch.device("cpu")
|
||||
|
||||
assert GPUARModelRunner._sample(runner, original, None) == 2
|
||||
torch.testing.assert_close(seen[0], original)
|
||||
|
||||
def test_declaration_matcher_ignores_mentions_and_opt_outs(self):
|
||||
# Guards the guard: the inventory below is only meaningful if
|
||||
# "declares" means an actual opt-in assignment.
|
||||
@@ -1838,6 +1860,7 @@ class TestPreferModelSamplerNoneFallback:
|
||||
"minicpmo_4_5",
|
||||
"minimax_music3",
|
||||
"nemotron_voicechat",
|
||||
"qwen3_tts",
|
||||
}
|
||||
assert declarers == expected, (
|
||||
"The set of models declaring `prefer_model_sampler` changed:\n"
|
||||
|
||||
Reference in new issue
Block a user