Skip to content

Commit 16c274b

Browse files
Fix fuse_qkv only applying to BFL-format LoKR
fuse_qkv=True with LyCORIS or diffusers-native checkpoints would fuse the model QKV then fail injection (adapter targets separate Q/K/V modules that no longer exist). Now only set fuse_qkv metadata for BFL format.
1 parent 0920939 commit 16c274b

2 files changed

Lines changed: 6 additions & 3 deletions

File tree

benchmark_lokr.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,8 +162,9 @@ def main():
162162
img.save(path)
163163
print(f" Saved: {path}")
164164

165-
# Tier 1: Fuse-first (lossless, BFL only)
165+
# Tier 1: Fuse-first (lossless, BFL format only - identical to tier 2 for other formats)
166166
if 1 in args.tiers:
167+
print("\n Note: Tier 1 only differs from tier 2 for BFL-format LoKR (fused QKV).")
167168
img = benchmark_tier1_fuse_first(pipe, args.prompt, args.seed, args.lokr_path, args.lokr_name)
168169
path = os.path.join(OUTPUT_DIR, "tier1_fuse_lossless.png")
169170
img.save(path)

src/diffusers/loaders/lora_pipeline.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5691,7 +5691,8 @@ def lora_state_dict(
56915691

56925692
is_lokr = any("lokr_" in k for k in state_dict)
56935693
if is_lokr:
5694-
if any(k.startswith("diffusion_model.") for k in state_dict):
5694+
is_bfl_format = any(k.startswith("diffusion_model.") for k in state_dict)
5695+
if is_bfl_format:
56955696
state_dict = _convert_non_diffusers_flux2_lokr_to_diffusers(state_dict, fuse_qkv=fuse_qkv)
56965697
elif any(k.startswith("lycoris_") for k in state_dict):
56975698
state_dict = _convert_lycoris_flux2_lokr_to_diffusers(state_dict)
@@ -5700,7 +5701,8 @@ def lora_state_dict(
57005701
if metadata is None:
57015702
metadata = {}
57025703
metadata["is_lokr"] = "true"
5703-
if fuse_qkv:
5704+
# Only fuse model QKV for BFL format (which has fused QKV keys to map 1:1)
5705+
if fuse_qkv and is_bfl_format:
57045706
metadata["fuse_qkv"] = "true"
57055707
else:
57065708
is_ai_toolkit = any(k.startswith("diffusion_model.") for k in state_dict)

0 commit comments

Comments
 (0)