mirror of
https://github.com/vladmandic/automatic
synced 2026-09-18 16:54:33 +02:00
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.
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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):
|
||||
|
||||
Reference in New Issue
Block a user