From e8659c87acf3fccf15070d8032c4f7e835d0fa4c Mon Sep 17 00:00:00 2001 From: CalamitousFelicitousness Date: Sun, 30 Aug 2026 05:01:16 +0100 Subject: [PATCH] fix(lora): record how the pass left the weights The mode shown in the load and unload lines was derived at print time from the live fuse setting, so a set applied under one setting was reported under whatever the setting said later, and the unload line described the pass that was about to replace it rather than the one being removed. The pass records the mode it actually used. last_backup_size was created on lora_common by assignment from networks.py and read back through a getattr default; both fields are declared where they live now. --- modules/lora/lora_common.py | 2 ++ modules/lora/networks.py | 16 ++++++++++------ 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/modules/lora/lora_common.py b/modules/lora/lora_common.py index 8fc5532a5..51d70fdbf 100644 --- a/modules/lora/lora_common.py +++ b/modules/lora/lora_common.py @@ -19,3 +19,5 @@ module_types = [ loaded_networks: list = [] # no type due to circular import previously_loaded_networks: list = [] # no type due to circular import extra_network_lora = None # initialized in extra_networks.py +last_backup_size: int = 0 # bytes of weight backups the last activate pass held +last_mode: str = '' # how that pass left the weights: backup, fuse or factor diff --git a/modules/lora/networks.py b/modules/lora/networks.py index 2d78b72e0..cb65edddc 100644 --- a/modules/lora/networks.py +++ b/modules/lora/networks.py @@ -288,6 +288,7 @@ def finish_pass(ctx, t0): native_active = len(l.loaded_networks) > 0 refused_writes = ctx.refused l.last_backup_size = ctx.backup_size + l.last_mode = 'backup' if ctx.backup_size > 0 else ('fuse' if ctx.fuse else 'factor') l.timer.activate += time.time() - t0 if ctx.refused > 0: log.error(f'Network load: type=LoRA networks={[n.name for n in l.loaded_networks]} weights={ctx.applied_weight} bias={ctx.applied_bias} refused={ctx.refused} network partially applied') @@ -342,12 +343,15 @@ def network_activate(include=None, exclude=None): def effective_mode(): - """Weight-state label for load logs: backup and fuse say how touched weights restore, factor means the whole load rode the svd channel and unload just drops factors.""" - if getattr(l, 'last_backup_size', 0) > 0: - return 'backup' - if lora_overrides.fuse_native(): - return 'fuse' - return 'factor' + """Weight-state label for load logs: backup and fuse say how touched weights restore, factor means the whole load rode the svd channel and unload just drops factors. + + Recorded by the pass rather than derived here, so the unload line + describes the pass being unloaded even when the settings it ran under + have since changed. + """ + if l.last_mode: + return l.last_mode + return 'fuse' if lora_overrides.fuse_native() else 'factor' def network_deactivate(include=None, exclude=None):