From 09a22c75dc622d199ed35102a12f3ac88f10cef9 Mon Sep 17 00:00:00 2001 From: secretzer0 Date: Sat, 15 Aug 2026 22:07:08 -0500 Subject: [PATCH] Fix GPU memory leak in voice conditioning cache Wrap generation in torch.inference_mode so cached conds do not retain autograd graphs (~200 MB per voice). --- engine.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/engine.py b/engine.py index a2be1e9..1a4407b 100644 --- a/engine.py +++ b/engine.py @@ -487,7 +487,7 @@ def synthesize( # Call the core model's generate method. # autocast promotes float32 inputs to bfloat16 to match T3/S3Gen weights, # keeping numerically sensitive ops (softmax, norms) in float32 automatically. - with torch.autocast("cuda", dtype=torch.bfloat16, enabled=BF16_ENABLED): + with torch.inference_mode(), torch.autocast("cuda", dtype=torch.bfloat16, enabled=BF16_ENABLED): if loaded_model_type == "multilingual": wav_tensor = chatterbox_model.generate( text=text,