[Core] Defer generation payload host waits to output consumption (#8540)

Signed-off-by: amy-why-3459 <wuhaiyan17@huawei.com>
This commit is contained in:
amy-why-3459 authored and GitHub committed 2026-10-07 17:20:54 +08:00
1 parent d5a3380103
commit de253412b0
8 files changed
+350 -11

No files matched your search

@@ -744,6 +744,13 @@ class CosyVoice3Model(
prefer_model_sampler = True
_sampling_eps = 1e-5
@property
def owns_generation_output_storage(self) -> bool:
"""Expose the codec's ownership contract on the model seen by the runner."""
return self.model_stage == "cosyvoice3_code2wav" and (
getattr(self.code2wav, "owns_generation_output_storage", False) is True
)
@property
def logits_vocab_size(self) -> int | None:
"""Width of the logits ``compute_logits`` returns (the speech head).
@@ -92,6 +92,11 @@ class CosyVoice3Code2Wav(nn.Module):
- HiFiGAN vocoder for mel-to-waveform conversion
"""
# Returned CUDA payloads own their storage (including HiFT graph results).
# Subsequent forwards/state updates never mutate it; the runner can retain
# the tensors and copy to host without taking another device snapshot.
owns_generation_output_storage = True
def __init__(self, config: CosyVoice3Config):
super().__init__()
self.config = config
@@ -270,6 +270,11 @@ class MiniCPMO45Code2Wav(nn.Module):
has_preprocess = False
has_postprocess = False
# Returned CUDA payloads own their storage (including HiFT graph results).
# Subsequent forwards/state updates never mutate it; the runner can retain
# the tensors and copy to host without taking another device snapshot.
owns_generation_output_storage = True
def __init__(
self,
*,