Skip to content

Commit 6ca800f

Browse files
authored
fix(flux): support .weight variant for attention norm parameter mappings (invoke-ai#9190)
1 parent af37c23 commit 6ca800f

1 file changed

Lines changed: 12 additions & 12 deletions

File tree

  • invokeai/backend/model_manager/load/model_loaders

invokeai/backend/model_manager/load/model_loaders/flux.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -984,13 +984,13 @@ def _convert_double_block_key(self, key: str, tensor: torch.Tensor, converted: d
984984
return f"{prefix}.attn.to_add_out.weight"
985985

986986
# Attention norms
987-
if "img_attn.norm.query_norm.scale" in rest:
987+
if "img_attn.norm.query_norm.scale" in rest or "img_attn.norm.query_norm.weight" in rest:
988988
return f"{prefix}.attn.norm_q.weight"
989-
elif "img_attn.norm.key_norm.scale" in rest:
989+
elif "img_attn.norm.key_norm.scale" in rest or "img_attn.norm.key_norm.weight" in rest:
990990
return f"{prefix}.attn.norm_k.weight"
991-
elif "txt_attn.norm.query_norm.scale" in rest:
991+
elif "txt_attn.norm.query_norm.scale" in rest or "txt_attn.norm.query_norm.weight" in rest:
992992
return f"{prefix}.attn.norm_added_q.weight"
993-
elif "txt_attn.norm.key_norm.scale" in rest:
993+
elif "txt_attn.norm.key_norm.scale" in rest or "txt_attn.norm.key_norm.weight" in rest:
994994
return f"{prefix}.attn.norm_added_k.weight"
995995

996996
# MLP layers
@@ -1020,9 +1020,9 @@ def _convert_single_block_key(self, key: str, tensor: torch.Tensor, converted: d
10201020
return f"{prefix}.attn.to_out.weight"
10211021

10221022
# Norms
1023-
if "norm.query_norm.scale" in rest:
1023+
if "norm.query_norm.scale" in rest or "norm.query_norm.weight" in rest:
10241024
return f"{prefix}.attn.norm_q.weight"
1025-
elif "norm.key_norm.scale" in rest:
1025+
elif "norm.key_norm.scale" in rest or "norm.key_norm.weight" in rest:
10261026
return f"{prefix}.attn.norm_k.weight"
10271027

10281028
return key
@@ -1328,13 +1328,13 @@ def _convert_double_block_key(self, key: str, tensor, converted: dict) -> str |
13281328
elif "txt_attn.proj.weight" in rest:
13291329
return f"{prefix}.attn.to_add_out.weight"
13301330

1331-
if "img_attn.norm.query_norm.scale" in rest:
1331+
if "img_attn.norm.query_norm.scale" in rest or "img_attn.norm.query_norm.weight" in rest:
13321332
return f"{prefix}.attn.norm_q.weight"
1333-
elif "img_attn.norm.key_norm.scale" in rest:
1333+
elif "img_attn.norm.key_norm.scale" in rest or "img_attn.norm.key_norm.weight" in rest:
13341334
return f"{prefix}.attn.norm_k.weight"
1335-
elif "txt_attn.norm.query_norm.scale" in rest:
1335+
elif "txt_attn.norm.query_norm.scale" in rest or "txt_attn.norm.query_norm.weight" in rest:
13361336
return f"{prefix}.attn.norm_added_q.weight"
1337-
elif "txt_attn.norm.key_norm.scale" in rest:
1337+
elif "txt_attn.norm.key_norm.scale" in rest or "txt_attn.norm.key_norm.weight" in rest:
13381338
return f"{prefix}.attn.norm_added_k.weight"
13391339

13401340
if "img_mlp.0.weight" in rest:
@@ -1359,9 +1359,9 @@ def _convert_single_block_key(self, key: str, tensor, converted: dict) -> str |
13591359
elif "linear2.weight" in rest:
13601360
return f"{prefix}.attn.to_out.weight"
13611361

1362-
if "norm.query_norm.scale" in rest:
1362+
if "norm.query_norm.scale" in rest or "norm.query_norm.weight" in rest:
13631363
return f"{prefix}.attn.norm_q.weight"
1364-
elif "norm.key_norm.scale" in rest:
1364+
elif "norm.key_norm.scale" in rest or "norm.key_norm.weight" in rest:
13651365
return f"{prefix}.attn.norm_k.weight"
13661366

13671367
return key

0 commit comments

Comments
 (0)