[Perf] release unused Code2Wav stream caches (#6100)

Signed-off-by: natureofnature <wzliu@connect.hku.hk>
This commit is contained in:
NATURE authored and GitHub committed 2026-08-12 18:43:40 +08:00
1 parent b4cc0d6da6
commit 49977ce7a3
2 files changed
+30

No files matched your search

@@ -65,6 +65,14 @@ class BatchedToken2Wav(nn.Module):
self._token2wav = token2wav
self.flow = token2wav.flow
self.hift = token2wav.hift
# The upstream streaming path preallocates fixed-size CFM and DiT
# caches. This adapter never calls that path and supplies dynamically
# sized request-owned buffers to ``blocks_forward_chunk`` instead.
decoder = self.flow.decoder
for module in (decoder, decoder.estimator):
for buffer_name in ("att_cache_buffer", "cnn_cache_buffer"):
if buffer_name in module._buffers:
setattr(module, buffer_name, None)
hift_parameter = next(self.hift.parameters(), None)
if hift_parameter is not None and hift_parameter.device.type == "cuda":
# Prime the CUDA state used by HiFT during backend construction.