[Refactor] msgspec standardisation for data entry key names and improved type checks (#3149)
Signed-off-by: Divyansh Singhvi <divyanshsinghvi@gmail.com> Signed-off-by: dsinghvi <divyanshsinghvi@gmail.com>
This commit is contained in:
1 parent
9a60e11e3d
commit
e40076e872
25 files changed
+1047
-686
No files matched your search
@@ -32,6 +32,7 @@ from vllm.v1.outputs import SamplerOutput
|
||||
from vllm.v1.sample.metadata import SamplingMetadata
|
||||
from vllm.v1.sample.sampler import Sampler
|
||||
|
||||
from vllm_omni.data_entry_keys import EmbeddingsStruct, OmniPayloadStruct, to_dict, to_struct
|
||||
from vllm_omni.model_executor.models.cosyvoice3.config import CosyVoice3Config
|
||||
from vllm_omni.model_executor.models.cosyvoice3.utils import (
|
||||
concat_text_with_prompt_ids,
|
||||
@@ -379,43 +380,6 @@ class CosyVoice3Model(
|
||||
# Use parent's cache config - critical for PagedAttention to work correctly
|
||||
return parent_config.with_hf_config(qwen_hf_config, architectures=["Qwen2Model"])
|
||||
|
||||
@staticmethod
|
||||
def _as_tensor(value: object) -> torch.Tensor | None:
|
||||
"""Extract tensor payload from runtime info fields."""
|
||||
if isinstance(value, list):
|
||||
if not value:
|
||||
return None
|
||||
value = value[0]
|
||||
if isinstance(value, torch.Tensor):
|
||||
return value
|
||||
return None
|
||||
|
||||
@staticmethod
|
||||
def _as_str(value: object) -> str | None:
|
||||
"""Extract string payload from runtime info fields."""
|
||||
if isinstance(value, list):
|
||||
if not value:
|
||||
return None
|
||||
value = value[0]
|
||||
if value is None:
|
||||
return None
|
||||
return str(value)
|
||||
|
||||
@staticmethod
|
||||
def _as_bool(value: object) -> bool:
|
||||
"""Extract boolean payload from runtime info fields."""
|
||||
if isinstance(value, list):
|
||||
if not value:
|
||||
return False
|
||||
value = value[0]
|
||||
if isinstance(value, torch.Tensor):
|
||||
if value.numel() == 0:
|
||||
return False
|
||||
return bool(value.reshape(-1)[0].item())
|
||||
if value is None:
|
||||
return False
|
||||
return bool(value)
|
||||
|
||||
@staticmethod
|
||||
def _cross_fade_audio(audio: torch.Tensor, prev_tail: torch.Tensor) -> torch.Tensor:
|
||||
"""Blend previous chunk tail into current chunk head using a Hamming window.
|
||||
@@ -710,12 +674,17 @@ class CosyVoice3Model(
|
||||
multimodal_outputs = {}
|
||||
|
||||
if "speech_token" in kwargs:
|
||||
# Wrap in lists to pass through gpu_ar_model_runner shape filtering
|
||||
multimodal_outputs = {
|
||||
"speech_token": [kwargs.get("speech_token")],
|
||||
"speech_feat": [kwargs.get("speech_feat")],
|
||||
"embedding": [kwargs.get("embedding")],
|
||||
}
|
||||
# Prompt conditioning tensors for code2wav: live under
|
||||
# ``embed.*`` per OmniPayloadStruct schema.
|
||||
multimodal_outputs = to_dict(
|
||||
OmniPayloadStruct(
|
||||
embed=EmbeddingsStruct(
|
||||
speech_token=kwargs.get("speech_token"),
|
||||
speech_feat=kwargs.get("speech_feat"),
|
||||
embedding=kwargs.get("embedding"),
|
||||
),
|
||||
)
|
||||
)
|
||||
|
||||
return OmniOutput(text_hidden_states=hidden_states, multimodal_outputs=multimodal_outputs)
|
||||
elif self.model_stage == "cosyvoice3_code2wav":
|
||||
@@ -738,23 +707,29 @@ class CosyVoice3Model(
|
||||
runtime_info = []
|
||||
|
||||
for idx, req_ids in enumerate(request_ids_list):
|
||||
info = runtime_info[idx] if idx < len(runtime_info) and isinstance(runtime_info[idx], dict) else {}
|
||||
req_id = self._as_str(info.get("req_id")) if info else None
|
||||
stream_finished = self._as_bool(info.get("stream_finished")) if info else False
|
||||
speech_token = self._as_tensor(info.get("speech_token")) if info else None
|
||||
speech_feat = self._as_tensor(info.get("speech_feat")) if info else None
|
||||
embedding = self._as_tensor(info.get("embedding")) if info else None
|
||||
raw = runtime_info[idx] if idx < len(runtime_info) and isinstance(runtime_info[idx], dict) else {}
|
||||
payload = to_struct(raw)
|
||||
meta = payload.meta
|
||||
embed = payload.embed
|
||||
|
||||
req_id = meta.req_id[0] if (meta and meta.req_id) else None
|
||||
stream_finished = (
|
||||
bool(meta.stream_finished.item()) if (meta and meta.stream_finished is not None) else False
|
||||
)
|
||||
speech_token = embed.speech_token if embed else None
|
||||
speech_feat = embed.speech_feat if embed else None
|
||||
embedding = embed.embedding if embed else None
|
||||
if speech_token is None or speech_feat is None or embedding is None:
|
||||
if stream_finished and req_id is not None and hasattr(self, "_stream_vocoder_cache_by_req"):
|
||||
with self._stream_audio_cache_lock:
|
||||
self._stream_vocoder_cache_by_req.pop(req_id, None)
|
||||
audios[idx] = self._stitch_stream_audio(req_id, empty_audio, stream_finished)
|
||||
if (
|
||||
req_ids.numel() > 0
|
||||
and info
|
||||
and ("token_offset" in info or "left_context_size" in info or "generated_len" in info)
|
||||
if req_ids.numel() > 0 and (
|
||||
(meta and meta.left_context_size is not None) or payload.generated_len is not None
|
||||
):
|
||||
info_keys = ",".join(sorted(info.keys())) if info else ""
|
||||
info_keys = ",".join(
|
||||
sorted(f for f in payload.__struct_fields__ if getattr(payload, f) is not None)
|
||||
)
|
||||
logger.warning_once(
|
||||
"CosyVoice3 code2wav missing prompt conditioning for non-empty codec tokens: "
|
||||
"raw_len=%d info_keys=%s",
|
||||
@@ -780,18 +755,11 @@ class CosyVoice3Model(
|
||||
# `generated_len` is injected for many models by the generic
|
||||
# runner, so only explicit chunk-routing fields should switch
|
||||
# code2wav into the streaming path.
|
||||
uses_streaming_decode = bool(info) and (
|
||||
"stream_finished" in info or "token_offset" in info or "left_context_size" in info
|
||||
uses_streaming_decode = meta and (
|
||||
meta.stream_finished is not None or meta.left_context_size is not None
|
||||
)
|
||||
if uses_streaming_decode:
|
||||
token_offset = 0
|
||||
try:
|
||||
if info and "token_offset" in info:
|
||||
token_offset = max(0, int(info.get("token_offset", 0)))
|
||||
elif info:
|
||||
token_offset = max(0, int(info.get("left_context_size", 0)))
|
||||
except (TypeError, ValueError):
|
||||
token_offset = 0
|
||||
token_offset = max(0, meta.left_context_size or 0)
|
||||
|
||||
cache_state = None
|
||||
if req_id is not None and hasattr(self, "_stream_vocoder_cache_by_req"):
|
||||
|
||||
@@ -137,13 +137,7 @@ class Qwen3TTSCode2Wav(nn.Module):
|
||||
break
|
||||
meta = info.get("meta", {})
|
||||
if "left_context_size" in meta:
|
||||
# left_context_size may come through serialization as an int, [int], or tensor([int]).
|
||||
value = meta["left_context_size"]
|
||||
if isinstance(value, list):
|
||||
value = value[0] if value else 0
|
||||
if isinstance(value, torch.Tensor):
|
||||
value = value.reshape(-1)[0].item() if value.numel() > 0 else 0
|
||||
left_context_size[i] = int(value)
|
||||
left_context_size[i] = meta["left_context_size"]
|
||||
for i, req_ids in enumerate(request_ids_list):
|
||||
if req_ids.numel() < 1:
|
||||
parsed.append((0, 0))
|
||||
|
||||
@@ -8,9 +8,29 @@ import numpy as np
|
||||
import torch
|
||||
from vllm.inputs import TextPrompt
|
||||
|
||||
from vllm_omni.data_entry_keys import (
|
||||
CodesStruct,
|
||||
EmbeddingsStruct,
|
||||
MetaStruct,
|
||||
OmniPayloadStruct,
|
||||
)
|
||||
from vllm_omni.inputs.data import OmniTokensPrompt
|
||||
|
||||
|
||||
def _build_prompt_embed_struct(prompt_payload: dict[str, Any]) -> EmbeddingsStruct | None:
|
||||
"""Wrap prompt_payload's flat speech_token/speech_feat/embedding tensors into EmbeddingsStruct."""
|
||||
speech_token = prompt_payload.get("speech_token")
|
||||
speech_feat = prompt_payload.get("speech_feat")
|
||||
embedding = prompt_payload.get("embedding")
|
||||
if speech_token is None and speech_feat is None and embedding is None:
|
||||
return None
|
||||
return EmbeddingsStruct(
|
||||
speech_token=speech_token,
|
||||
speech_feat=speech_feat,
|
||||
embedding=embedding,
|
||||
)
|
||||
|
||||
|
||||
def _ensure_list(x: Any) -> list[Any]:
|
||||
if hasattr(x, "_x"):
|
||||
return list(x._x)
|
||||
@@ -88,7 +108,7 @@ def talker2code2wav_async_chunk(
|
||||
pooling_output: dict[str, Any] | None,
|
||||
request: Any,
|
||||
is_finished: bool = False,
|
||||
) -> dict[str, Any] | None:
|
||||
) -> OmniPayloadStruct | None:
|
||||
"""CosyVoice3 async_chunk processor: talker token stream -> code2wav chunks."""
|
||||
with nullcontext():
|
||||
request_id = request.external_req_id
|
||||
@@ -114,16 +134,18 @@ def talker2code2wav_async_chunk(
|
||||
if not isinstance(request_state, dict) or "_cosyvoice3_async_state" not in request_state:
|
||||
with nullcontext():
|
||||
info = _decode_additional_information(getattr(request, "additional_information", None))
|
||||
info_embed = info.get("embed", {}) if isinstance(info, dict) else {}
|
||||
prompt_payload = {}
|
||||
for key in ("speech_token", "speech_feat", "embedding"):
|
||||
value = _to_cpu_tensor(info.get(key))
|
||||
value = _to_cpu_tensor(info_embed.get(key))
|
||||
if value is not None:
|
||||
prompt_payload[key] = value
|
||||
if isinstance(pooling_output, dict):
|
||||
po_embed = pooling_output.get("embed", {}) if isinstance(pooling_output.get("embed"), dict) else {}
|
||||
for key in ("speech_token", "speech_feat", "embedding"):
|
||||
if key in prompt_payload:
|
||||
continue
|
||||
value = _to_cpu_tensor(pooling_output.get(key))
|
||||
value = _to_cpu_tensor(po_embed.get(key))
|
||||
if value is not None:
|
||||
prompt_payload[key] = value
|
||||
prompt_token = prompt_payload.get("speech_token")
|
||||
@@ -176,27 +198,29 @@ def talker2code2wav_async_chunk(
|
||||
if length <= 0:
|
||||
if not finished:
|
||||
return None
|
||||
payload: dict[str, Any] = {
|
||||
"codes": {"audio": []},
|
||||
"meta": {"finished": torch.tensor(True, dtype=torch.bool)},
|
||||
}
|
||||
embed_struct = None
|
||||
if not state.get("sent_prompt", False):
|
||||
payload.update(state.get("prompt_payload", {}))
|
||||
embed_struct = _build_prompt_embed_struct(state.get("prompt_payload", {}))
|
||||
state["sent_prompt"] = True
|
||||
state["terminal_sent"] = True
|
||||
return payload
|
||||
return OmniPayloadStruct(
|
||||
codes=CodesStruct(audio=torch.empty(0, dtype=torch.long)),
|
||||
meta=MetaStruct(finished=torch.tensor(True, dtype=torch.bool)),
|
||||
embed=embed_struct,
|
||||
)
|
||||
|
||||
emitted_token_len = int(state.get("emitted_token_len", 0))
|
||||
if finished and length <= emitted_token_len:
|
||||
payload = {
|
||||
"codes": {"audio": []},
|
||||
"meta": {"finished": torch.tensor(True, dtype=torch.bool)},
|
||||
}
|
||||
embed_struct = None
|
||||
if not state.get("sent_prompt", False):
|
||||
payload.update(state.get("prompt_payload", {}))
|
||||
embed_struct = _build_prompt_embed_struct(state.get("prompt_payload", {}))
|
||||
state["sent_prompt"] = True
|
||||
state["terminal_sent"] = True
|
||||
return payload
|
||||
return OmniPayloadStruct(
|
||||
codes=CodesStruct(audio=torch.empty(0, dtype=torch.long)),
|
||||
meta=MetaStruct(finished=torch.tensor(True, dtype=torch.bool)),
|
||||
embed=embed_struct,
|
||||
)
|
||||
|
||||
with nullcontext():
|
||||
token_hop_len = max(1, int(state.get("token_hop_len", chunk_size)))
|
||||
@@ -220,18 +244,22 @@ def talker2code2wav_async_chunk(
|
||||
with nullcontext():
|
||||
code_predictor_codes = [int(frame[0]) for frame in token_frames[:prefix_len]]
|
||||
|
||||
payload = {
|
||||
"codes": {"audio": code_predictor_codes},
|
||||
"meta": {"finished": torch.tensor(finished, dtype=torch.bool)},
|
||||
"token_offset": token_offset,
|
||||
"left_context_size": token_offset,
|
||||
"req_id": [request_id],
|
||||
"stream_finished": torch.tensor(finished, dtype=torch.bool),
|
||||
}
|
||||
embed_struct = None
|
||||
if not state.get("sent_prompt", False):
|
||||
payload.update(state.get("prompt_payload", {}))
|
||||
embed_struct = _build_prompt_embed_struct(state.get("prompt_payload", {}))
|
||||
state["sent_prompt"] = True
|
||||
|
||||
payload = OmniPayloadStruct(
|
||||
codes=CodesStruct(audio=torch.tensor(code_predictor_codes, dtype=torch.long)),
|
||||
meta=MetaStruct(
|
||||
finished=torch.tensor(finished, dtype=torch.bool),
|
||||
stream_finished=torch.tensor(finished, dtype=torch.bool),
|
||||
req_id=[request_id],
|
||||
left_context_size=token_offset,
|
||||
),
|
||||
embed=embed_struct,
|
||||
)
|
||||
|
||||
if not finished:
|
||||
state["emitted_token_len"] = emitted_token_len + this_token_hop_len
|
||||
state["token_hop_len"] = min(
|
||||
|
||||
@@ -5,6 +5,12 @@ from typing import Any
|
||||
import torch
|
||||
from vllm.logger import init_logger
|
||||
|
||||
from vllm_omni.data_entry_keys import (
|
||||
CodesStruct,
|
||||
MetaStruct,
|
||||
OmniPayloadStruct,
|
||||
)
|
||||
|
||||
logger = init_logger(__name__)
|
||||
|
||||
|
||||
@@ -59,7 +65,7 @@ def slow_ar_to_dac_decoder_async_chunk(
|
||||
pooling_output: dict[str, Any] | None,
|
||||
request: Any,
|
||||
is_finished: bool = False,
|
||||
) -> dict[str, Any] | None:
|
||||
) -> OmniPayloadStruct | None:
|
||||
"""Async streaming processor: emit code chunks as they are produced.
|
||||
|
||||
Accumulates per-step codes and emits fixed-size chunks with left context
|
||||
@@ -107,10 +113,10 @@ def slow_ar_to_dac_decoder_async_chunk(
|
||||
|
||||
if length <= 0:
|
||||
if finished:
|
||||
return {
|
||||
"codes": {"audio": []},
|
||||
"meta": {"finished": torch.tensor(True, dtype=torch.bool)},
|
||||
}
|
||||
return OmniPayloadStruct(
|
||||
codes=CodesStruct(audio=torch.empty(0, dtype=torch.long)),
|
||||
meta=MetaStruct(finished=torch.tensor(True, dtype=torch.bool)),
|
||||
)
|
||||
return None
|
||||
|
||||
in_initial_phase = initial_chunk_size > 0 and length <= chunk_size
|
||||
@@ -138,9 +144,12 @@ def slow_ar_to_dac_decoder_async_chunk(
|
||||
|
||||
# Pack into codebook-major flat codes.
|
||||
stacked_frames = torch.stack(window_frames, dim=0)
|
||||
code_predictor_codes = stacked_frames.transpose(0, 1).reshape(-1).tolist()
|
||||
code_predictor_codes = stacked_frames.transpose(0, 1).reshape(-1)
|
||||
|
||||
return {
|
||||
"codes": {"audio": code_predictor_codes},
|
||||
"meta": {"left_context_size": left_context_size, "finished": torch.tensor(finished, dtype=torch.bool)},
|
||||
}
|
||||
return OmniPayloadStruct(
|
||||
codes=CodesStruct(audio=code_predictor_codes),
|
||||
meta=MetaStruct(
|
||||
left_context_size=left_context_size,
|
||||
finished=torch.tensor(finished, dtype=torch.bool),
|
||||
),
|
||||
)
|
||||
@@ -4,6 +4,12 @@ import torch
|
||||
from vllm.inputs import TextPrompt
|
||||
from vllm.logger import init_logger
|
||||
|
||||
from vllm_omni.data_entry_keys import (
|
||||
CodesStruct,
|
||||
MetaStruct,
|
||||
OmniPayload,
|
||||
OmniPayloadStruct,
|
||||
)
|
||||
from vllm_omni.inputs.data import OmniTokensPrompt
|
||||
from vllm_omni.model_executor.models.mimo_audio.config_mimo_audio import TALKER_CODEC_PAD_TOKEN_ID
|
||||
|
||||
@@ -53,9 +59,12 @@ def prepend_and_flatten_colmajor(x: torch.Tensor, pad_vec: torch.Tensor) -> torc
|
||||
return y_col_major
|
||||
|
||||
|
||||
def _make_finished_sentinel() -> dict[str, Any]:
|
||||
def _make_finished_sentinel() -> OmniPayloadStruct:
|
||||
"""Return a minimal payload with finished=True so Stage-1 can end the request."""
|
||||
return {"codes": {"audio": []}, "meta": {"finished": torch.tensor(True, dtype=torch.bool)}}
|
||||
return OmniPayloadStruct(
|
||||
codes=CodesStruct(audio=torch.empty(0, dtype=torch.long)),
|
||||
meta=MetaStruct(finished=torch.tensor(True, dtype=torch.bool)),
|
||||
)
|
||||
|
||||
|
||||
def _flush_remaining_codes(
|
||||
@@ -63,7 +72,7 @@ def _flush_remaining_codes(
|
||||
request_id: str,
|
||||
chunk_size: int,
|
||||
left_context_size: int,
|
||||
) -> dict[str, Any]:
|
||||
) -> OmniPayloadStruct:
|
||||
"""Flush any accumulated but unsent codes when the request finishes."""
|
||||
accumulated = transfer_manager.code_prompt_token_ids.get(request_id, [])
|
||||
if not accumulated:
|
||||
@@ -76,18 +85,18 @@ def _flush_remaining_codes(
|
||||
|
||||
# Align with qwen3_omni talker2code2wav_async_chunk: decoder strip uses explicit frame count.
|
||||
left_ctx_frames = max(0, min(length - context_length, left_context_size))
|
||||
flat_codes = torch.tensor(accumulated[-end_index:]).reshape(-1).tolist()
|
||||
flat_codes = torch.tensor(accumulated[-end_index:]).reshape(-1)
|
||||
|
||||
return {
|
||||
"codes": {"audio": flat_codes},
|
||||
"meta": {
|
||||
"left_context_size": left_ctx_frames,
|
||||
"codec_chunk_frames": chunk_size,
|
||||
"codec_left_context_frames": left_context_size,
|
||||
"code_flat_numel": len(flat_codes),
|
||||
"finished": torch.tensor(True, dtype=torch.bool),
|
||||
},
|
||||
}
|
||||
return OmniPayloadStruct(
|
||||
codes=CodesStruct(audio=flat_codes),
|
||||
meta=MetaStruct(
|
||||
left_context_size=left_ctx_frames,
|
||||
codec_chunk_frames=chunk_size,
|
||||
codec_left_context_frames=left_context_size,
|
||||
code_flat_numel=int(flat_codes.numel()),
|
||||
finished=torch.tensor(True, dtype=torch.bool),
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
def _is_codes_empty(codes: Any) -> bool:
|
||||
@@ -114,10 +123,10 @@ def _to_code_tensor(codes: Any) -> torch.Tensor | None:
|
||||
|
||||
def llm2code2wav_async_chunk(
|
||||
transfer_manager: Any,
|
||||
pooling_output: dict[str, Any],
|
||||
pooling_output: OmniPayload,
|
||||
request: Any,
|
||||
is_finished: bool = False,
|
||||
) -> dict[str, Any] | None:
|
||||
) -> OmniPayloadStruct | None:
|
||||
"""
|
||||
Async chunk version: convert stage-0 pooling_output to code2wav payload (pooling / connector accumulation).
|
||||
|
||||
@@ -167,18 +176,16 @@ def llm2code2wav_async_chunk(
|
||||
left_ctx_frames = max(0, min(length - context_length, left_context_size))
|
||||
flat_codes = torch.tensor(transfer_manager.code_prompt_token_ids[request_id][-end_index:]).reshape(-1).tolist()
|
||||
|
||||
return {
|
||||
"codes": {
|
||||
"audio": flat_codes,
|
||||
},
|
||||
"meta": {
|
||||
"left_context_size": left_ctx_frames,
|
||||
"codec_chunk_frames": chunk_size,
|
||||
"codec_left_context_frames": left_context_size,
|
||||
"code_flat_numel": len(flat_codes),
|
||||
"finished": torch.tensor(is_finished, dtype=torch.bool),
|
||||
},
|
||||
}
|
||||
return OmniPayloadStruct(
|
||||
codes=CodesStruct(audio=torch.tensor(flat_codes)),
|
||||
meta=MetaStruct(
|
||||
left_context_size=left_ctx_frames,
|
||||
codec_chunk_frames=chunk_size,
|
||||
codec_left_context_frames=left_context_size,
|
||||
code_flat_numel=len(flat_codes),
|
||||
finished=torch.tensor(is_finished, dtype=torch.bool),
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
def llm2code2wav(
|
||||
|
||||
@@ -1,7 +1,14 @@
|
||||
import torch
|
||||
from vllm.inputs import TextPrompt
|
||||
|
||||
from vllm_omni.data_entry_keys import OmniPayload
|
||||
from vllm_omni.data_entry_keys import (
|
||||
EmbeddingsStruct,
|
||||
HiddenStatesStruct,
|
||||
IdsStruct,
|
||||
OmniPayload,
|
||||
OmniPayloadStruct,
|
||||
to_dict,
|
||||
)
|
||||
from vllm_omni.inputs.data import OmniTokensPrompt
|
||||
|
||||
TALKER_CODEC_PAD_TOKEN_ID = 8292
|
||||
@@ -30,17 +37,15 @@ def thinker2talker(
|
||||
mm: OmniPayload = output.multimodal_output
|
||||
latent = mm["latent"]
|
||||
thinker_hidden_states = latent.clone().detach().to(latent.device)
|
||||
additional_information = {
|
||||
"hidden_states": {
|
||||
"output": thinker_hidden_states[prompt_token_ids_len:].to(torch.float32),
|
||||
"output_shape": list(thinker_hidden_states[prompt_token_ids_len:].shape),
|
||||
},
|
||||
"embed": {
|
||||
"prefill": thinker_hidden_states[:prompt_token_ids_len].to(torch.float32),
|
||||
"prefill_shape": list(thinker_hidden_states[:prompt_token_ids_len].shape),
|
||||
},
|
||||
"ids": {"prompt": prompt_token_ids, "output": thinker_output_ids},
|
||||
}
|
||||
decode_hidden = thinker_hidden_states[prompt_token_ids_len:].to(torch.float32)
|
||||
prefill_hidden = thinker_hidden_states[:prompt_token_ids_len].to(torch.float32)
|
||||
additional_information = to_dict(
|
||||
OmniPayloadStruct(
|
||||
hidden_states=HiddenStatesStruct(output=decode_hidden, output_shape=list(decode_hidden.shape)),
|
||||
embed=EmbeddingsStruct(prefill=prefill_hidden, prefill_shape=list(prefill_hidden.shape)),
|
||||
ids=IdsStruct(prompt=list(prompt_token_ids), output=list(thinker_output_ids)),
|
||||
)
|
||||
)
|
||||
talker_inputs.append(
|
||||
OmniTokensPrompt(
|
||||
prompt_token_ids=[TALKER_CODEC_START_TOKEN_ID]
|
||||
|
||||
@@ -11,7 +11,16 @@ import torch
|
||||
from vllm.inputs import TextPrompt
|
||||
from vllm.platforms import current_platform
|
||||
|
||||
from vllm_omni.data_entry_keys import OmniPayload
|
||||
from vllm_omni.data_entry_keys import (
|
||||
CodesStruct,
|
||||
EmbeddingsStruct,
|
||||
HiddenStatesStruct,
|
||||
IdsStruct,
|
||||
MetaStruct,
|
||||
OmniPayload,
|
||||
OmniPayloadStruct,
|
||||
to_dict,
|
||||
)
|
||||
from vllm_omni.engine import OmniEngineCoreRequest
|
||||
from vllm_omni.inputs.data import OmniTokensPrompt
|
||||
from vllm_omni.model_executor.stage_input_processors.tts_utils import (
|
||||
@@ -275,10 +284,10 @@ def _get_streaming_codec_delta_len(
|
||||
|
||||
def thinker2talker_async_chunk(
|
||||
transfer_manager: Any,
|
||||
pooling_output: dict[str, Any],
|
||||
pooling_output: OmniPayload,
|
||||
request: OmniEngineCoreRequest,
|
||||
is_finished: bool = False,
|
||||
) -> list[dict[str, Any]]:
|
||||
) -> OmniPayloadStruct | None:
|
||||
"""
|
||||
Process thinker outputs to create talker inputs.
|
||||
1. thinker's text generation outputs (token IDs + hidden states)
|
||||
@@ -294,7 +303,8 @@ def thinker2talker_async_chunk(
|
||||
|
||||
thinker_hs = pooling_output.get("hidden_states", {})
|
||||
thinker_layers = thinker_hs.get("layers", {}) if isinstance(thinker_hs, dict) else {}
|
||||
thinker_embed = pooling_output.get("embed", {}) if isinstance(pooling_output.get("embed", {}), dict) else {}
|
||||
thinker_embed_raw = pooling_output.get("embed", {})
|
||||
thinker_embed = thinker_embed_raw if isinstance(thinker_embed_raw, dict) else {}
|
||||
thinker_emb = _layer_tensor(thinker_layers, _EMBED_LAYER_KEY)
|
||||
thinker_hid = _layer_tensor(thinker_layers, _HIDDEN_LAYER_KEY)
|
||||
if thinker_emb is None or thinker_hid is None:
|
||||
@@ -305,82 +315,62 @@ def thinker2talker_async_chunk(
|
||||
thinker_hid is not None,
|
||||
)
|
||||
return None
|
||||
speaker = extract_speaker_from_request(request)
|
||||
language = extract_language_from_request(request)
|
||||
|
||||
def _maybe_cpu(t: Any) -> torch.Tensor | None:
|
||||
return t.detach().cpu() if isinstance(t, torch.Tensor) else None
|
||||
|
||||
if chunk_id == 0:
|
||||
all_token_ids = request.all_token_ids # prefill + decode
|
||||
prompt_token_ids = request.prompt_token_ids
|
||||
# Convert ConstantList to regular list for OmniSerializer serialization
|
||||
all_token_ids = _ensure_list(all_token_ids)
|
||||
prompt_token_ids = _ensure_list(prompt_token_ids)
|
||||
payload: OmniPayload = {
|
||||
"embed": {
|
||||
"prefill": thinker_emb.detach().cpu(),
|
||||
# Provide thinker-side TTS token embeddings for talker projection
|
||||
"tts_bos": thinker_embed.get("tts_bos").detach().cpu()
|
||||
if isinstance(thinker_embed.get("tts_bos"), torch.Tensor)
|
||||
else None,
|
||||
"tts_eos": thinker_embed.get("tts_eos").detach().cpu()
|
||||
if isinstance(thinker_embed.get("tts_eos"), torch.Tensor)
|
||||
else None,
|
||||
"tts_pad": thinker_embed.get("tts_pad").detach().cpu()
|
||||
if isinstance(thinker_embed.get("tts_pad"), torch.Tensor)
|
||||
else None,
|
||||
},
|
||||
"hidden_states": {"output": thinker_hid.detach().cpu()},
|
||||
"ids": {"all": all_token_ids, "prompt": prompt_token_ids},
|
||||
"meta": {"finished": torch.tensor(is_finished, dtype=torch.bool)},
|
||||
}
|
||||
talker_additional_info = payload
|
||||
speaker = extract_speaker_from_request(request)
|
||||
if speaker is not None:
|
||||
talker_additional_info["speaker"] = speaker
|
||||
language = extract_language_from_request(request)
|
||||
if language is not None:
|
||||
talker_additional_info["language"] = language
|
||||
all_token_ids = _ensure_list(request.all_token_ids)
|
||||
prompt_token_ids = _ensure_list(request.prompt_token_ids)
|
||||
payload = OmniPayloadStruct(
|
||||
embed=EmbeddingsStruct(
|
||||
prefill=thinker_emb.detach().cpu(),
|
||||
tts_bos=_maybe_cpu(thinker_embed.get("tts_bos")),
|
||||
tts_eos=_maybe_cpu(thinker_embed.get("tts_eos")),
|
||||
tts_pad=_maybe_cpu(thinker_embed.get("tts_pad")),
|
||||
),
|
||||
hidden_states=HiddenStatesStruct(output=thinker_hid.detach().cpu()),
|
||||
ids=IdsStruct(all=all_token_ids, prompt=prompt_token_ids),
|
||||
meta=MetaStruct(finished=torch.tensor(is_finished, dtype=torch.bool)),
|
||||
speaker=speaker,
|
||||
language=language,
|
||||
)
|
||||
if transfer_manager.request_payload.get(request_id) is None:
|
||||
if not is_finished:
|
||||
transfer_manager.request_payload[request_id] = talker_additional_info
|
||||
transfer_manager.request_payload[request_id] = to_dict(payload)
|
||||
return None
|
||||
else:
|
||||
save_payload = transfer_manager.request_payload.pop(request_id)
|
||||
talker_additional_info["embed"]["prefill"] = torch.cat(
|
||||
(
|
||||
save_payload.get("embed", {}).get("prefill"),
|
||||
talker_additional_info.get("embed", {}).get("prefill"),
|
||||
),
|
||||
dim=0,
|
||||
payload.embed.prefill = torch.cat(
|
||||
(save_payload.get("embed", {}).get("prefill"), payload.embed.prefill), dim=0
|
||||
)
|
||||
talker_additional_info["hidden_states"]["output"] = torch.cat(
|
||||
(
|
||||
save_payload.get("hidden_states", {}).get("output"),
|
||||
talker_additional_info.get("hidden_states", {}).get("output"),
|
||||
),
|
||||
dim=0,
|
||||
payload.hidden_states.output = torch.cat(
|
||||
(save_payload.get("hidden_states", {}).get("output"), payload.hidden_states.output), dim=0
|
||||
)
|
||||
else:
|
||||
output_token_ids = request.output_token_ids
|
||||
# Convert ConstantList to regular list for OmniSerializer serialization
|
||||
output_token_ids = _ensure_list(output_token_ids)
|
||||
|
||||
talker_additional_info: OmniPayload = {
|
||||
"meta": {"finished": torch.tensor(is_finished, dtype=torch.bool)},
|
||||
}
|
||||
speaker = extract_speaker_from_request(request)
|
||||
if speaker is not None:
|
||||
talker_additional_info["speaker"] = speaker
|
||||
language = extract_language_from_request(request)
|
||||
if language is not None:
|
||||
talker_additional_info["language"] = language
|
||||
|
||||
output_token_ids = _ensure_list(request.output_token_ids)
|
||||
meta = MetaStruct(finished=torch.tensor(is_finished, dtype=torch.bool))
|
||||
if output_token_ids:
|
||||
talker_additional_info["meta"]["override_keys"] = [("embed", "decode"), ("ids", "output")]
|
||||
talker_additional_info["embed"] = {"decode": thinker_emb.detach().cpu()}
|
||||
talker_additional_info["ids"] = {"output": output_token_ids}
|
||||
meta.override_keys = [("embed", "decode"), ("ids", "output")]
|
||||
payload = OmniPayloadStruct(
|
||||
meta=meta,
|
||||
embed=EmbeddingsStruct(decode=thinker_emb.detach().cpu()),
|
||||
ids=IdsStruct(output=output_token_ids),
|
||||
speaker=speaker,
|
||||
language=language,
|
||||
)
|
||||
else:
|
||||
# When prefilling a chunked thinker, thinker_hidden_states needs to be updated.
|
||||
talker_additional_info["embed"] = {"prefill": thinker_emb.detach().cpu()}
|
||||
talker_additional_info["hidden_states"] = {"output": thinker_hid.detach().cpu()}
|
||||
return talker_additional_info
|
||||
payload = OmniPayloadStruct(
|
||||
meta=meta,
|
||||
embed=EmbeddingsStruct(prefill=thinker_emb.detach().cpu()),
|
||||
hidden_states=HiddenStatesStruct(output=thinker_hid.detach().cpu()),
|
||||
speaker=speaker,
|
||||
language=language,
|
||||
)
|
||||
return payload
|
||||
|
||||
|
||||
def thinker2talker(
|
||||
@@ -459,36 +449,26 @@ def thinker2talker(
|
||||
except Exception as exc:
|
||||
logger.warning("[PD] Could not merge prefill embeddings: %s", exc)
|
||||
|
||||
payload: OmniPayload = {
|
||||
"embed": {
|
||||
"prefill": thinker_emb,
|
||||
"tts_bos": _resolve_tts_token_embedding(
|
||||
payload = OmniPayloadStruct(
|
||||
embed=EmbeddingsStruct(
|
||||
prefill=thinker_emb,
|
||||
tts_bos=_resolve_tts_token_embedding(
|
||||
"tts_bos", thinker_mm=thinker_mm, prefill_mm=prefill_mm, device=device
|
||||
),
|
||||
"tts_eos": _resolve_tts_token_embedding(
|
||||
tts_eos=_resolve_tts_token_embedding(
|
||||
"tts_eos", thinker_mm=thinker_mm, prefill_mm=prefill_mm, device=device
|
||||
),
|
||||
"tts_pad": _resolve_tts_token_embedding(
|
||||
tts_pad=_resolve_tts_token_embedding(
|
||||
"tts_pad", thinker_mm=thinker_mm, prefill_mm=prefill_mm, device=device
|
||||
),
|
||||
},
|
||||
"hidden_states": {
|
||||
"output": thinker_hid,
|
||||
},
|
||||
"ids": {
|
||||
"all": thinker_sequences,
|
||||
"prompt": thinker_input_ids,
|
||||
},
|
||||
}
|
||||
info = payload
|
||||
speaker = extract_speaker_from_prompt(prompt, index=i)
|
||||
if speaker is not None:
|
||||
info["speaker"] = speaker
|
||||
language = extract_language_from_prompt(prompt, index=i)
|
||||
if language is not None:
|
||||
info["language"] = language
|
||||
|
||||
prompt_len = _compute_talker_prompt_ids_length(payload, device=device)
|
||||
),
|
||||
hidden_states=HiddenStatesStruct(output=thinker_hid),
|
||||
ids=IdsStruct(all=thinker_sequences, prompt=thinker_input_ids),
|
||||
speaker=extract_speaker_from_prompt(prompt, index=i),
|
||||
language=extract_language_from_prompt(prompt, index=i),
|
||||
)
|
||||
info = to_dict(payload)
|
||||
prompt_len = _compute_talker_prompt_ids_length(info, device=device)
|
||||
|
||||
talker_inputs.append(
|
||||
OmniTokensPrompt(
|
||||
@@ -509,10 +489,10 @@ def thinker2talker(
|
||||
|
||||
def talker2code2wav_async_chunk(
|
||||
transfer_manager: Any,
|
||||
pooling_output: dict[str, Any],
|
||||
pooling_output: OmniPayload,
|
||||
request: OmniEngineCoreRequest,
|
||||
is_finished: bool = False,
|
||||
):
|
||||
) -> OmniPayloadStruct | None:
|
||||
"""
|
||||
Pooling version.
|
||||
"""
|
||||
@@ -565,17 +545,15 @@ def talker2code2wav_async_chunk(
|
||||
left_context_size = max(0, min(length - context_length, left_context_size_config))
|
||||
end_index = min(length, left_context_size + context_length)
|
||||
|
||||
codes = (
|
||||
torch.tensor(transfer_manager.code_prompt_token_ids[request_id][-end_index:])
|
||||
.transpose(0, 1)
|
||||
.reshape(-1)
|
||||
.tolist()
|
||||
)
|
||||
codes = torch.tensor(transfer_manager.code_prompt_token_ids[request_id][-end_index:]).transpose(0, 1).reshape(-1)
|
||||
|
||||
return {
|
||||
"codes": {"audio": codes},
|
||||
"meta": {"left_context_size": left_context_size, "finished": torch.tensor(is_finished, dtype=torch.bool)},
|
||||
}
|
||||
return OmniPayloadStruct(
|
||||
codes=CodesStruct(audio=codes),
|
||||
meta=MetaStruct(
|
||||
left_context_size=left_context_size,
|
||||
finished=torch.tensor(is_finished, dtype=torch.bool),
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
def talker2code2wav(
|
||||
|
||||
@@ -5,6 +5,13 @@ from typing import Any
|
||||
import torch
|
||||
from vllm.logger import init_logger
|
||||
|
||||
from vllm_omni.data_entry_keys import (
|
||||
CodesStruct,
|
||||
MetaStruct,
|
||||
OmniPayload,
|
||||
OmniPayloadStruct,
|
||||
to_dict,
|
||||
)
|
||||
from vllm_omni.model_executor.stage_input_processors.chunk_size_utils import (
|
||||
compute_dynamic_initial_chunk_size,
|
||||
max_ic_for_chunk_size,
|
||||
@@ -95,18 +102,13 @@ def talker2code2wav(
|
||||
ref_code_len = 0
|
||||
# Code2Wav expects codebook-major flat: [Q*num_frames]
|
||||
codec_codes = audio_codes.transpose(0, 1).cpu().reshape(-1).tolist()
|
||||
additional_information: dict[str, Any] = {}
|
||||
if ref_code_len > 0:
|
||||
additional_information["meta"] = {"left_context_size": [ref_code_len]}
|
||||
# Propagate speaker and language from the original prompt so they are
|
||||
# available as runtime_additional_information in later pipeline stages,
|
||||
# consistent with qwen3-omni and qwen2.5-omni stage input processors.
|
||||
speaker = extract_speaker_from_prompt(prompt, index=i)
|
||||
if speaker is not None:
|
||||
additional_information["speaker"] = speaker
|
||||
language = extract_language_from_prompt(prompt, index=i)
|
||||
if language is not None:
|
||||
additional_information["language"] = language
|
||||
additional_information = to_dict(
|
||||
OmniPayloadStruct(
|
||||
meta=MetaStruct(left_context_size=ref_code_len) if ref_code_len > 0 else None,
|
||||
speaker=extract_speaker_from_prompt(prompt, index=i),
|
||||
language=extract_language_from_prompt(prompt, index=i),
|
||||
)
|
||||
)
|
||||
code2wav_inputs.append(
|
||||
OmniTokensPrompt(
|
||||
prompt_token_ids=codec_codes,
|
||||
@@ -118,7 +120,7 @@ def talker2code2wav(
|
||||
return code2wav_inputs
|
||||
|
||||
|
||||
def _extract_last_frame(pooling_output: dict[str, Any]) -> torch.Tensor | None:
|
||||
def _extract_last_frame(pooling_output: OmniPayload) -> torch.Tensor | None:
|
||||
audio_codes = pooling_output.get("codes", {}).get("audio")
|
||||
if not isinstance(audio_codes, torch.Tensor) or audio_codes.numel() == 0:
|
||||
return None
|
||||
@@ -134,10 +136,10 @@ def _extract_last_frame(pooling_output: dict[str, Any]) -> torch.Tensor | None:
|
||||
|
||||
def talker2code2wav_async_chunk(
|
||||
transfer_manager: Any,
|
||||
pooling_output: dict[str, Any] | None,
|
||||
pooling_output: OmniPayload | None,
|
||||
request: Any,
|
||||
is_finished: bool = False,
|
||||
) -> dict[str, Any] | None:
|
||||
) -> OmniPayloadStruct | None:
|
||||
request_id = request.external_req_id
|
||||
finished = bool(is_finished or request.is_finished())
|
||||
request_payload = getattr(transfer_manager, "request_payload", None)
|
||||
@@ -209,10 +211,10 @@ def talker2code2wav_async_chunk(
|
||||
|
||||
if length <= 0:
|
||||
if finished:
|
||||
return {
|
||||
"codes": {"audio": []},
|
||||
"meta": {"finished": torch.tensor(True, dtype=torch.bool)},
|
||||
}
|
||||
return OmniPayloadStruct(
|
||||
codes=CodesStruct(audio=torch.empty(0, dtype=torch.long)),
|
||||
meta=MetaStruct(finished=torch.tensor(True, dtype=torch.bool)),
|
||||
)
|
||||
return None
|
||||
|
||||
use_first_chunk = initial_chunk_size > 0 and initial_chunk_size < chunk_size
|
||||
@@ -249,19 +251,17 @@ def talker2code2wav_async_chunk(
|
||||
|
||||
num_quantizers = len(window_frames[0])
|
||||
num_frames = len(window_frames)
|
||||
code_predictor_codes = [window_frames[f][q] for q in range(num_quantizers) for f in range(num_frames)]
|
||||
code_predictor_codes = torch.tensor(
|
||||
[window_frames[f][q] for q in range(num_quantizers) for f in range(num_frames)],
|
||||
dtype=torch.long,
|
||||
)
|
||||
|
||||
info: dict[str, Any] = {
|
||||
"codes": {"audio": code_predictor_codes},
|
||||
"meta": {"left_context_size": left_context_size, "finished": torch.tensor(finished, dtype=torch.bool)},
|
||||
}
|
||||
# Propagate speaker and language from the request so they are available
|
||||
# as runtime_additional_information in subsequent pipeline stages, consistent
|
||||
# with qwen3-omni and qwen2.5-omni stage input processors.
|
||||
speaker = extract_speaker_from_request(request)
|
||||
if speaker is not None:
|
||||
info["speaker"] = speaker
|
||||
language = extract_language_from_request(request)
|
||||
if language is not None:
|
||||
info["language"] = language
|
||||
return info
|
||||
return OmniPayloadStruct(
|
||||
codes=CodesStruct(audio=code_predictor_codes),
|
||||
meta=MetaStruct(
|
||||
left_context_size=left_context_size,
|
||||
finished=torch.tensor(finished, dtype=torch.bool),
|
||||
),
|
||||
speaker=extract_speaker_from_request(request),
|
||||
language=extract_language_from_request(request),
|
||||
)
|
||||
@@ -5,6 +5,11 @@ from typing import Any
|
||||
import torch
|
||||
from vllm.inputs import TextPrompt
|
||||
|
||||
from vllm_omni.data_entry_keys import (
|
||||
CodesStruct,
|
||||
MetaStruct,
|
||||
OmniPayloadStruct,
|
||||
)
|
||||
from vllm_omni.inputs.data import OmniTokensPrompt
|
||||
|
||||
_VOXCPM_LATENT_MAGIC = 131071
|
||||
@@ -74,12 +79,19 @@ def latent2vae(
|
||||
return vae_inputs
|
||||
|
||||
|
||||
def _eof_payload() -> OmniPayloadStruct:
|
||||
return OmniPayloadStruct(
|
||||
codes=CodesStruct(audio=torch.empty(0, dtype=torch.long)),
|
||||
meta=MetaStruct(finished=torch.tensor(True, dtype=torch.bool)),
|
||||
)
|
||||
|
||||
|
||||
def latent2vae_async_chunk(
|
||||
transfer_manager: Any,
|
||||
pooling_output: dict[str, Any] | None,
|
||||
request: Any,
|
||||
is_finished: bool = False,
|
||||
) -> dict[str, Any] | None:
|
||||
) -> OmniPayloadStruct | None:
|
||||
"""Stage-0 latent → stage-1 VAE under ``async_chunk`` (connector payload)."""
|
||||
# Kept for callback signature compatibility with OmniChunkTransferAdapter.
|
||||
_ = transfer_manager
|
||||
@@ -87,28 +99,17 @@ def latent2vae_async_chunk(
|
||||
if callable(getattr(request, "is_finished", None)):
|
||||
finished_request = finished_request or _coerce_finished_flag(request.is_finished())
|
||||
if not isinstance(pooling_output, dict):
|
||||
if finished_request:
|
||||
return {
|
||||
"code_predictor_codes": [],
|
||||
"finished": torch.tensor(True, dtype=torch.bool),
|
||||
}
|
||||
return None
|
||||
return _eof_payload() if finished_request else None
|
||||
|
||||
latent = pooling_output.get("latent_audio_feat")
|
||||
if isinstance(latent, torch.Tensor) and latent.numel() == 0:
|
||||
latent = None
|
||||
|
||||
if latent is None:
|
||||
if finished_request:
|
||||
return {
|
||||
"code_predictor_codes": [],
|
||||
"finished": torch.tensor(True, dtype=torch.bool),
|
||||
}
|
||||
return None
|
||||
return _eof_payload() if finished_request else None
|
||||
|
||||
serialized_codes = _serialize_latent_to_codes(latent)
|
||||
out: dict[str, Any] = {
|
||||
"code_predictor_codes": serialized_codes,
|
||||
"finished": torch.tensor(finished_request, dtype=torch.bool),
|
||||
}
|
||||
return out
|
||||
return OmniPayloadStruct(
|
||||
codes=CodesStruct(audio=torch.tensor(serialized_codes, dtype=torch.long)),
|
||||
meta=MetaStruct(finished=torch.tensor(finished_request, dtype=torch.bool)),
|
||||
)
|
||||
@@ -4,6 +4,12 @@ import torch
|
||||
from vllm.inputs import TextPrompt
|
||||
from vllm.logger import init_logger
|
||||
|
||||
from vllm_omni.data_entry_keys import (
|
||||
CodesStruct,
|
||||
MetaStruct,
|
||||
OmniPayload,
|
||||
OmniPayloadStruct,
|
||||
)
|
||||
from vllm_omni.inputs.data import OmniTokensPrompt
|
||||
|
||||
logger = init_logger(__name__)
|
||||
@@ -29,7 +35,7 @@ def generator2tokenizer(
|
||||
return tokenizer_inputs
|
||||
|
||||
|
||||
def _extract_last_frame(pooling_output: dict[str, Any]) -> torch.Tensor | None:
|
||||
def _extract_last_frame(pooling_output: OmniPayload) -> torch.Tensor | None:
|
||||
audio = pooling_output.get("audio")
|
||||
if not isinstance(audio, torch.Tensor) or audio.numel() == 0:
|
||||
return None
|
||||
@@ -38,10 +44,10 @@ def _extract_last_frame(pooling_output: dict[str, Any]) -> torch.Tensor | None:
|
||||
|
||||
def generator2tokenizer_async_chunk(
|
||||
transfer_manager: Any,
|
||||
pooling_output: dict[str, Any],
|
||||
pooling_output: OmniPayload,
|
||||
request: Any,
|
||||
is_finished: bool = False,
|
||||
) -> dict[str, Any] | None:
|
||||
) -> OmniPayloadStruct | None:
|
||||
request_id = request.external_req_id
|
||||
finished = bool(is_finished or request.is_finished())
|
||||
|
||||
@@ -71,10 +77,10 @@ def generator2tokenizer_async_chunk(
|
||||
# finished and nothing was produced, emit an EOF marker.
|
||||
if length <= 0:
|
||||
if finished:
|
||||
return {
|
||||
"codes": {"audio": []},
|
||||
"meta": {"finished": torch.tensor(True, dtype=torch.bool)},
|
||||
}
|
||||
return OmniPayloadStruct(
|
||||
codes=CodesStruct(audio=torch.empty(0, dtype=torch.long)),
|
||||
meta=MetaStruct(finished=torch.tensor(True, dtype=torch.bool)),
|
||||
)
|
||||
return None
|
||||
|
||||
# Use a small chunk size at begin
|
||||
@@ -94,7 +100,12 @@ def generator2tokenizer_async_chunk(
|
||||
# Pack context + chunk into codebook-major flat codes for adapter.
|
||||
code_predictor_codes = torch.tensor(window_frames).reshape(-1).tolist()
|
||||
|
||||
return {
|
||||
"codes": {"audio": [int(ctx_frames)] + [int(context_length)] + code_predictor_codes},
|
||||
"meta": {"finished": torch.tensor(finished, dtype=torch.bool)},
|
||||
}
|
||||
return OmniPayloadStruct(
|
||||
codes=CodesStruct(
|
||||
audio=torch.tensor(
|
||||
[int(ctx_frames), int(context_length)] + code_predictor_codes,
|
||||
dtype=torch.long,
|
||||
),
|
||||
),
|
||||
meta=MetaStruct(finished=torch.tensor(finished, dtype=torch.bool)),
|
||||
)
|
||||
Reference in new issue
Block a user