mirror of
https://github.com/vladmandic/automatic
synced 2026-09-19 09:14:35 +02:00
fix(lora): restore native weights when LoRA removed on diffusers-path models
Flux2/Klein loads LoRAs as native modules through the diffusers method path. network_activate() was only called when new native modules existed, so removing a LoRA from the prompt left backed-up weights unrestored. Check applied_layers to detect previously active native modules and trigger network_activate() for the restore path.
This commit is contained in:
@@ -339,9 +339,11 @@ def network_load(names, te_multipliers=None, unet_multipliers=None, dyn_dims=Non
|
||||
shared.sd_model = sd_models.apply_balanced_offload(shared.sd_model, force=True, silent=True) # some layers may end up on cpu without hook
|
||||
|
||||
# Activate native modules loaded via diffusers path (e.g., LoKR on Flux2)
|
||||
# Also restore backed-up weights when previously active native modules are removed
|
||||
from modules.lora import networks
|
||||
native_nets = [net for net in l.loaded_networks if len(net.modules) > 0]
|
||||
if native_nets:
|
||||
from modules.lora import networks
|
||||
had_native = len(networks.applied_layers) > 0
|
||||
if native_nets or had_native:
|
||||
networks.network_activate()
|
||||
|
||||
if len(l.loaded_networks) > 0 and l.debug:
|
||||
|
||||
Reference in New Issue
Block a user