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.

Call unpatch_hooks at the start of ModelPatcher.partially_unload (#7253)

Jedrzej Kosinski2e24a1590512
diff --git a/comfy/model_patcher.py b/comfy/model_patcher.py
index e291158ce..b7cb12dfc 100644
--- a/comfy/model_patcher.py
+++ b/comfy/model_patcher.py
@@ -747,6 +747,7 @@ class ModelPatcher:
def partially_unload(self, device_to, memory_to_free=0):
with self.use_ejected():
+ hooks_unpatched = False
memory_freed = 0
patch_counter = 0
unload_list = self._load_list()
@@ -770,6 +771,10 @@ class ModelPatcher:
move_weight = False
break
+ if not hooks_unpatched:
+ self.unpatch_hooks()
+ hooks_unpatched = True
+
if bk.inplace_update:
comfy.utils.copy_to_param(self.model, key, bk.weight)
else: