Signed-off-by: chickeyton <ngton2014@gmail.com> Signed-off-by: Yueqian Lin <linyueqian@outlook.com> Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com> Co-authored-by: Yueqian Lin <linyueqian@outlook.com>
This commit is contained in:
49 files changed
+3056
-1715
No files matched your search
@@ -12,7 +12,7 @@ from vllm.logger import init_logger
|
||||
from vllm_omni.engine.duplex.contracts import (
|
||||
duplex_resource_request_belongs_to_session,
|
||||
)
|
||||
from vllm_omni.engine.duplex.plugin import DuplexDataPlane
|
||||
from vllm_omni.engine.duplex.plugin import DuplexDataPlane, DuplexDataPlaneContext
|
||||
from vllm_omni.outputs.duplex import get_duplex_output_decision
|
||||
|
||||
logger = init_logger(__name__)
|
||||
@@ -21,17 +21,8 @@ EncodeAudio = Callable[[object, int, str, float | None], str | None]
|
||||
|
||||
|
||||
@dataclass(frozen=True, slots=True)
|
||||
class MiniCPMO45DataPlaneContext:
|
||||
"""Serving state needed to project one MiniCPM data-plane output."""
|
||||
|
||||
epoch: int = 0
|
||||
turn_id: int = 0
|
||||
active_response_turn_id: int | None = None
|
||||
active_response_id: str | None = None
|
||||
auto_responds: bool = False
|
||||
response_format: str = "wav"
|
||||
speed: float | None = None
|
||||
modalities: tuple[str, ...] = ()
|
||||
class MiniCPMO45DataPlaneContext(DuplexDataPlaneContext):
|
||||
"""Serving state needed to project one MiniCPM data-plane output (the framework fields)."""
|
||||
|
||||
|
||||
@dataclass(slots=True)
|
||||
|
||||
@@ -18,7 +18,7 @@ from base64 import b64decode
|
||||
from binascii import Error as BinasciiError
|
||||
from collections.abc import Mapping
|
||||
from copy import deepcopy
|
||||
from typing import TYPE_CHECKING, Any, cast
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
import numpy as np
|
||||
from numpy.typing import NDArray
|
||||
@@ -40,6 +40,11 @@ from vllm_omni.engine.duplex.plugin import (
|
||||
reject_changed_runtime_value,
|
||||
reject_private_runtime_keys,
|
||||
)
|
||||
from vllm_omni.model_executor.common.duplex.payload import payload_sample_count as _duplex_pcm_sample_count
|
||||
from vllm_omni.model_executor.common.request_outputs import coerce_int as _coerce_int
|
||||
from vllm_omni.model_executor.common.request_outputs import coerce_int_list as _coerce_int_list
|
||||
from vllm_omni.model_executor.common.request_outputs import first_completion as _first_completion
|
||||
from vllm_omni.model_executor.common.request_outputs import multimodal_output as _multimodal_output
|
||||
from vllm_omni.model_executor.models.minicpmo_4_5.duplex.capabilities import (
|
||||
minicpmo45_native_capabilities,
|
||||
)
|
||||
@@ -56,7 +61,6 @@ from vllm_omni.model_executor.models.minicpmo_4_5.duplex.session import (
|
||||
)
|
||||
|
||||
if TYPE_CHECKING:
|
||||
import torch
|
||||
from transformers import PreTrainedTokenizerBase
|
||||
from vllm.config import ModelConfig
|
||||
|
||||
@@ -170,19 +174,6 @@ def _duplex_vision_tokens(payload: object, *, tile_pixels: int | None = None) ->
|
||||
return blocks * _DUPLEX_VISION_TOKENS_PER_FRAME
|
||||
|
||||
|
||||
def _duplex_pcm_sample_count(payload: object) -> int | None:
|
||||
if not isinstance(payload, dict):
|
||||
return None
|
||||
audio = payload.get("audio") or payload.get("data")
|
||||
if payload.get("format") != "pcm_f32le" or not isinstance(audio, str):
|
||||
return None
|
||||
try:
|
||||
raw = b64decode(audio, validate=True)
|
||||
except (BinasciiError, ValueError):
|
||||
return None
|
||||
return len(raw) // 4
|
||||
|
||||
|
||||
def duplex_payload_is_exact_chunks(payload: object) -> bool:
|
||||
sample_count = _duplex_pcm_sample_count(payload)
|
||||
return sample_count is not None and sample_count != 0 and sample_count % _DUPLEX_CHUNK_SAMPLES == 0
|
||||
@@ -288,48 +279,6 @@ def build_duplex_data_plane_prompt(
|
||||
# ---- engine policy helpers: listen decision ----
|
||||
|
||||
|
||||
def _coerce_int(value: object) -> int | None:
|
||||
detach = getattr(value, "detach", None)
|
||||
if callable(detach):
|
||||
try:
|
||||
flat: torch.Tensor = detach().cpu().reshape(-1)
|
||||
if flat.numel() == 0:
|
||||
return None
|
||||
value = flat[0].item()
|
||||
except Exception:
|
||||
return None
|
||||
try:
|
||||
return int(cast(Any, value)) # Any: duck-typed scalar (int/float/str/tensor item)
|
||||
except (TypeError, ValueError):
|
||||
return None
|
||||
|
||||
|
||||
def _coerce_int_list(value: object) -> list[int]:
|
||||
if value is None:
|
||||
return []
|
||||
if hasattr(value, "detach"):
|
||||
try:
|
||||
value = value.detach().cpu().reshape(-1).tolist()
|
||||
except Exception:
|
||||
return []
|
||||
if not isinstance(value, (list, tuple)):
|
||||
return []
|
||||
return [token_id for item in value if (token_id := _coerce_int(item)) is not None]
|
||||
|
||||
|
||||
def _first_completion(output: object) -> object | None:
|
||||
outputs = getattr(output, "outputs", None)
|
||||
return outputs[0] if isinstance(outputs, list) and outputs else None
|
||||
|
||||
|
||||
def _multimodal_output(output: object, completion: object | None) -> dict[str, object]:
|
||||
metadata = getattr(output, "multimodal_output", None)
|
||||
if isinstance(metadata, dict):
|
||||
return metadata
|
||||
metadata = getattr(completion, "multimodal_output", None) if completion is not None else None
|
||||
return metadata if isinstance(metadata, dict) else {}
|
||||
|
||||
|
||||
def _special_token_ids(metadata: dict[str, object]) -> dict[str, int]:
|
||||
sources: list[object] = [metadata.get("special_token_ids"), metadata.get("meta")]
|
||||
sources.append(
|
||||
|
||||
@@ -3,39 +3,22 @@
|
||||
"""PersonaPlex full-duplex integration.
|
||||
|
||||
PersonaPlex (``nvidia/personaplex-7b-v1``) is a Moshi finetune: a pure-lockstep
|
||||
speech-to-speech model. This package plugs it into the generic duplex serving
|
||||
stack through the standard plugin seams (``duplex_serving_adapter`` /
|
||||
``duplex_runtime_extension`` dotted strings in the model's ``pipeline.py``):
|
||||
speech-to-speech model. This package plugs it into the unified full-duplex
|
||||
framework through the one seam the framework has, ``PipelineConfig.duplex_plugin``:
|
||||
|
||||
- :class:`PersonaPlexConfig` immutable session config (voice / persona / sampling)
|
||||
- :class:`PersonaPlexServingRuntimeAdapter` the ``ServingRuntimeAdapter`` impl
|
||||
- :class:`PersonaPlexDuplexRuntimeExtension` the engine ``DuplexRuntimeExtension``
|
||||
- :class:`PersonaPlexStage0DuplexRuntime` Stage 0 session state and prefill
|
||||
- :class:`PersonaPlexPcmAppendBuffer` PCM input framing
|
||||
- :class:`PersonaPlexDuplexPlugin` the ``DuplexModelPlugin`` (engine + session policy)
|
||||
- :class:`PersonaPlexStage0DuplexRuntime` worker-side lockstep state and first-append prefill
|
||||
- :class:`PersonaPlexPcmAppendBuffer` 80 ms PCM input framing
|
||||
"""
|
||||
|
||||
from .config import (
|
||||
PersonaPlexConfig,
|
||||
)
|
||||
from .input import (
|
||||
PersonaPlexPcmAppendBuffer,
|
||||
)
|
||||
from .input import PersonaPlexPcmAppendBuffer
|
||||
from .plugin import PersonaPlexDuplexPlugin
|
||||
from .policy import PrefillStep
|
||||
from .runtime_extension import (
|
||||
PersonaPlexDuplexRuntimeExtension,
|
||||
)
|
||||
from .serving_adapter import (
|
||||
PersonaPlexServingRuntimeAdapter,
|
||||
)
|
||||
from .stage0 import (
|
||||
PersonaPlexStage0DuplexRuntime,
|
||||
)
|
||||
from .stage0 import PersonaPlexStage0DuplexRuntime
|
||||
|
||||
__all__ = [
|
||||
"PersonaPlexConfig",
|
||||
"PersonaPlexDuplexRuntimeExtension",
|
||||
"PersonaPlexDuplexPlugin",
|
||||
"PersonaPlexPcmAppendBuffer",
|
||||
"PersonaPlexServingRuntimeAdapter",
|
||||
"PersonaPlexStage0DuplexRuntime",
|
||||
"PrefillStep",
|
||||
]
|
||||
@@ -0,0 +1,55 @@
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
# SPDX-FileCopyrightText: Copyright contributors to the vLLM-Omni project
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from vllm_omni.engine.duplex.config import DuplexCapabilities
|
||||
from vllm_omni.model_executor.models.personaplex.duplex.config import CHUNK_PERIOD_MS
|
||||
|
||||
|
||||
def personaplex_capabilities(*, max_sessions: int = 1) -> DuplexCapabilities:
|
||||
"""What a PersonaPlex session advertises in ``session.created``.
|
||||
|
||||
PersonaPlex is a pure-lockstep model: audio flows both ways at the codec
|
||||
frame rate, the model itself decides when to speak, and there are no
|
||||
client commits or external turn signals. Barge-in is native model
|
||||
behaviour but destructive output interruption and model-state rewind are
|
||||
not validated, so it is not advertised. No text seeding exists, so the
|
||||
model cannot serve ``/v1/chat/completions``.
|
||||
"""
|
||||
supports_multi_session = max_sessions > 1
|
||||
return DuplexCapabilities(
|
||||
supports_model_native_turn_policy=True,
|
||||
supports_external_turn_signal=False,
|
||||
supports_client_commit=False,
|
||||
supports_barge_in=False,
|
||||
supports_playback_ack=True,
|
||||
supports_input_append=True,
|
||||
supports_replace_latest_chunk=False,
|
||||
supports_reencode_context=False,
|
||||
supports_rollback_to_checkpoint=False,
|
||||
supports_turn_commit_only=False,
|
||||
supports_model_internal_state=True,
|
||||
supports_stage_resumption=True,
|
||||
supports_core_resumable_request=True,
|
||||
supports_stage_connector_handoff=True,
|
||||
supports_independent_io_streams=True,
|
||||
supports_realtime_endpoint=True,
|
||||
supports_multi_session=supports_multi_session,
|
||||
supports_multi_session_same_replica=supports_multi_session,
|
||||
supports_session_lease=True,
|
||||
supports_session_resume=False,
|
||||
session_admission_mode="engine_managed",
|
||||
supports_audio_truncate=False,
|
||||
supports_chat_completions=False,
|
||||
requires_model_runner_kv=True,
|
||||
requires_native_stage_role=True,
|
||||
adapter_patterns=["scheduler_data_plane"],
|
||||
signal_sources=["model_native", "client_event"],
|
||||
stage_handoff_transport="scheduler_data_plane",
|
||||
chunk_period_ms=CHUNK_PERIOD_MS,
|
||||
target_barge_in_latency_ms=None,
|
||||
)
|
||||
|
||||
|
||||
__all__ = ["personaplex_capabilities"]
|
||||
@@ -1,64 +1,24 @@
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
# SPDX-FileCopyrightText: Copyright contributors to the vLLM-Omni project
|
||||
"""Configuration for the PersonaPlex full-duplex backend.
|
||||
"""Constants of the PersonaPlex full-duplex integration.
|
||||
|
||||
PersonaPlex (``nvidia/personaplex-7b-v1``) is a Moshi finetune: a pure-lockstep
|
||||
full-duplex speech-to-speech model running at the Mimi codec frame rate
|
||||
(12.5 Hz / 80 ms). One config drives both the offline driver and the duplex
|
||||
adapter. Defaults mirror the PersonaPlex reference loop.
|
||||
(12.5 Hz / 80 ms). The values are fixed by the pretrained checkpoint; they
|
||||
live here so the rest of the package never hard-codes them.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from dataclasses import dataclass
|
||||
|
||||
# Mimi codec constants (loaders.py: SAMPLE_RATE / FRAME_RATE). Fixed by the
|
||||
# pretrained checkpoint; exposed here only so the rest of the package never
|
||||
# hard-codes them.
|
||||
# Mimi codec constants (loaders.py: SAMPLE_RATE / FRAME_RATE).
|
||||
SAMPLE_RATE = 24000
|
||||
FRAME_RATE = 12.5
|
||||
FRAME_SIZE = int(SAMPLE_RATE / FRAME_RATE) # 1920 samples per 80 ms frame
|
||||
CHUNK_PERIOD_MS = int(round(1000 / FRAME_RATE)) # 80
|
||||
|
||||
# Default assistant persona shipped with PersonaPlex (offline.py:335).
|
||||
DEFAULT_PERSONA = "You are a wise and friendly teacher. Answer questions or provide advice in a clear and engaging way."
|
||||
# Bundled voice prompt used when a session names none.
|
||||
DEFAULT_VOICE = "NATF2.pt"
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class PersonaPlexConfig:
|
||||
"""Immutable session configuration for a PersonaPlex conversation.
|
||||
|
||||
Attributes:
|
||||
hf_repo: HuggingFace repo holding the weights, Mimi codec and tokenizer.
|
||||
voice_prompt: Voice-clone reference. Either a bundled basename
|
||||
(``"NATF2.pt"`` / ``"NATM1.pt"`` from ``voices.tgz``) or a path to a
|
||||
``.pt`` embedding bundle or a reference ``.wav``.
|
||||
persona: System role text; injected as ``<system> ... <system>`` into the
|
||||
inner-monologue stream at session start.
|
||||
device: Torch device for the backend (``"cuda"`` / ``"cpu"``).
|
||||
cpu_offload: Offload LM layers to CPU when GPU memory is tight (needs
|
||||
``accelerate``).
|
||||
batch_size: Concurrent conversation slots sharing one engine. ``1`` is
|
||||
the single-session path; ``> 1`` enables elastic batching with
|
||||
per-slot recycle for new callers.
|
||||
|
||||
Note: the native stepper decodes greedily (argmax) for both the text head
|
||||
and the depformer, so there are no sampling knobs here yet. Temperature /
|
||||
top-k / seed fields will be added if and when a sampling path is wired in.
|
||||
"""
|
||||
|
||||
hf_repo: str = "nvidia/personaplex-7b-v1"
|
||||
voice_prompt: str = "NATF2.pt"
|
||||
persona: str = DEFAULT_PERSONA
|
||||
|
||||
device: str = "cuda"
|
||||
cpu_offload: bool = False
|
||||
|
||||
batch_size: int = 1
|
||||
|
||||
@property
|
||||
def sample_rate(self) -> int:
|
||||
return SAMPLE_RATE
|
||||
|
||||
@property
|
||||
def frame_size(self) -> int:
|
||||
return FRAME_SIZE
|
||||
__all__ = ["CHUNK_PERIOD_MS", "DEFAULT_PERSONA", "DEFAULT_VOICE", "FRAME_RATE", "FRAME_SIZE", "SAMPLE_RATE"]
|
||||
@@ -1,228 +1,17 @@
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
# SPDX-FileCopyrightText: Copyright contributors to the vLLM-Omni project
|
||||
"""PersonaPlex output projection: cumulative Code2Wav audio and inner-monologue text into deltas."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from collections.abc import Callable, Iterator, Mapping
|
||||
from dataclasses import dataclass
|
||||
|
||||
import numpy as np
|
||||
|
||||
from vllm_omni.engine.duplex.contracts import (
|
||||
duplex_resource_request_belongs_to_session,
|
||||
)
|
||||
|
||||
EncodeAudio = Callable[[object, int, str, float | None], str | None]
|
||||
from vllm_omni.model_executor.common.duplex.data_plane import CumulativeAudioTextDataPlane
|
||||
from vllm_omni.model_executor.models.personaplex.duplex.config import SAMPLE_RATE
|
||||
|
||||
|
||||
@dataclass(frozen=True, slots=True)
|
||||
class PersonaPlexDataPlaneContext:
|
||||
epoch: int = 0
|
||||
turn_id: int = 0
|
||||
active_response_turn_id: int | None = None
|
||||
active_response_id: str | None = None
|
||||
auto_responds: bool = True
|
||||
response_format: str = "wav"
|
||||
speed: float | None = None
|
||||
modalities: tuple[str, ...] = ("audio", "text")
|
||||
class PersonaPlexDataPlaneSession(CumulativeAudioTextDataPlane):
|
||||
"""Project cumulative staged PersonaPlex output into Realtime deltas (24 kHz by default)."""
|
||||
|
||||
default_sample_rate_hz = SAMPLE_RATE
|
||||
|
||||
|
||||
@dataclass(slots=True)
|
||||
class _RequestCursor:
|
||||
audio_samples: int = 0
|
||||
text: str = ""
|
||||
terminal: bool = False
|
||||
|
||||
|
||||
class PersonaPlexDataPlaneSession:
|
||||
"""Project cumulative staged PersonaPlex output into Realtime deltas."""
|
||||
|
||||
def __init__(self, encode_audio: EncodeAudio) -> None:
|
||||
self._encode_audio = encode_audio
|
||||
self._requests: dict[str, _RequestCursor] = {}
|
||||
|
||||
def begin_request(self, request_id: str) -> None:
|
||||
self._requests.setdefault(request_id, _RequestCursor()).terminal = False
|
||||
|
||||
def is_terminal(self, request_id: str | None) -> bool:
|
||||
if request_id is None:
|
||||
return False
|
||||
state = self._requests.get(request_id)
|
||||
return state is not None and state.terminal
|
||||
|
||||
def mark_terminal(self, request_id: str) -> None:
|
||||
self._requests.setdefault(request_id, _RequestCursor()).terminal = True
|
||||
|
||||
def close_stream(self, request_id: str) -> None:
|
||||
self._requests.pop(request_id, None)
|
||||
|
||||
def close_session(self, session_id: str, *, active_request_id: str | None = None) -> None:
|
||||
if active_request_id is not None:
|
||||
self._requests.pop(active_request_id, None)
|
||||
for request_id in list(self._requests):
|
||||
if duplex_resource_request_belongs_to_session(request_id, session_id):
|
||||
self._requests.pop(request_id, None)
|
||||
|
||||
def project(
|
||||
self,
|
||||
result: object,
|
||||
*,
|
||||
context: PersonaPlexDataPlaneContext | None = None,
|
||||
) -> Iterator[dict[str, object]]:
|
||||
if not isinstance(result, dict):
|
||||
return
|
||||
outputs = result.get("data_plane_outputs")
|
||||
if not isinstance(outputs, list):
|
||||
return
|
||||
context = context or PersonaPlexDataPlaneContext()
|
||||
for output in outputs:
|
||||
projected = self._project_output(output, context=context)
|
||||
if projected is not None:
|
||||
yield projected
|
||||
|
||||
def _project_output(
|
||||
self,
|
||||
output: object,
|
||||
*,
|
||||
context: PersonaPlexDataPlaneContext,
|
||||
) -> dict[str, object] | None:
|
||||
output, completion = _unwrap_output(output)
|
||||
request_id = getattr(output, "request_id", None)
|
||||
if not isinstance(request_id, str) or not request_id:
|
||||
request_id = None
|
||||
state = self._requests.setdefault(request_id, _RequestCursor()) if request_id is not None else _RequestCursor()
|
||||
multimodal = _multimodal_output(output, completion)
|
||||
audio = _audio_value(multimodal)
|
||||
audio_delta = _slice_audio(audio, state.audio_samples)
|
||||
audio_samples = _num_samples(audio)
|
||||
if audio_samples is not None:
|
||||
state.audio_samples = audio_samples
|
||||
|
||||
text = _text_value(multimodal, completion)
|
||||
text_delta = _text_delta(text, state.text)
|
||||
if text:
|
||||
state.text = text
|
||||
|
||||
sample_rate_hz = _sample_rate(multimodal)
|
||||
encoded = self._encode_audio(audio_delta, sample_rate_hz, context.response_format, context.speed)
|
||||
if not encoded and not text_delta:
|
||||
return None
|
||||
delta_samples = _num_samples(audio_delta) or 0
|
||||
return {
|
||||
"supported": True,
|
||||
"stage_role": "tts",
|
||||
"is_listen": False,
|
||||
"data_plane_request_id": request_id,
|
||||
"text": text_delta,
|
||||
"audio_data": encoded or "",
|
||||
"audio_format": context.response_format,
|
||||
"sample_rate_hz": sample_rate_hz,
|
||||
"audio_duration_ms": round(delta_samples * 1000 / max(1, sample_rate_hz)),
|
||||
"end_of_turn": False,
|
||||
"uses_model_runner_scheduler": True,
|
||||
"runner_kv_backed": True,
|
||||
"runtime_impl": "scheduler_data_plane",
|
||||
"owned_runtime": False,
|
||||
}
|
||||
|
||||
|
||||
def _unwrap_output(output: object) -> tuple[object, object | None]:
|
||||
inner = getattr(output, "request_output", None)
|
||||
if inner is not None and inner is not output:
|
||||
output = inner
|
||||
outputs = getattr(output, "outputs", None)
|
||||
completion = outputs[0] if isinstance(outputs, list) and outputs else None
|
||||
return output, completion
|
||||
|
||||
|
||||
def _multimodal_output(output: object, completion: object | None) -> dict[str, object]:
|
||||
for candidate in (
|
||||
getattr(output, "multimodal_output", None),
|
||||
getattr(completion, "multimodal_output", None) if completion is not None else None,
|
||||
):
|
||||
if isinstance(candidate, Mapping) and candidate:
|
||||
return dict(candidate)
|
||||
return {}
|
||||
|
||||
|
||||
def _audio_value(multimodal: dict[str, object]) -> object | None:
|
||||
value = next(
|
||||
(multimodal[key] for key in ("audio", "model_outputs", "latent") if key in multimodal),
|
||||
None,
|
||||
)
|
||||
if isinstance(value, list) and len(value) == 1:
|
||||
return value[0]
|
||||
return value
|
||||
|
||||
|
||||
def _text_value(multimodal: dict[str, object], completion: object | None) -> str:
|
||||
for candidate in (
|
||||
multimodal.get("text"),
|
||||
multimodal.get("llm_output_text"),
|
||||
getattr(completion, "text", None) if completion is not None else None,
|
||||
):
|
||||
if isinstance(candidate, str) and candidate:
|
||||
return candidate
|
||||
return ""
|
||||
|
||||
|
||||
def _text_delta(text: str, previous: str) -> str:
|
||||
if not text:
|
||||
return ""
|
||||
if text == previous:
|
||||
return ""
|
||||
if previous and text.startswith(previous):
|
||||
return text[len(previous) :]
|
||||
return text
|
||||
|
||||
|
||||
def _slice_audio(audio: object | None, offset: int) -> object | None:
|
||||
samples = _num_samples(audio)
|
||||
if samples is None or samples <= 0:
|
||||
return None
|
||||
if offset <= 0 or samples < offset:
|
||||
return audio
|
||||
if samples == offset:
|
||||
return None
|
||||
try:
|
||||
import torch
|
||||
|
||||
if isinstance(audio, torch.Tensor):
|
||||
return audio.reshape(-1)[offset:].contiguous()
|
||||
except Exception:
|
||||
pass
|
||||
return np.asarray(audio, dtype=np.float32).reshape(-1)[offset:]
|
||||
|
||||
|
||||
def _num_samples(audio: object | None) -> int | None:
|
||||
if audio is None:
|
||||
return None
|
||||
try:
|
||||
import torch
|
||||
|
||||
if isinstance(audio, torch.Tensor):
|
||||
return int(audio.numel())
|
||||
except Exception:
|
||||
pass
|
||||
try:
|
||||
return int(np.asarray(audio, dtype=np.float32).size)
|
||||
except Exception:
|
||||
return None
|
||||
|
||||
|
||||
def _sample_rate(multimodal: dict[str, object]) -> int:
|
||||
value = multimodal.get("sr", multimodal.get("sample_rate_hz", 24000))
|
||||
if isinstance(value, list) and value:
|
||||
value = value[0]
|
||||
if hasattr(value, "item"):
|
||||
try:
|
||||
value = value.item()
|
||||
except Exception:
|
||||
value = 24000
|
||||
return int(value) if isinstance(value, int | float) else 24000
|
||||
|
||||
|
||||
__all__ = [
|
||||
"PersonaPlexDataPlaneContext",
|
||||
"PersonaPlexDataPlaneSession",
|
||||
]
|
||||
__all__ = ["PersonaPlexDataPlaneSession"]
|
||||
@@ -1,213 +1,27 @@
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
# SPDX-FileCopyrightText: Copyright contributors to the vLLM-Omni project
|
||||
"""PCM input framing for PersonaPlex: 24 kHz ``pcm_f32le`` into 1920-sample (80 ms) units."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import base64
|
||||
import binascii
|
||||
|
||||
import numpy as np
|
||||
|
||||
_SAMPLE_RATE_HZ = 24000
|
||||
_FRAME_SAMPLES = 1920
|
||||
_BYTES_PER_SAMPLE = 4
|
||||
from vllm_omni.model_executor.common.duplex.pcm_buffer import FixedFramePcmAppendBuffer
|
||||
from vllm_omni.model_executor.models.personaplex.duplex.config import (
|
||||
CHUNK_PERIOD_MS,
|
||||
FRAME_SIZE,
|
||||
SAMPLE_RATE,
|
||||
)
|
||||
|
||||
|
||||
class PersonaPlexPcmAppendReservation:
|
||||
__slots__ = (
|
||||
"_active",
|
||||
"_owner",
|
||||
"_raw",
|
||||
"operation_id",
|
||||
"payload",
|
||||
)
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
*,
|
||||
owner: PersonaPlexPcmAppendBuffer,
|
||||
operation_id: str,
|
||||
payload: dict[str, object] | None,
|
||||
raw: bytes,
|
||||
) -> None:
|
||||
self._owner = owner
|
||||
self.operation_id = operation_id
|
||||
self.payload = payload
|
||||
self._raw = raw
|
||||
self._active = True
|
||||
|
||||
@property
|
||||
def active(self) -> bool:
|
||||
return self._active
|
||||
|
||||
@property
|
||||
def byte_count(self) -> int:
|
||||
return len(self._raw)
|
||||
|
||||
def commit(self) -> None:
|
||||
self._owner._commit_reservation(self)
|
||||
|
||||
def rollback(self) -> None:
|
||||
self._owner._rollback_reservation(self)
|
||||
|
||||
|
||||
class PersonaPlexPcmAppendBuffer:
|
||||
class PersonaPlexPcmAppendBuffer(FixedFramePcmAppendBuffer):
|
||||
"""Transactionally frame 24 kHz float PCM into PersonaPlex 80 ms units."""
|
||||
|
||||
def __init__(self) -> None:
|
||||
self._buffer = bytearray()
|
||||
self._sample_rate_hz: int | None = None
|
||||
self._reservations: list[PersonaPlexPcmAppendReservation] = []
|
||||
|
||||
@property
|
||||
def pending_byte_count(self) -> int:
|
||||
return len(self._buffer)
|
||||
|
||||
def has_pending(self) -> bool:
|
||||
return bool(self._buffer)
|
||||
|
||||
def has_reserved(self) -> bool:
|
||||
return any(reservation.active for reservation in self._reservations)
|
||||
|
||||
def clear_force_listen(self) -> None:
|
||||
return
|
||||
|
||||
def clear(self) -> None:
|
||||
for reservation in self._reservations:
|
||||
reservation._active = False
|
||||
self._reservations.clear()
|
||||
self._buffer.clear()
|
||||
self._sample_rate_hz = None
|
||||
|
||||
def prepare_append(
|
||||
self,
|
||||
payload: dict[str, object],
|
||||
*,
|
||||
operation_id: str,
|
||||
chunk_period_ms: int,
|
||||
allow_emit: bool,
|
||||
) -> PersonaPlexPcmAppendReservation | None:
|
||||
if chunk_period_ms != 80:
|
||||
raise ValueError("PersonaPlex chunk_period_ms must be 80")
|
||||
if any(reservation.active and reservation.operation_id == operation_id for reservation in self._reservations):
|
||||
raise ValueError(f"PersonaPlex duplicate active operation_id: {operation_id}")
|
||||
|
||||
raw = self._decode_payload(payload)
|
||||
self._buffer.extend(raw)
|
||||
if not allow_emit or len(self._buffer) < _FRAME_SAMPLES * _BYTES_PER_SAMPLE:
|
||||
return None
|
||||
return self._reserve_frame(payload, operation_id=operation_id, flush=False)
|
||||
|
||||
def prepare_commit(
|
||||
self,
|
||||
*,
|
||||
operation_id: str,
|
||||
chunk_period_ms: int,
|
||||
) -> PersonaPlexPcmAppendReservation:
|
||||
if chunk_period_ms != 80:
|
||||
raise ValueError("PersonaPlex chunk_period_ms must be 80")
|
||||
if not self._buffer:
|
||||
reservation = PersonaPlexPcmAppendReservation(
|
||||
owner=self,
|
||||
operation_id=operation_id,
|
||||
payload=None,
|
||||
raw=b"",
|
||||
)
|
||||
self._reservations.append(reservation)
|
||||
return reservation
|
||||
payload: dict[str, object] = {
|
||||
"type": "audio",
|
||||
"format": "pcm_f32le",
|
||||
"sample_rate_hz": self._sample_rate_hz or _SAMPLE_RATE_HZ,
|
||||
"audio": "",
|
||||
"final": True,
|
||||
}
|
||||
return self._reserve_frame(payload, operation_id=operation_id, flush=True)
|
||||
|
||||
def flush(self, *, chunk_period_ms: int) -> dict[str, object] | None:
|
||||
reservation = self.prepare_commit(
|
||||
operation_id="personaplex-flush",
|
||||
chunk_period_ms=chunk_period_ms,
|
||||
super().__init__(
|
||||
sample_rate_hz=SAMPLE_RATE,
|
||||
frame_samples=FRAME_SIZE,
|
||||
chunk_period_ms=CHUNK_PERIOD_MS,
|
||||
model="PersonaPlex",
|
||||
)
|
||||
payload = reservation.payload
|
||||
reservation.commit()
|
||||
return payload
|
||||
|
||||
def _decode_payload(self, payload: dict[str, object]) -> bytes:
|
||||
if payload.get("format") != "pcm_f32le":
|
||||
raise ValueError("PersonaPlex input format must be pcm_f32le")
|
||||
sample_rate_hz = payload.get("sample_rate_hz")
|
||||
if sample_rate_hz != _SAMPLE_RATE_HZ:
|
||||
raise ValueError("PersonaPlex sample_rate_hz must be 24000")
|
||||
if self._sample_rate_hz is not None and self._sample_rate_hz != sample_rate_hz:
|
||||
raise ValueError("PersonaPlex sample_rate_hz changed within a session")
|
||||
audio = payload.get("audio")
|
||||
if not isinstance(audio, str):
|
||||
raise ValueError("PersonaPlex audio must be base64 pcm_f32le")
|
||||
try:
|
||||
raw = base64.b64decode(audio, validate=True)
|
||||
except (binascii.Error, ValueError) as exc:
|
||||
raise ValueError("PersonaPlex audio is not valid base64") from exc
|
||||
if len(raw) % _BYTES_PER_SAMPLE:
|
||||
raise ValueError("PersonaPlex pcm_f32le byte length must be divisible by four")
|
||||
samples = np.frombuffer(raw, dtype="<f4")
|
||||
if not np.isfinite(samples).all():
|
||||
raise ValueError("PersonaPlex pcm_f32le samples must be finite")
|
||||
self._sample_rate_hz = int(sample_rate_hz)
|
||||
return raw
|
||||
|
||||
def _reserve_frame(
|
||||
self,
|
||||
source_payload: dict[str, object],
|
||||
*,
|
||||
operation_id: str,
|
||||
flush: bool,
|
||||
) -> PersonaPlexPcmAppendReservation:
|
||||
frame_bytes = _FRAME_SAMPLES * _BYTES_PER_SAMPLE
|
||||
if flush:
|
||||
consumed_bytes = min(len(self._buffer), frame_bytes)
|
||||
else:
|
||||
consumed_bytes = frame_bytes
|
||||
raw = bytes(self._buffer[:consumed_bytes])
|
||||
del self._buffer[:consumed_bytes]
|
||||
encoded_raw = raw + b"\x00" * (frame_bytes - consumed_bytes)
|
||||
payload = dict(source_payload)
|
||||
payload["type"] = "audio"
|
||||
payload["format"] = "pcm_f32le"
|
||||
payload["sample_rate_hz"] = _SAMPLE_RATE_HZ
|
||||
payload["audio"] = base64.b64encode(encoded_raw).decode("ascii")
|
||||
reservation = PersonaPlexPcmAppendReservation(
|
||||
owner=self,
|
||||
operation_id=operation_id,
|
||||
payload=payload,
|
||||
raw=raw,
|
||||
)
|
||||
self._reservations.append(reservation)
|
||||
return reservation
|
||||
|
||||
def _commit_reservation(self, reservation: PersonaPlexPcmAppendReservation) -> None:
|
||||
if not reservation.active:
|
||||
return
|
||||
reservation._active = False
|
||||
self._reservations.remove(reservation)
|
||||
|
||||
def _rollback_reservation(self, reservation: PersonaPlexPcmAppendReservation) -> None:
|
||||
if not reservation.active:
|
||||
return
|
||||
try:
|
||||
index = self._reservations.index(reservation)
|
||||
except ValueError:
|
||||
reservation._active = False
|
||||
return
|
||||
rolled_back = self._reservations[index:]
|
||||
restored = b"".join(item._raw for item in rolled_back if item.active)
|
||||
self._buffer[:0] = restored
|
||||
for item in rolled_back:
|
||||
item._active = False
|
||||
del self._reservations[index:]
|
||||
|
||||
|
||||
__all__ = [
|
||||
"PersonaPlexPcmAppendBuffer",
|
||||
"PersonaPlexPcmAppendReservation",
|
||||
]
|
||||
__all__ = ["PersonaPlexPcmAppendBuffer"]
|
||||
@@ -0,0 +1,269 @@
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
# SPDX-FileCopyrightText: Copyright contributors to the vLLM-Omni project
|
||||
"""PersonaPlex full-duplex model plugin: engine policy and session policy in one class.
|
||||
|
||||
PersonaPlex is a pure-lockstep model. Engine policy is one 80 ms frame per
|
||||
resumable Stage 0 append with greedy one-token decoding; session policy is
|
||||
the bundled voice prompt and the persona text, resolved once at open into the
|
||||
server-owned runtime configuration the worker replays as its prefill.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import asyncio
|
||||
from collections.abc import Mapping
|
||||
from copy import deepcopy
|
||||
from dataclasses import dataclass, field
|
||||
from pathlib import PurePath
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
from vllm.sampling_params import SamplingParams
|
||||
|
||||
from vllm_omni.engine.duplex.config import DuplexCapabilities, DuplexSessionConfig
|
||||
from vllm_omni.engine.duplex.contracts import (
|
||||
DuplexAppendPlan,
|
||||
DuplexFence,
|
||||
DuplexOutputDecision,
|
||||
)
|
||||
from vllm_omni.engine.duplex.plugin import (
|
||||
DefaultDuplexModelSessionState,
|
||||
DuplexModelPlugin,
|
||||
DuplexRuntimeConfigError,
|
||||
EncodeAudio,
|
||||
reject_changed_runtime_value,
|
||||
)
|
||||
from vllm_omni.model_executor.common.duplex.payload import decode_pcm_f32le_payload
|
||||
from vllm_omni.model_executor.models.personaplex.duplex.capabilities import personaplex_capabilities
|
||||
from vllm_omni.model_executor.models.personaplex.duplex.config import (
|
||||
DEFAULT_PERSONA,
|
||||
DEFAULT_VOICE,
|
||||
FRAME_SIZE,
|
||||
SAMPLE_RATE,
|
||||
)
|
||||
from vllm_omni.model_executor.models.personaplex.duplex.data_plane import PersonaPlexDataPlaneSession
|
||||
from vllm_omni.model_executor.models.personaplex.duplex.input import PersonaPlexPcmAppendBuffer
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from vllm.config import ModelConfig
|
||||
|
||||
#: Runtime-config keys the server derives from the session fields; a client
|
||||
#: cannot set them through ``extra_body``.
|
||||
PRIVATE_RUNTIME_CONFIG_KEYS = frozenset(
|
||||
{
|
||||
"personaplex_prefill_slots",
|
||||
"personaplex_model_path",
|
||||
"personaplex_voice_prompt",
|
||||
"personaplex_persona",
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
@dataclass
|
||||
class PersonaPlexSessionState(DefaultDuplexModelSessionState):
|
||||
"""Per-session model state: the framework flags plus the 80 ms framing buffer."""
|
||||
|
||||
audio_buffer: PersonaPlexPcmAppendBuffer = field(default_factory=PersonaPlexPcmAppendBuffer)
|
||||
|
||||
|
||||
def voice_name(value: object) -> str:
|
||||
"""A bundled ``.pt`` basename (``NATF2.pt``); paths are refused so the worker only reads the checkpoint."""
|
||||
voice = value if isinstance(value, str) and value else DEFAULT_VOICE
|
||||
path = PurePath(voice)
|
||||
if path.name != voice or path.suffix != ".pt" or any(part == ".." for part in path.parts):
|
||||
raise DuplexRuntimeConfigError("PersonaPlex voice must be a bundled .pt basename", code="invalid_voice")
|
||||
return voice
|
||||
|
||||
|
||||
def persona_text(value: object) -> str:
|
||||
return str(value) if isinstance(value, str) and value else DEFAULT_PERSONA
|
||||
|
||||
|
||||
def prefill_slot_count(runtime_config: Mapping[str, object]) -> int:
|
||||
raw = runtime_config.get("personaplex_prefill_slots", 0)
|
||||
try:
|
||||
return max(0, int(raw)) # type: ignore[arg-type]
|
||||
except (TypeError, ValueError) as exc:
|
||||
raise ValueError("personaplex_prefill_slots must be a non-negative integer") from exc
|
||||
|
||||
|
||||
class PersonaPlexDuplexPlugin(DuplexModelPlugin):
|
||||
"""PersonaPlex-owned sampling policy, append planning, session state and output projection."""
|
||||
|
||||
plugin_id = "personaplex"
|
||||
private_runtime_config_keys = PRIVATE_RUNTIME_CONFIG_KEYS
|
||||
#: One codec frame: the runner keeps a model turn clocked with these when the client pauses.
|
||||
silence_continuation_samples = FRAME_SIZE
|
||||
silence_continuation_sample_rate_hz = SAMPLE_RATE
|
||||
|
||||
def __init__(self, encode_audio: EncodeAudio) -> None:
|
||||
super().__init__(encode_audio)
|
||||
self.data_plane = PersonaPlexDataPlaneSession(encode_audio)
|
||||
# The prefill length depends only on (model, voice, persona); the
|
||||
# voice bundle and tokenizer are read once per distinct triple.
|
||||
self._prefill_slots: dict[tuple[str, str, str], int] = {}
|
||||
self._prefill_lock = asyncio.Lock()
|
||||
|
||||
# ---- engine policy (the resumable Stage 0 request) ----
|
||||
|
||||
def configure_sampling_params(
|
||||
self,
|
||||
*,
|
||||
runtime_config: dict[str, object],
|
||||
defaults: tuple[object, ...],
|
||||
) -> tuple[object, ...]:
|
||||
del runtime_config
|
||||
if not defaults:
|
||||
return defaults
|
||||
configured = list(defaults)
|
||||
stage0 = defaults[0]
|
||||
if isinstance(stage0, SamplingParams):
|
||||
# Greedy, one temporal token per frame: the native stepper takes
|
||||
# argmax for the text head and the depformer.
|
||||
stage0 = stage0.clone()
|
||||
stage0.temperature = 0.0
|
||||
stage0.top_k = 1
|
||||
stage0.max_tokens = 1
|
||||
configured[0] = stage0
|
||||
return tuple(configured)
|
||||
|
||||
def plan_append(
|
||||
self,
|
||||
*,
|
||||
request_id: str,
|
||||
fence: DuplexFence,
|
||||
session_config: dict[str, object],
|
||||
runtime_config: dict[str, object],
|
||||
seq: int,
|
||||
turn_seq: int,
|
||||
payload: object,
|
||||
final: bool,
|
||||
sampling_params: object,
|
||||
) -> DuplexAppendPlan:
|
||||
del sampling_params
|
||||
decode_pcm_f32le_payload(payload, sample_rate_hz=SAMPLE_RATE, exact_samples=FRAME_SIZE, model="PersonaPlex")
|
||||
normalized_payload = dict(payload) # type: ignore[call-overload]
|
||||
# One scheduler slot per frame; the first append of an epoch also
|
||||
# carries the voice/persona prefill (a new epoch is a new Stage 0
|
||||
# request with fresh KV, so the worker replays it).
|
||||
prompt_slots = 1 + (prefill_slot_count(runtime_config) if seq <= 1 else 0)
|
||||
return DuplexAppendPlan(
|
||||
prompt={
|
||||
"prompt_token_ids": [0] * prompt_slots,
|
||||
"model_intermediate_buffer": {
|
||||
"request_id": request_id,
|
||||
"global_request_id": [fence.session_id],
|
||||
"duplex": {
|
||||
"data_plane": True,
|
||||
"fence": fence,
|
||||
"session_id": fence.session_id,
|
||||
"epoch": fence.epoch,
|
||||
"turn_id": fence.turn_id,
|
||||
"seq": seq,
|
||||
"turn_seq": turn_seq,
|
||||
"mode": "append_audio_chunk",
|
||||
"payload": normalized_payload,
|
||||
"final": final,
|
||||
"session_config": dict(session_config),
|
||||
"runtime_config": dict(runtime_config),
|
||||
"scheduler_token_budget": prompt_slots,
|
||||
},
|
||||
},
|
||||
}
|
||||
)
|
||||
|
||||
def decide_output(
|
||||
self,
|
||||
*,
|
||||
stage_id: int,
|
||||
final_stage_id: int,
|
||||
segment_finished: bool,
|
||||
segment_token_ids: tuple[int, ...],
|
||||
segment_output_metadata: dict[str, object],
|
||||
output: object,
|
||||
) -> DuplexOutputDecision | None:
|
||||
# Always-clocked model: what the client hears comes from the final
|
||||
# stage data plane, never from a Stage 0 listen/speak decision.
|
||||
del stage_id, final_stage_id, segment_finished, segment_token_ids, segment_output_metadata, output
|
||||
return None
|
||||
|
||||
# ---- session policy ----
|
||||
|
||||
def create_session_state(self) -> PersonaPlexSessionState:
|
||||
return PersonaPlexSessionState()
|
||||
|
||||
def capabilities(self, *, max_sessions: int) -> DuplexCapabilities:
|
||||
return personaplex_capabilities(max_sessions=max_sessions)
|
||||
|
||||
async def prepare_runtime_config(
|
||||
self, config: DuplexSessionConfig, *, model_config: ModelConfig | None
|
||||
) -> dict[str, object]:
|
||||
self.validate_client_extra_body(config.extra_body)
|
||||
model_path = getattr(model_config, "model", None)
|
||||
if not isinstance(model_path, str) or not model_path:
|
||||
raise DuplexRuntimeConfigError("PersonaPlex model path is unavailable", code="model_path_unavailable")
|
||||
voice = voice_name(config.voice)
|
||||
persona = persona_text(config.instructions)
|
||||
prefill_slots = await self._prefill_slots_for(model_path, voice, persona)
|
||||
return {
|
||||
"personaplex_model_path": model_path,
|
||||
"personaplex_voice_prompt": voice,
|
||||
"personaplex_persona": persona,
|
||||
"personaplex_prefill_slots": prefill_slots,
|
||||
}
|
||||
|
||||
async def _prefill_slots_for(self, model_path: str, voice: str, persona: str) -> int:
|
||||
key = (model_path, voice, persona)
|
||||
cached = self._prefill_slots.get(key)
|
||||
if cached is not None:
|
||||
return cached
|
||||
from vllm_omni.model_executor.models.personaplex.duplex.stage0 import personaplex_prefill_slots
|
||||
|
||||
async with self._prefill_lock:
|
||||
cached = self._prefill_slots.get(key)
|
||||
if cached is not None:
|
||||
return cached
|
||||
try:
|
||||
# Reads the voice bundle and the tokenizer: off the orchestrator loop.
|
||||
slots = await asyncio.to_thread(personaplex_prefill_slots, model_path, voice, persona)
|
||||
except Exception as exc:
|
||||
raise DuplexRuntimeConfigError(
|
||||
f"PersonaPlex voice/persona prefill could not be prepared: {exc}",
|
||||
code="prefill_unavailable",
|
||||
) from exc
|
||||
self._prefill_slots[key] = slots
|
||||
return slots
|
||||
|
||||
def runtime_config_for_update(
|
||||
self,
|
||||
config: DuplexSessionConfig,
|
||||
current: Mapping[str, object],
|
||||
) -> dict[str, object]:
|
||||
self.validate_client_extra_body(config.extra_body)
|
||||
new_persona = persona_text(config.instructions)
|
||||
reject_changed_runtime_value(
|
||||
new_persona,
|
||||
current.get("personaplex_persona"),
|
||||
message="PersonaPlex persona (instructions) cannot be changed after the session is created",
|
||||
code="persona_update_unsupported",
|
||||
)
|
||||
new_voice = voice_name(config.voice)
|
||||
reject_changed_runtime_value(
|
||||
new_voice,
|
||||
current.get("personaplex_voice_prompt"),
|
||||
message="PersonaPlex voice cannot be changed after the session is created",
|
||||
code="voice_update_unsupported",
|
||||
)
|
||||
runtime_config = deepcopy(dict(current))
|
||||
runtime_config["personaplex_voice_prompt"] = new_voice
|
||||
runtime_config["personaplex_persona"] = new_persona
|
||||
return runtime_config
|
||||
|
||||
|
||||
__all__ = [
|
||||
"PRIVATE_RUNTIME_CONFIG_KEYS",
|
||||
"PersonaPlexDuplexPlugin",
|
||||
"PersonaPlexSessionState",
|
||||
"persona_text",
|
||||
"prefill_slot_count",
|
||||
"voice_name",
|
||||
]
|
||||
@@ -1,129 +0,0 @@
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
# SPDX-FileCopyrightText: Copyright contributors to the vLLM-Omni project
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import base64
|
||||
import binascii
|
||||
from typing import Any
|
||||
|
||||
from vllm.sampling_params import SamplingParams
|
||||
|
||||
from vllm_omni.engine.duplex.messages import DuplexFence
|
||||
from vllm_omni.engine.duplex.runtime import (
|
||||
DuplexAppendPlan,
|
||||
DuplexInputMode,
|
||||
DuplexOutputDecision,
|
||||
)
|
||||
|
||||
_FRAME_BYTES = 1920 * 4
|
||||
|
||||
|
||||
def _validated_frame_payload(payload: object) -> dict[str, object]:
|
||||
if not isinstance(payload, dict):
|
||||
raise ValueError("PersonaPlex duplex append payload must be a mapping")
|
||||
if payload.get("format") != "pcm_f32le":
|
||||
raise ValueError("PersonaPlex duplex append format must be pcm_f32le")
|
||||
if payload.get("sample_rate_hz") != 24000:
|
||||
raise ValueError("PersonaPlex duplex append sample_rate_hz must be 24000")
|
||||
audio = payload.get("audio")
|
||||
if not isinstance(audio, str):
|
||||
raise ValueError("PersonaPlex duplex append audio must be base64 pcm_f32le")
|
||||
try:
|
||||
raw = base64.b64decode(audio, validate=True)
|
||||
except (binascii.Error, ValueError) as exc:
|
||||
raise ValueError("PersonaPlex duplex append audio is not valid base64") from exc
|
||||
if len(raw) != _FRAME_BYTES:
|
||||
raise ValueError("PersonaPlex duplex append must contain exactly 1920 samples")
|
||||
return dict(payload)
|
||||
|
||||
|
||||
class PersonaPlexDuplexRuntimeExtension:
|
||||
"""PersonaPlex policy for the engine-owned resumable duplex request."""
|
||||
|
||||
def configure_sampling_params(
|
||||
self,
|
||||
*,
|
||||
runtime_config: dict[str, Any],
|
||||
defaults: tuple[object, ...],
|
||||
) -> tuple[object, ...]:
|
||||
del runtime_config
|
||||
if not defaults:
|
||||
return defaults
|
||||
configured = list(defaults)
|
||||
stage0 = defaults[0]
|
||||
if isinstance(stage0, SamplingParams):
|
||||
stage0 = stage0.clone()
|
||||
stage0.temperature = 0.0
|
||||
stage0.top_k = 1
|
||||
stage0.max_tokens = 1
|
||||
configured[0] = stage0
|
||||
return tuple(configured)
|
||||
|
||||
def plan_append(
|
||||
self,
|
||||
*,
|
||||
request_id: str,
|
||||
fence: DuplexFence,
|
||||
session_config: dict[str, Any],
|
||||
runtime_config: dict[str, Any],
|
||||
seq: int,
|
||||
turn_seq: int,
|
||||
mode: DuplexInputMode,
|
||||
payload: object,
|
||||
final: bool,
|
||||
sampling_params: object,
|
||||
) -> DuplexAppendPlan:
|
||||
del sampling_params
|
||||
if mode is not DuplexInputMode.APPEND_AUDIO_CHUNK:
|
||||
raise ValueError(f"PersonaPlex does not support duplex input mode {mode.value!r}")
|
||||
normalized_payload = _validated_frame_payload(payload)
|
||||
prefill_slots = runtime_config.get("personaplex_prefill_slots", 0)
|
||||
try:
|
||||
prefill_slots = max(0, int(prefill_slots))
|
||||
except (TypeError, ValueError) as exc:
|
||||
raise ValueError("personaplex_prefill_slots must be a non-negative integer") from exc
|
||||
prompt_slots = 1 + (prefill_slots if seq <= 1 else 0)
|
||||
return DuplexAppendPlan(
|
||||
prompt={
|
||||
"prompt_token_ids": [0] * prompt_slots,
|
||||
"model_intermediate_buffer": {
|
||||
"request_id": request_id,
|
||||
"global_request_id": [fence.session_id],
|
||||
"duplex": {
|
||||
"data_plane": True,
|
||||
"fence": fence,
|
||||
"session_id": fence.session_id,
|
||||
"incarnation": fence.incarnation,
|
||||
"epoch": fence.epoch,
|
||||
"turn_id": fence.turn_id,
|
||||
"response_seq": fence.response_seq,
|
||||
"seq": seq,
|
||||
"turn_seq": turn_seq,
|
||||
"mode": mode.value,
|
||||
"payload": normalized_payload,
|
||||
"final": final,
|
||||
"session_config": dict(session_config),
|
||||
"runtime_config": dict(runtime_config),
|
||||
"scheduler_token_budget": prompt_slots,
|
||||
},
|
||||
},
|
||||
}
|
||||
)
|
||||
|
||||
def decide_output(
|
||||
self,
|
||||
*,
|
||||
stage_id: int,
|
||||
final_stage_id: int,
|
||||
segment_finished: bool,
|
||||
segment_token_ids: tuple[int, ...],
|
||||
segment_output_metadata: dict[str, Any],
|
||||
output: object,
|
||||
) -> DuplexOutputDecision | None:
|
||||
del stage_id, final_stage_id, segment_finished
|
||||
del segment_token_ids, segment_output_metadata, output
|
||||
return None
|
||||
|
||||
|
||||
__all__ = ["PersonaPlexDuplexRuntimeExtension"]
|
||||
@@ -1,253 +0,0 @@
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
# SPDX-FileCopyrightText: Copyright contributors to the vLLM-Omni project
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import asyncio
|
||||
from collections.abc import Awaitable, Callable, Mapping
|
||||
from copy import deepcopy
|
||||
from dataclasses import dataclass, field
|
||||
from pathlib import PurePath
|
||||
from typing import Any
|
||||
|
||||
from vllm_omni.entrypoints.duplex.protocol import (
|
||||
DuplexCapabilities,
|
||||
)
|
||||
from vllm_omni.entrypoints.duplex.runtime_adapter import (
|
||||
ServingRuntimeConfigError,
|
||||
reject_changed_runtime_value,
|
||||
)
|
||||
from vllm_omni.model_executor.models.personaplex.duplex.config import DEFAULT_PERSONA
|
||||
from vllm_omni.model_executor.models.personaplex.duplex.data_plane import (
|
||||
PersonaPlexDataPlaneContext,
|
||||
PersonaPlexDataPlaneSession,
|
||||
)
|
||||
from vllm_omni.model_executor.models.personaplex.duplex.input import (
|
||||
PersonaPlexPcmAppendBuffer,
|
||||
)
|
||||
|
||||
EncodeAudio = Callable[[object, int, str, float | None], str | None]
|
||||
|
||||
_PRIVATE_RUNTIME_CONFIG_KEYS = frozenset(
|
||||
{
|
||||
"personaplex_prefill_slots",
|
||||
"personaplex_model_path",
|
||||
# PersonaPlex is always model-native; the per-session opt-in knob
|
||||
# (canonical name and its deprecated alias) is server-owned here.
|
||||
"native_duplex",
|
||||
"minicpmo45_native_duplex",
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
@dataclass(slots=True)
|
||||
class PersonaPlexServingSessionState:
|
||||
audio_buffer: PersonaPlexPcmAppendBuffer = field(default_factory=PersonaPlexPcmAppendBuffer)
|
||||
input_since_commit: bool = False
|
||||
speech_since_commit: bool = False
|
||||
native_context_locked: bool = False
|
||||
committed_audio_payload: dict[str, object] | None = None
|
||||
committed_audio_operation_id: str | None = None
|
||||
committed_audio_reserved_bytes: int = 0
|
||||
deferred_response_create: bool = False
|
||||
deferred_precreate_response: bool = False
|
||||
data_plane_task: asyncio.Task[None] | None = None
|
||||
data_plane_restart_requested: bool = False
|
||||
continuation_owner_id: str | None = None
|
||||
continuation_units: int = 0
|
||||
pending_silence_task: asyncio.Task[bool] | None = None
|
||||
pending_silence_owner_id: str | None = None
|
||||
silence_continuation_scheduler: Callable[..., Awaitable[bool]] | None = None
|
||||
|
||||
def retain_committed_audio(
|
||||
self,
|
||||
payload: dict[str, object],
|
||||
*,
|
||||
operation_id: str | None,
|
||||
reserved_bytes: int = 0,
|
||||
) -> None:
|
||||
self.committed_audio_payload = payload
|
||||
self.committed_audio_operation_id = operation_id
|
||||
self.committed_audio_reserved_bytes += max(0, int(reserved_bytes))
|
||||
|
||||
def clear_committed_audio(self) -> int:
|
||||
reserved_bytes = self.committed_audio_reserved_bytes
|
||||
self.committed_audio_payload = None
|
||||
self.committed_audio_operation_id = None
|
||||
self.committed_audio_reserved_bytes = 0
|
||||
self.deferred_response_create = False
|
||||
self.deferred_precreate_response = False
|
||||
return reserved_bytes
|
||||
|
||||
def clear_continuation(self) -> None:
|
||||
self.continuation_owner_id = None
|
||||
self.continuation_units = 0
|
||||
self.pending_silence_task = None
|
||||
self.pending_silence_owner_id = None
|
||||
|
||||
|
||||
class PersonaPlexServingRuntimeAdapter:
|
||||
adapter_id = "personaplex"
|
||||
clean_response_done_prefix = ""
|
||||
interrupted_tts_prefix = ""
|
||||
private_runtime_config_keys = _PRIVATE_RUNTIME_CONFIG_KEYS
|
||||
|
||||
def __init__(self, encode_audio: EncodeAudio) -> None:
|
||||
self.session_states: dict[str, PersonaPlexServingSessionState] = {}
|
||||
self.data_plane = PersonaPlexDataPlaneSession(encode_audio)
|
||||
|
||||
def create_session_state(self) -> PersonaPlexServingSessionState:
|
||||
return PersonaPlexServingSessionState()
|
||||
|
||||
def session_state(self, session_id: str) -> PersonaPlexServingSessionState:
|
||||
return self.session_states.setdefault(session_id, self.create_session_state())
|
||||
|
||||
def remove_session_state(self, session_id: str) -> None:
|
||||
self.session_states.pop(session_id, None)
|
||||
|
||||
@staticmethod
|
||||
def is_enabled(config: object) -> bool:
|
||||
del config
|
||||
return True
|
||||
|
||||
@staticmethod
|
||||
def capabilities(*, max_sessions: int) -> DuplexCapabilities:
|
||||
supports_multi_session = max_sessions > 1
|
||||
return DuplexCapabilities(
|
||||
supports_model_native_turn_policy=True,
|
||||
supports_external_turn_signal=False,
|
||||
supports_client_commit=False,
|
||||
supports_barge_in=False,
|
||||
supports_playback_ack=True,
|
||||
supports_input_append=True,
|
||||
supports_replace_latest_chunk=False,
|
||||
supports_reencode_context=False,
|
||||
supports_rollback_to_checkpoint=False,
|
||||
supports_turn_commit_only=False,
|
||||
supports_model_internal_state=True,
|
||||
supports_stage_resumption=True,
|
||||
supports_core_resumable_request=True,
|
||||
supports_stage_connector_handoff=True,
|
||||
supports_independent_io_streams=True,
|
||||
supports_realtime_endpoint=True,
|
||||
supports_multi_session=supports_multi_session,
|
||||
supports_multi_session_same_replica=supports_multi_session,
|
||||
supports_session_lease=True,
|
||||
supports_session_resume=False,
|
||||
session_admission_mode="engine_managed",
|
||||
supports_audio_truncate=False,
|
||||
requires_model_runner_kv=True,
|
||||
requires_native_stage_role=True,
|
||||
implementation_level="model_native_duplex",
|
||||
adapter_patterns=["scheduler_data_plane"],
|
||||
input_modes=["append_audio_chunk"],
|
||||
signal_sources=["model_native", "client_event"],
|
||||
stage_handoff_transport="scheduler_data_plane",
|
||||
chunk_period_ms=80,
|
||||
target_barge_in_latency_ms=None,
|
||||
)
|
||||
|
||||
@staticmethod
|
||||
def validate_client_extra_body(extra_body: object) -> None:
|
||||
if not isinstance(extra_body, dict):
|
||||
return
|
||||
private = sorted(_PRIVATE_RUNTIME_CONFIG_KEYS.intersection(extra_body))
|
||||
if private:
|
||||
raise ServingRuntimeConfigError("PersonaPlex runtime configuration is server-owned: " + ", ".join(private))
|
||||
|
||||
@classmethod
|
||||
async def prepare_runtime_config(
|
||||
cls,
|
||||
config: object,
|
||||
*,
|
||||
model_config: Any,
|
||||
) -> dict[str, object]:
|
||||
extra_body = getattr(config, "extra_body", None)
|
||||
cls.validate_client_extra_body(extra_body)
|
||||
model_path = getattr(model_config, "model", None)
|
||||
if not isinstance(model_path, str) or not model_path:
|
||||
raise ServingRuntimeConfigError("PersonaPlex model path is unavailable")
|
||||
voice = cls._voice_name(getattr(config, "voice", None))
|
||||
instructions = getattr(config, "instructions", None) or DEFAULT_PERSONA
|
||||
from vllm_omni.model_executor.models.personaplex.duplex.stage0 import (
|
||||
personaplex_prefill_slots,
|
||||
)
|
||||
|
||||
try:
|
||||
prefill_slots = await asyncio.to_thread(
|
||||
personaplex_prefill_slots,
|
||||
model_path,
|
||||
voice,
|
||||
str(instructions),
|
||||
)
|
||||
except Exception as exc:
|
||||
raise ServingRuntimeConfigError(f"PersonaPlex voice/persona prefill could not be prepared: {exc}") from exc
|
||||
return {
|
||||
"personaplex_model_path": model_path,
|
||||
"personaplex_voice_prompt": voice,
|
||||
"personaplex_persona": str(instructions),
|
||||
"personaplex_prefill_slots": prefill_slots,
|
||||
}
|
||||
|
||||
@classmethod
|
||||
def runtime_config_for_update(
|
||||
cls,
|
||||
config: object,
|
||||
current: Mapping[str, object],
|
||||
) -> dict[str, object]:
|
||||
cls.validate_client_extra_body(getattr(config, "extra_body", None))
|
||||
new_persona = str(getattr(config, "instructions", None) or DEFAULT_PERSONA)
|
||||
reject_changed_runtime_value(
|
||||
new_persona,
|
||||
current.get("personaplex_persona"),
|
||||
message="PersonaPlex persona (instructions) cannot be changed after the session is created",
|
||||
code="persona_update_unsupported",
|
||||
)
|
||||
new_voice = cls._voice_name(getattr(config, "voice", None))
|
||||
reject_changed_runtime_value(
|
||||
new_voice,
|
||||
current.get("personaplex_voice_prompt"),
|
||||
message="PersonaPlex voice cannot be changed after the session is created",
|
||||
code="voice_update_unsupported",
|
||||
)
|
||||
runtime_config = deepcopy(dict(current))
|
||||
runtime_config["personaplex_voice_prompt"] = new_voice
|
||||
runtime_config["personaplex_persona"] = new_persona
|
||||
return runtime_config
|
||||
|
||||
@staticmethod
|
||||
def data_plane_context(
|
||||
*,
|
||||
epoch: int,
|
||||
turn_id: int,
|
||||
active_response_turn_id: int | None,
|
||||
active_response_id: str | None,
|
||||
auto_responds: bool,
|
||||
response_format: str,
|
||||
speed: float | None,
|
||||
modalities: tuple[str, ...],
|
||||
) -> PersonaPlexDataPlaneContext:
|
||||
return PersonaPlexDataPlaneContext(
|
||||
epoch=epoch,
|
||||
turn_id=turn_id,
|
||||
active_response_turn_id=active_response_turn_id,
|
||||
active_response_id=active_response_id,
|
||||
auto_responds=auto_responds,
|
||||
response_format=response_format,
|
||||
speed=speed,
|
||||
modalities=modalities,
|
||||
)
|
||||
|
||||
@staticmethod
|
||||
def _voice_name(value: object) -> str:
|
||||
voice = value if isinstance(value, str) and value else "NATF2.pt"
|
||||
path = PurePath(voice)
|
||||
if path.name != voice or path.suffix != ".pt" or any(part == ".." for part in path.parts):
|
||||
raise ServingRuntimeConfigError("PersonaPlex voice must be a bundled .pt basename")
|
||||
return voice
|
||||
|
||||
|
||||
__all__ = [
|
||||
"PersonaPlexServingRuntimeAdapter",
|
||||
"PersonaPlexServingSessionState",
|
||||
]
|
||||
@@ -3,17 +3,19 @@
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import base64
|
||||
import binascii
|
||||
import io
|
||||
import tarfile
|
||||
from collections.abc import Callable
|
||||
from dataclasses import dataclass, field
|
||||
from functools import lru_cache
|
||||
from pathlib import Path
|
||||
from typing import Any
|
||||
|
||||
import numpy as np
|
||||
|
||||
from vllm_omni.model_executor.common.audio.pcm import pcm_f32le_samples
|
||||
from vllm_omni.model_executor.common.duplex.payload import decode_pcm_f32le_payload
|
||||
from vllm_omni.model_executor.models.personaplex.duplex.config import FRAME_SIZE, SAMPLE_RATE
|
||||
from vllm_omni.model_executor.models.personaplex.duplex.policy import (
|
||||
AUDIO_SILENCE_FRAME_CNT,
|
||||
SILENCE_TOKENS,
|
||||
@@ -22,7 +24,7 @@ from vllm_omni.model_executor.models.personaplex.duplex.policy import (
|
||||
wrap_with_system_tags,
|
||||
)
|
||||
|
||||
_FRAME_SAMPLES = 1920
|
||||
_FRAME_SAMPLES = FRAME_SIZE
|
||||
|
||||
|
||||
@dataclass(slots=True)
|
||||
@@ -37,8 +39,10 @@ class PersonaPlexStage0PreparedAppend:
|
||||
|
||||
@dataclass(slots=True)
|
||||
class PersonaPlexStage0SessionState:
|
||||
"""Lockstep state of one (session, epoch): a new epoch is a new Stage 0 request with fresh KV."""
|
||||
|
||||
session_id: str
|
||||
incarnation: int
|
||||
epoch: int
|
||||
user_codes: Any | None = None
|
||||
last_text_token: Any | None = None
|
||||
last_agent_codes: Any | None = None
|
||||
@@ -94,14 +98,29 @@ def load_personaplex_voice_state(model_path: str, voice: str) -> dict[str, Any]:
|
||||
raise FileNotFoundError(f"PersonaPlex bundled voice prompt {voice!r} was not found under {model_path!r}")
|
||||
|
||||
|
||||
def personaplex_prefill_slots(model_path: str, voice: str, persona: str) -> int:
|
||||
@lru_cache(maxsize=4)
|
||||
def _cached_tokenizer(model_path: str):
|
||||
return load_personaplex_tokenizer(model_path)
|
||||
|
||||
|
||||
@lru_cache(maxsize=16)
|
||||
def _cached_voice_embedding_rows(model_path: str, voice: str) -> int:
|
||||
state = load_personaplex_voice_state(model_path, voice)
|
||||
embeddings = state.get("embeddings")
|
||||
if not hasattr(embeddings, "shape") or len(embeddings.shape) < 1:
|
||||
raise ValueError(f"PersonaPlex voice prompt {voice!r} has no embeddings")
|
||||
tokenizer = load_personaplex_tokenizer(model_path)
|
||||
persona_tokens = tokenizer(wrap_with_system_tags(persona)) if persona else []
|
||||
return int(embeddings.shape[0]) + 2 * AUDIO_SILENCE_FRAME_CNT + len(persona_tokens)
|
||||
return int(embeddings.shape[0])
|
||||
|
||||
|
||||
def personaplex_prefill_slots(model_path: str, voice: str, persona: str) -> int:
|
||||
"""Scheduler slots the first append of a session needs for the voice + persona prefill.
|
||||
|
||||
The voice bundle row count and the tokenizer are cached per model path:
|
||||
they are constant, and this runs on every session open.
|
||||
"""
|
||||
voice_rows = _cached_voice_embedding_rows(model_path, voice)
|
||||
persona_tokens = _cached_tokenizer(model_path)(wrap_with_system_tags(persona)) if persona else []
|
||||
return voice_rows + 2 * AUDIO_SILENCE_FRAME_CNT + len(persona_tokens)
|
||||
|
||||
|
||||
class PersonaPlexStage0DuplexRuntime:
|
||||
@@ -147,19 +166,24 @@ class PersonaPlexStage0DuplexRuntime:
|
||||
session_id = duplex.get("session_id")
|
||||
if not isinstance(session_id, str) or not session_id:
|
||||
raise ValueError("PersonaPlex duplex append requires session_id")
|
||||
incarnation = _coerce_non_negative_int(duplex.get("incarnation"), "incarnation")
|
||||
epoch = _coerce_non_negative_int(duplex.get("epoch"), "epoch")
|
||||
seq = _coerce_positive_int(duplex.get("seq"), "seq")
|
||||
identity = (epoch, seq)
|
||||
key = (session_id, incarnation)
|
||||
key = (session_id, epoch)
|
||||
|
||||
state = self.sessions.get(key)
|
||||
if state is None:
|
||||
# A newer epoch supersedes the session's earlier lockstep state:
|
||||
# the engine aborted that request, but its finish notification
|
||||
# may still be in flight, so release it here rather than let the
|
||||
# two epochs share the codec budget.
|
||||
for stale_key in [k for k in self.sessions if k[0] == session_id and k[1] < epoch]:
|
||||
self.close_session(*stale_key)
|
||||
if len(self.sessions) >= self.max_sessions:
|
||||
raise RuntimeError(f"PersonaPlex Stage 0 session capacity {self.max_sessions} is exhausted")
|
||||
state = PersonaPlexStage0SessionState(
|
||||
session_id=session_id,
|
||||
incarnation=incarnation,
|
||||
epoch=epoch,
|
||||
codec=self._acquire_codec(),
|
||||
)
|
||||
self.sessions[key] = state
|
||||
@@ -291,7 +315,6 @@ class PersonaPlexStage0DuplexRuntime:
|
||||
"stage0_prepared": True,
|
||||
"prefill_applied": first_append,
|
||||
"session_id": session_id,
|
||||
"incarnation": incarnation,
|
||||
"epoch": epoch,
|
||||
"seq": seq,
|
||||
},
|
||||
@@ -363,8 +386,8 @@ class PersonaPlexStage0DuplexRuntime:
|
||||
if not state.request_ids:
|
||||
self.close_session(*key)
|
||||
|
||||
def close_session(self, session_id: str, incarnation: int) -> None:
|
||||
key = (session_id, incarnation)
|
||||
def close_session(self, session_id: str, epoch: int) -> None:
|
||||
key = (session_id, epoch)
|
||||
state = self.sessions.pop(key, None)
|
||||
if state is None:
|
||||
return
|
||||
@@ -421,23 +444,13 @@ class PersonaPlexStage0DuplexRuntime:
|
||||
|
||||
@staticmethod
|
||||
def _decode_pcm(payload: object) -> np.ndarray:
|
||||
if not isinstance(payload, dict):
|
||||
raise ValueError("PersonaPlex duplex payload must be a mapping")
|
||||
if payload.get("format") != "pcm_f32le" or payload.get("sample_rate_hz") != 24000:
|
||||
raise ValueError("PersonaPlex Stage 0 requires 24 kHz pcm_f32le")
|
||||
audio = payload.get("audio")
|
||||
if not isinstance(audio, str):
|
||||
raise ValueError("PersonaPlex Stage 0 requires base64 audio")
|
||||
try:
|
||||
raw = base64.b64decode(audio, validate=True)
|
||||
except (binascii.Error, ValueError) as exc:
|
||||
raise ValueError("PersonaPlex Stage 0 audio is not valid base64") from exc
|
||||
samples = np.frombuffer(raw, dtype="<f4")
|
||||
if samples.size != _FRAME_SAMPLES:
|
||||
raise ValueError(f"PersonaPlex Stage 0 requires {_FRAME_SAMPLES} samples per append")
|
||||
if not np.isfinite(samples).all():
|
||||
raise ValueError("PersonaPlex Stage 0 samples must be finite")
|
||||
return np.ascontiguousarray(samples, dtype=np.float32).copy()
|
||||
raw = decode_pcm_f32le_payload(
|
||||
payload,
|
||||
sample_rate_hz=SAMPLE_RATE,
|
||||
exact_samples=_FRAME_SAMPLES,
|
||||
model="PersonaPlex Stage 0",
|
||||
)
|
||||
return pcm_f32le_samples(raw)
|
||||
|
||||
|
||||
def _coerce_non_negative_int(value: object, name: str) -> int:
|
||||
|
||||
@@ -2,9 +2,10 @@
|
||||
# SPDX-FileCopyrightText: Copyright contributors to the vLLM-Omni project
|
||||
"""PersonaPlex pipeline: Talker (AR decode -> Mimi codebooks) -> Code2Wav (codebooks -> 24 kHz PCM).
|
||||
|
||||
PersonaPlex is a Moshi finetune (full-duplex speech-to-speech). For offline/batch
|
||||
runs it is served as a 2-stage vllm-omni audio->audio pipeline, reusing the
|
||||
Qwen3-TTS staged topology:
|
||||
PersonaPlex is a Moshi finetune (full-duplex speech-to-speech), served as a
|
||||
2-stage vllm-omni audio->audio pipeline that reuses the Qwen3-TTS staged
|
||||
topology (online: one resumable Stage 0 request per duplex session, see
|
||||
``duplex/plugin.py``):
|
||||
|
||||
* Stage 0 (``personaplex``) is the AR talker: the Helium temporal transformer
|
||||
plus the depformer (both built by the lead). It emits the per-frame audio
|
||||
@@ -31,13 +32,8 @@ PERSONAPLEX_PIPELINE = PipelineConfig(
|
||||
# Pipeline-level default; the code2wav stage overrides per-stage below.
|
||||
model_arch="PersonaPlexTalkerForConditionalGeneration",
|
||||
default_deploy_config_name="personaplex.yaml",
|
||||
duplex_runtime_extension=(
|
||||
"vllm_omni.model_executor.models.personaplex.duplex.runtime_extension.PersonaPlexDuplexRuntimeExtension"
|
||||
),
|
||||
duplex_serving_adapter=(
|
||||
"vllm_omni.model_executor.models.personaplex.duplex.serving_adapter.PersonaPlexServingRuntimeAdapter"
|
||||
),
|
||||
duplex_control_enabled=True,
|
||||
# Served full duplex over /v1/realtime?duplex=1 by the unified framework.
|
||||
duplex_plugin="vllm_omni.model_executor.models.personaplex.duplex.plugin.PersonaPlexDuplexPlugin",
|
||||
stages=(
|
||||
StagePipelineConfig(
|
||||
stage_id=0,
|
||||
|
||||
Reference in new issue
Block a user