From a028b56687ce23d93c0fe22c2cafa896c108585d Mon Sep 17 00:00:00 2001 From: CalamitousFelicitousness Date: Wed, 29 Apr 2026 02:00:33 +0100 Subject: [PATCH] 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. --- modules/lora/lora_load.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/modules/lora/lora_load.py b/modules/lora/lora_load.py index 19a36e4f9..f9cea425d 100644 --- a/modules/lora/lora_load.py +++ b/modules/lora/lora_load.py @@ -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: