mirror of
https://github.com/comfyanonymous/ComfyUI.git
synced 2026-03-22 01:23:43 +08:00
Merge f1f4f545f4 into 0904cc3fe5
This commit is contained in:
commit
bac47130e4
@ -726,8 +726,12 @@ class ModelPatcher:
|
|||||||
self.pinned.remove(key)
|
self.pinned.remove(key)
|
||||||
|
|
||||||
def unpin_all_weights(self):
|
def unpin_all_weights(self):
|
||||||
for key in list(self.pinned):
|
if hasattr(self, 'pinned'): # Safety check
|
||||||
self.unpin_weight(key)
|
for key in list(self.pinned):
|
||||||
|
self.unpin_weight(key)
|
||||||
|
else:
|
||||||
|
# Log or skip: self.pinned was not set
|
||||||
|
pass
|
||||||
|
|
||||||
def _load_list(self, for_dynamic=False, default_device=None):
|
def _load_list(self, for_dynamic=False, default_device=None):
|
||||||
loading = []
|
loading = []
|
||||||
@ -1463,8 +1467,14 @@ class ModelPatcher:
|
|||||||
return self.model.state_dict_for_saving(unet_state_dict, clip_state_dict=clip_state_dict, vae_state_dict=vae_state_dict, clip_vision_state_dict=clip_vision_state_dict)
|
return self.model.state_dict_for_saving(unet_state_dict, clip_state_dict=clip_state_dict, vae_state_dict=vae_state_dict, clip_vision_state_dict=clip_vision_state_dict)
|
||||||
|
|
||||||
def __del__(self):
|
def __del__(self):
|
||||||
self.unpin_all_weights()
|
try:
|
||||||
self.detach(unpatch_all=False)
|
if hasattr(self, 'pinned'):
|
||||||
|
self.unpin_all_weights()
|
||||||
|
self.detach(unpatch_all=False)
|
||||||
|
except Exception as e:
|
||||||
|
# Suppress errors in destructor to avoid noise
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
class ModelPatcherDynamic(ModelPatcher):
|
class ModelPatcherDynamic(ModelPatcher):
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user