[Model][Core] Avoid unused CosyVoice3 payloads and redundant AR output work (#8473)
Signed-off-by: Sorbett <sorbet111@163.com>
This commit is contained in:
1 parent
5ca23106fd
commit
1f47fa2f29
9 files changed
+525
-73
No files matched your search
@@ -11,7 +11,7 @@ from __future__ import annotations
|
||||
|
||||
import gc
|
||||
import threading
|
||||
from collections.abc import Callable, Sequence
|
||||
from collections.abc import Callable, Mapping, Sequence
|
||||
from contextlib import nullcontext
|
||||
from copy import copy
|
||||
from dataclasses import replace
|
||||
@@ -1596,10 +1596,12 @@ class GPUARModelRunner(OmniGPUModelRunner, OmniConnectorModelRunnerMixin, Duplex
|
||||
return None
|
||||
return wire_payloads
|
||||
|
||||
def _snapshot_query_start_loc_cpu(self) -> Any:
|
||||
def _get_query_start_loc_cpu(self, *, snapshot: bool) -> Any:
|
||||
query_start_loc_cpu = self.query_start_loc.cpu
|
||||
if callable(query_start_loc_cpu):
|
||||
query_start_loc_cpu = query_start_loc_cpu()
|
||||
if not snapshot:
|
||||
return query_start_loc_cpu
|
||||
if isinstance(query_start_loc_cpu, torch.Tensor):
|
||||
return query_start_loc_cpu.detach().cpu().clone()
|
||||
if isinstance(query_start_loc_cpu, np.ndarray):
|
||||
@@ -1888,7 +1890,18 @@ class GPUARModelRunner(OmniGPUModelRunner, OmniConnectorModelRunnerMixin, Duplex
|
||||
# OmniModelRunnerOutput.pooler_output (which is set to None below).
|
||||
# The actual multimodal wire transport uses multimodal_outputs instead.
|
||||
pooler_output: list[dict[str, object]] | None = None
|
||||
if needs_pooler_payload:
|
||||
# Token-only steps have no pooler payload to construct. Keep the full
|
||||
# path for cached payloads and model postprocess, even without MM input.
|
||||
has_mm_payload = multimodal_outputs is not None and (
|
||||
not isinstance(multimodal_outputs, Mapping) or len(multimodal_outputs) > 0
|
||||
)
|
||||
needs_payload_work = (
|
||||
include_hidden_payload
|
||||
or has_mm_payload
|
||||
or self.omni_prefix_cache is not None
|
||||
or (not postprocess_already_applied and self._runner_model_omni_flag("has_postprocess"))
|
||||
)
|
||||
if needs_pooler_payload and needs_payload_work:
|
||||
hidden_seq_len = int(hidden_states.shape[0])
|
||||
scheduled_seq_len = int(scheduler_output.total_num_scheduled_tokens)
|
||||
mm_cpu = None
|
||||
@@ -2186,6 +2199,7 @@ class GPUARModelRunner(OmniGPUModelRunner, OmniConnectorModelRunnerMixin, Duplex
|
||||
kv_connector_output = self.kv_connector_output
|
||||
self.kv_connector_output = None
|
||||
|
||||
use_async_omni_output = self._should_use_async_omni_output()
|
||||
num_scheduled_tokens_np = getattr(self, "_omni_num_scheduled_tokens_np", None)
|
||||
if num_scheduled_tokens_np is None:
|
||||
num_scheduled_tokens_np = np.array(
|
||||
@@ -2193,20 +2207,29 @@ class GPUARModelRunner(OmniGPUModelRunner, OmniConnectorModelRunnerMixin, Duplex
|
||||
dtype=np.int32,
|
||||
)
|
||||
else:
|
||||
num_scheduled_tokens_np = np.asarray(num_scheduled_tokens_np, dtype=np.int32).copy()
|
||||
num_scheduled_tokens_np = np.asarray(num_scheduled_tokens_np, dtype=np.int32)
|
||||
if use_async_omni_output:
|
||||
num_scheduled_tokens_np = num_scheduled_tokens_np.copy()
|
||||
|
||||
query_start_loc_cpu = self._snapshot_query_start_loc_cpu()
|
||||
scheduler_output_snapshot = self._snapshot_scheduler_output_for_async_omni_output(scheduler_output)
|
||||
req_ids_output_snapshot = list(req_ids_output_copy)
|
||||
req_id_to_index_output_snapshot = dict(req_id_to_index_output_copy)
|
||||
valid_sampled_token_ids_snapshot = [list(token_ids) for token_ids in valid_sampled_token_ids]
|
||||
logprobs_lists_snapshot = copy(logprobs_lists) if logprobs_lists is not None else None
|
||||
prompt_logprobs_dict_snapshot = dict(prompt_logprobs_dict) if prompt_logprobs_dict is not None else {}
|
||||
num_nans_in_logits_snapshot = (
|
||||
dict(num_nans_in_logits) if isinstance(num_nans_in_logits, dict) else num_nans_in_logits
|
||||
)
|
||||
|
||||
use_async_omni_output = self._should_use_async_omni_output()
|
||||
# Inline materialization finishes before the next execute_model can
|
||||
# mutate step metadata. Only the background builder needs snapshots.
|
||||
query_start_loc_cpu = self._get_query_start_loc_cpu(snapshot=use_async_omni_output)
|
||||
scheduler_output_snapshot = scheduler_output
|
||||
valid_sampled_token_ids_snapshot = valid_sampled_token_ids
|
||||
logprobs_lists_snapshot = logprobs_lists
|
||||
prompt_logprobs_dict_snapshot = prompt_logprobs_dict
|
||||
num_nans_in_logits_snapshot = num_nans_in_logits
|
||||
if use_async_omni_output:
|
||||
scheduler_output_snapshot = self._snapshot_scheduler_output_for_async_omni_output(scheduler_output)
|
||||
valid_sampled_token_ids_snapshot = [list(token_ids) for token_ids in valid_sampled_token_ids]
|
||||
logprobs_lists_snapshot = copy(logprobs_lists) if logprobs_lists is not None else None
|
||||
prompt_logprobs_dict_snapshot = dict(prompt_logprobs_dict) if prompt_logprobs_dict is not None else {}
|
||||
num_nans_in_logits_snapshot = (
|
||||
dict(num_nans_in_logits) if isinstance(num_nans_in_logits, dict) else num_nans_in_logits
|
||||
)
|
||||
# _bookkeeping_sync already detached these from the mutable input batch.
|
||||
req_ids_output_snapshot = req_ids_output_copy
|
||||
req_id_to_index_output_snapshot = req_id_to_index_output_copy
|
||||
omni_postprocess_already_applied = False
|
||||
if use_async_omni_output:
|
||||
omni_postprocess_already_applied = self._maybe_run_eager_omni_postprocess_before_async_output(
|
||||
|
||||
Reference in new issue
Block a user