[Model] Add opt-in packed Flow and batched HiFT inference for CosyVoice3 (#8224)

Signed-off-by: Sy03 <1370724210@qq.com>
Signed-off-by: zack <huixindaddy@yahoo.com>
Co-authored-by: zack <huixindaddy@yahoo.com>
This commit is contained in:
Sy03andzack authored and GitHub committed 2026-09-29 15:48:36 +00:00
1 parent c85f1a44fb
commit 1ea0ee3b38
28 files changed
+4009 -223

No files matched your search

@@ -29,3 +29,38 @@ def cosyvoice3_batch_flow_profile(name: str):
if cosyvoice3_batch_flow_debug():
return torch.profiler.record_function(name)
return nullcontext()
def cosyvoice3_full_response_enabled() -> bool:
"""Opt-in Hopper full-response path; other devices retain the standard path."""
return (
_env_flag("COSYVOICE3_FULL_RESPONSE_OPTIMIZATIONS", "0")
and torch.cuda.is_available()
and torch.cuda.get_device_capability()[0] == 9
)
def cosyvoice3_packed_streaming_enabled() -> bool:
"""Opt-in Hopper packed, chunk-causal Flow with request-owned GPU HiFT state."""
return (
_env_flag("COSYVOICE3_PACKED_STREAMING", "0")
and torch.cuda.is_available()
and torch.cuda.get_device_capability()[0] == 9
)
def cosyvoice3_packed_inference_enabled() -> bool:
"""Either optimized profile needs live conditioning outside CUDA graphs."""
return cosyvoice3_full_response_enabled() or cosyvoice3_packed_streaming_enabled()
def cosyvoice3_standard_sampling(config: object) -> bool:
"""Select ordinary sampling; RAS remains the default checkpoint behavior.
The optional HF override is shared by API stop configuration and the model
sampler. Reject misspellings instead of silently selecting another policy.
"""
mode = getattr(config, "cosyvoice3_sampling_mode", "ras")
if mode not in ("ras", "standard"):
raise ValueError("cosyvoice3_sampling_mode must be 'ras' or 'standard'")
return mode == "standard"