fix(bigvgan-trainer): clone vocoder parameters to strip inference tensor flag
The vocoder is loaded inside ComfyUI's torch.inference_mode(), making all its parameters inference tensors. Autograd cannot save inference tensors for backward even with requires_grad=True. Clone all parameters inside torch.inference_mode(False) before training to get normal tensors. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -222,6 +222,12 @@ class SelvaBigvganTrainer:
|
||||
try:
|
||||
with torch.inference_mode(False):
|
||||
with torch.enable_grad():
|
||||
# Vocoder parameters were loaded inside ComfyUI's inference_mode()
|
||||
# and are inference tensors. Autograd cannot save them for backward.
|
||||
# Clone inside inference_mode(False) to get normal tensors.
|
||||
for param in vocoder.parameters():
|
||||
param.data = param.data.clone()
|
||||
|
||||
vocoder.train()
|
||||
|
||||
for step in range(steps):
|
||||
|
||||
Reference in New Issue
Block a user