afb3242eca
torch.enable_grad() alone is insufficient: operations on inference tensors (created inside ComfyUI's outer inference_mode context) produce inference tensors even inside enable_grad, breaking autograd. inference_mode(False) exits the inference context so the deepcopy, apply_lora, and training loop run with a fully clean autograd context. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>