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

* Call unpatch_hooks at the start of ModelPatcher.partially_unload

* Only call unpatch_hooks in partially_unload if lowvram is possible
This commit is contained in:
Jedrzej Kosinski 2025-03-16 05:02:45 -05:00 committed by GitHub
parent fd5297131f
commit 2e24a15905
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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: