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.

get_key_patches now works without unloading the model.

comfyanonymous0849c80e2ab5
diff --git a/comfy/model_patcher.py b/comfy/model_patcher.py
index a89ad4fd7..6ca124e6d 100644
--- a/comfy/model_patcher.py
+++ b/comfy/model_patcher.py
@@ -283,17 +283,21 @@ class ModelPatcher:
return list(p)
def get_key_patches(self, filter_prefix=None):
- comfy.model_management.unload_model_clones(self)
model_sd = self.model_state_dict()
p = {}
for k in model_sd:
if filter_prefix is not None:
if not k.startswith(filter_prefix):
continue
+ bk = self.backup.get(k, None)
+ if bk is not None:
+ weight = bk.weight
+ else:
+ weight = model_sd[k]
if k in self.patches:
- p[k] = [model_sd[k]] + self.patches[k]
+ p[k] = [weight] + self.patches[k]
else:
- p[k] = (model_sd[k],)
+ p[k] = (weight,)
return p
def model_state_dict(self, filter_prefix=None):