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
@@ -35,6 +35,7 @@ from vllm_omni.diffusion.models.internvla_a1 import ( # noqa: E402
|
||||
from vllm_omni.diffusion.models.internvla_a1.config import OBS_STATE # noqa: E402
|
||||
from vllm_omni.diffusion.registry import initialize_model # noqa: E402
|
||||
from vllm_omni.diffusion.request import OmniDiffusionRequest # noqa: E402
|
||||
from vllm_omni.diffusion.worker.request_batch import DiffusionRequestBatch # noqa: E402
|
||||
from vllm_omni.inputs.data import OmniDiffusionSamplingParams # noqa: E402
|
||||
|
||||
|
||||
@@ -158,23 +159,29 @@ def run_pipeline_forward(
|
||||
request_id: str,
|
||||
) -> torch.Tensor:
|
||||
output = pipeline.forward(
|
||||
OmniDiffusionRequest(
|
||||
prompts=[""],
|
||||
sampling_params=OmniDiffusionSamplingParams(
|
||||
extra_args={
|
||||
"batch_inputs": batch_inputs,
|
||||
"noise": noise,
|
||||
"decode_image": False,
|
||||
}
|
||||
),
|
||||
request_id=request_id,
|
||||
DiffusionRequestBatch(
|
||||
requests=[
|
||||
OmniDiffusionRequest(
|
||||
prompt="",
|
||||
sampling_params=OmniDiffusionSamplingParams(
|
||||
extra_args={
|
||||
"batch_inputs": batch_inputs,
|
||||
"noise": noise,
|
||||
"decode_image": False,
|
||||
}
|
||||
),
|
||||
request_id=request_id,
|
||||
)
|
||||
]
|
||||
)
|
||||
)
|
||||
if output.error:
|
||||
raise RuntimeError(output.error)
|
||||
if output.output is None:
|
||||
raise RuntimeError("InternVLAA1Pipeline.forward returned no output tensor.")
|
||||
return output.output
|
||||
payload = output.output
|
||||
actions = payload.get("payload", {}).get("actions") if isinstance(payload, dict) else None
|
||||
if not isinstance(actions, torch.Tensor):
|
||||
raise RuntimeError("InternVLAA1Pipeline.forward returned no action tensor in output.payload.actions.")
|
||||
return actions
|
||||
|
||||
|
||||
def _synchronize(device: str) -> None:
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
|
||||
"""
|
||||
Offline end-to-end inference for MiniCPM-o 4.5 (thinker + talker/Token2Wav).
|
||||
Offline end-to-end inference for MiniCPM-o 4.5 (thinker + talker + Code2Wav).
|
||||
|
||||
MiniCPM-o uses placeholders ``(<image>./</image>)``, ``(<audio>./</audio>)``,
|
||||
and ``(<video>./</video>)``. Speech output requires a ``<|tts_bos|>`` suffix on
|
||||
@@ -16,7 +16,6 @@ import numpy as np
|
||||
import soundfile as sf
|
||||
import vllm
|
||||
from PIL import Image
|
||||
from vllm import SamplingParams
|
||||
from vllm.assets.audio import AudioAsset
|
||||
from vllm.assets.image import ImageAsset
|
||||
from vllm.assets.video import VideoAsset, video_to_ndarrays
|
||||
@@ -26,8 +25,6 @@ from vllm.multimodal.media.audio import load_audio
|
||||
from vllm_omni.entrypoints.omni import Omni
|
||||
from vllm_omni.utils.tracking_parser import TrackingArgumentParser
|
||||
|
||||
SEED = 42
|
||||
|
||||
default_system = (
|
||||
"You are MiniCPM-o, a helpful multimodal assistant that can "
|
||||
"understand images, audio and video, and respond in text and speech."
|
||||
@@ -40,8 +37,8 @@ class QueryResult(NamedTuple):
|
||||
|
||||
|
||||
def _assistant_prefix(use_tts: bool) -> str:
|
||||
# Matches HF chat_template: assistant header, optional empty <think>, then TTS bos.
|
||||
prefix = "<|im_start|>assistant\n"
|
||||
# Match the checkpoint chat template with enable_thinking=False.
|
||||
prefix = "<|im_start|>assistant\n<think>\n\n</think>\n\n"
|
||||
if use_tts:
|
||||
prefix += "<|tts_bos|>"
|
||||
return prefix
|
||||
@@ -285,27 +282,10 @@ def main(args):
|
||||
omni_kwargs["trust_remote_code"] = True
|
||||
omni = Omni(**omni_kwargs)
|
||||
|
||||
# Stage 0 (thinker): multimodal understanding → text (+ TTS span when enabled).
|
||||
thinker_sampling_params = SamplingParams(
|
||||
temperature=0.0,
|
||||
top_p=1.0,
|
||||
top_k=-1,
|
||||
max_tokens=2048,
|
||||
seed=SEED,
|
||||
detokenize=True,
|
||||
repetition_penalty=1.1,
|
||||
)
|
||||
# Stage 1 (talker + Token2Wav): max_tokens=1 satisfies the scheduler;
|
||||
# waveform is produced in-process by Token2Wav.
|
||||
talker_sampling_params = SamplingParams(
|
||||
temperature=0.0,
|
||||
top_p=1.0,
|
||||
top_k=-1,
|
||||
max_tokens=1,
|
||||
seed=SEED,
|
||||
detokenize=False,
|
||||
)
|
||||
sampling_params_list = [thinker_sampling_params, talker_sampling_params][: omni.num_stages]
|
||||
# The deploy config owns all three stages' sampling parameters. In
|
||||
# particular, the Talker requires min_tokens and the Code2Wav stage has
|
||||
# its own output limit; a two-entry list cannot describe this pipeline.
|
||||
sampling_params_list = None
|
||||
|
||||
if args.txt_prompts is None:
|
||||
prompts = [query_result.inputs for _ in range(args.num_prompts)]
|
||||
@@ -345,6 +325,8 @@ def main(args):
|
||||
str(output.prompt) + "\n",
|
||||
"vllm_text_output:\n",
|
||||
str(text_output).strip() + "\n",
|
||||
"vllm_token_ids:\n",
|
||||
str(output.outputs[0].token_ids) + "\n",
|
||||
]
|
||||
try:
|
||||
with open(out_txt, "w", encoding="utf-8") as f:
|
||||
|
||||
Reference in new issue
Block a user