mirror of
https://github.com/vladmandic/automatic
synced 2026-09-20 01:31:13 +02:00
fix(lora): accept lowercase lora_a and lora_b factor names
TaoLive adapters save the factors as lora_a and lora_b without the .weight suffix, which no suffix table knew, so the file bound nothing.
This commit is contained in:
@@ -94,6 +94,8 @@ SUFFIX_NORMALIZE = {
|
||||
"lora_B.weight": "lora_up.weight",
|
||||
# bare parameter names, saved by wrappers that hold the factors as nn.Parameter (alibaba-pai PDD files)
|
||||
"lora_down": "lora_down.weight",
|
||||
"lora_a": "lora_down.weight",
|
||||
"lora_b": "lora_up.weight",
|
||||
"lora_up": "lora_up.weight",
|
||||
}
|
||||
|
||||
@@ -107,6 +109,7 @@ LORA_SUFFIXES = (
|
||||
".lora_down.weight", ".lora_up.weight", ".lora_mid.weight",
|
||||
".lora_A.weight", ".lora_B.weight",
|
||||
".lora_down", ".lora_up",
|
||||
".lora_a", ".lora_b", # lowercase peft factor names without .weight (TaoLive adapters)
|
||||
# diff_b: bias delta some saves pair with the weight LoRA, applied as ex_bias.
|
||||
# magnitude / lora_magnitude_vector: DoRA row norms (ai-toolkit / PEFT key
|
||||
# names); converted onto the dora_scale path by try_load_lora.
|
||||
@@ -158,7 +161,7 @@ FULL_SUFFIXES = (
|
||||
# on accidental overlaps with other families.
|
||||
|
||||
LORA_MARKERS = (
|
||||
".lora_down", ".lora_up", # bare and .weight forms alike
|
||||
".lora_down", ".lora_up", ".lora_a", ".lora_b", # bare and .weight forms alike
|
||||
".lora_A.weight", ".lora_B.weight",
|
||||
# PEFT named-adapter saves embed the slot name as ``.lora_A.<name>.weight``;
|
||||
# the trailing-dot forms catch every variant.
|
||||
|
||||
@@ -390,6 +390,7 @@ def oracle_mapping(state_dict, network_alpha=None):
|
||||
"""
|
||||
if any(k.startswith(REFERENCE_PREFIXES) for k in state_dict):
|
||||
sd = {k.replace('base_model.model.dit.', 'diffusion_model.', 1) if k.startswith('base_model.model.dit.') else k: v for k, v in state_dict.items()}
|
||||
sd = {k[:-len('.lora_a')] + ('.lora_A.weight' if k.endswith('.lora_a') else '.lora_B.weight') if k.endswith(('.lora_a', '.lora_b')) else k: v for k, v in sd.items()} # lowercase peft names the converter does not read
|
||||
converted = convert_diffusers(sd)
|
||||
out = {}
|
||||
for key, value in converted.items():
|
||||
|
||||
Reference in New Issue
Block a user