505d445eb3
ComfyUI executes all nodes inside torch.no_grad(), which prevents gradient tracking and makes loss.backward() fail. torch.enable_grad() overrides it. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>