Skip to content

The most powerful and modular diffusion model GUI, api and backend with a graph/nodes interface. The fastest local inference engine in the world.

Disable gradients on diffusion models. (#15218)

comfyanonymous532a16f3b955
diff --git a/comfy/model_base.py b/comfy/model_base.py
index ee6dc57a2..7c68c6eba 100644
--- a/comfy/model_base.py
+++ b/comfy/model_base.py
@@ -169,6 +169,7 @@ class BaseModel(torch.nn.Module):
else:
operations = model_config.custom_operations
self.diffusion_model = unet_model(**unet_config, device=device, operations=operations)
+ self.diffusion_model.requires_grad_(False)
self.diffusion_model.eval()
if comfy.model_management.force_channels_last():
self.diffusion_model.to(memory_format=torch.channels_last)