Fix UnboundLocalError: move torch._dynamo import to module level
All checks were successful
Build ROCm Image / build (push) Successful in 2m39s
All checks were successful
Build ROCm Image / build (push) Successful in 2m39s
import inside a function creates a local binding that shadows the module-level torch import, breaking all earlier torch references in the same function scope. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import logging
|
||||
import time
|
||||
import torch
|
||||
import torch._dynamo
|
||||
from typing import Optional, Tuple
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
@@ -52,7 +53,6 @@ def load_model() -> bool:
|
||||
# s3gen (HiFiGAN vocoder + flow matching) since that's the bottleneck.
|
||||
# suppress_errors=True falls back to eager for any op compile can't handle.
|
||||
try:
|
||||
import torch._dynamo
|
||||
torch._dynamo.config.suppress_errors = True
|
||||
chatterbox_model.s3gen = torch.compile(chatterbox_model.s3gen, dynamic=True)
|
||||
logger.info("s3gen compiled with torch.compile")
|
||||
|
||||
Reference in New Issue
Block a user