The most powerful and modular diffusion model GUI, api and backend with a graph/nodes interface. The fastest local inference engine in the world.
mm/mp: always unload re-used but modified models (#10724)
rattus18e7d6dba5f1
diff --git a/comfy/model_management.py b/comfy/model_management.pyindex d8913082a..a21df54b3 100644--- a/comfy/model_management.py+++ b/comfy/model_management.py@@ -503,10 +503,7 @@ class LoadedModel:use_more_vram = lowvram_model_memoryif use_more_vram == 0:use_more_vram = 1e32- if use_more_vram > 0:- self.model_use_more_vram(use_more_vram, force_patch_weights=force_patch_weights)- else:- self.model.partially_unload(self.model.offload_device, -use_more_vram, force_patch_weights=force_patch_weights)+ self.model_use_more_vram(use_more_vram, force_patch_weights=force_patch_weights)real_model = self.model.modeldiff --git a/comfy/model_patcher.py b/comfy/model_patcher.pyindex 68b0a9192..cf1b0d441 100644--- a/comfy/model_patcher.py+++ b/comfy/model_patcher.py@@ -928,6 +928,9 @@ class ModelPatcher:extra_memory += (used - self.model.model_loaded_weight_memory)self.patch_model(load_weights=False)+ if extra_memory < 0 and not unpatch_weights:+ self.partially_unload(self.offload_device, -extra_memory, force_patch_weights=force_patch_weights)+ return 0full_load = Falseif self.model.model_lowvram == False and self.model.model_loaded_weight_memory > 0:self.apply_hooks(self.forced_hooks, force_apply=True)