backup only for needed weights required by lora

This commit is contained in:
Won-Kyu Park 2024-10-03 19:42:55 +09:00
parent 2a1988fa67
commit 412401becb
No known key found for this signature in database
GPG Key ID: 53AA79C8C9535D15

View File

@ -429,6 +429,18 @@ def network_backup_weights(self):
current_names = getattr(self, "network_current_names", ())
wanted_names = tuple((x.name, x.te_multiplier, x.unet_multiplier, x.dyn_dim) for x in loaded_networks)
need_backup = False
for net in loaded_networks:
if network_layer_name in net.modules:
need_backup = True
break
elif network_layer_name + "_q_proj" in net.modules:
need_backup = True
break
if not need_backup:
return
weights_backup = getattr(self, "network_weights_backup", None)
if weights_backup is None and wanted_names != ():
if current_names != () and not allowed_layer_without_weight(self):