mirror of
https://github.com/vladmandic/automatic
synced 2026-09-10 06:48:43 +02:00
fix(lora): use native_active flag instead of applied_layers for restore trigger
applied_layers is cleared and re-populated on every network_activate call. With lora_apply_te=True the second activate (TE-only pass) finds all modules already at the target state and skips them all, leaving applied_layers empty and breaking the restore trigger on the next gen. native_active is set from loaded_networks at the end of activate, so it survives idempotent re-runs and only flips false after the restore call clears loaded_networks.
This commit is contained in:
@@ -342,8 +342,7 @@ def network_load(names, te_multipliers=None, unet_multipliers=None, dyn_dims=Non
|
||||
# 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]
|
||||
had_native = len(networks.applied_layers) > 0
|
||||
if native_nets or had_native:
|
||||
if native_nets or networks.native_active:
|
||||
networks.network_activate()
|
||||
|
||||
if len(l.loaded_networks) > 0 and l.debug:
|
||||
|
||||
@@ -9,6 +9,7 @@ from modules.logger import log, console
|
||||
|
||||
|
||||
applied_layers: list[str] = []
|
||||
native_active: bool = False
|
||||
default_components = ['text_encoder', 'text_encoder_2', 'text_encoder_3', 'text_encoder_4', 'unet', 'transformer', 'transformer_2', 'llm_adapter']
|
||||
|
||||
|
||||
@@ -74,6 +75,8 @@ def network_activate(include=None, exclude=None):
|
||||
|
||||
if task is not None and len(applied_layers) == 0:
|
||||
pbar.remove_task(task) # hide progress bar for no action
|
||||
global native_active # pylint: disable=global-statement
|
||||
native_active = len(l.loaded_networks) > 0
|
||||
l.timer.activate += time.time() - t0
|
||||
if l.debug and len(l.loaded_networks) > 0:
|
||||
log.debug(f'Network load: type=LoRA networks={[n.name for n in l.loaded_networks]} modules={active_components} layers={total} weights={applied_weight} bias={applied_bias} backup={round(backup_size/1024/1024/1024, 2)} fuse={shared.opts.lora_fuse_native}:{shared.opts.lora_fuse_diffusers} device={device} time={l.timer.summary}')
|
||||
|
||||
Reference in New Issue
Block a user