Skip to content

Commit 59ae9ea

Browse files
authored
Merge pull request kohya-ss#1945 from yidiq7/dev
Remove position_ids for V2
2 parents 6e3c1d0 + 13df475 commit 59ae9ea

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

library/model_util.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -643,16 +643,15 @@ def convert_key(key):
643643
new_sd[key_pfx + "k_proj" + key_suffix] = values[1]
644644
new_sd[key_pfx + "v_proj" + key_suffix] = values[2]
645645

646-
# rename or add position_ids
646+
# remove position_ids for newer transformer, which causes error :(
647647
ANOTHER_POSITION_IDS_KEY = "text_model.encoder.text_model.embeddings.position_ids"
648648
if ANOTHER_POSITION_IDS_KEY in new_sd:
649649
# waifu diffusion v1.4
650-
position_ids = new_sd[ANOTHER_POSITION_IDS_KEY]
651650
del new_sd[ANOTHER_POSITION_IDS_KEY]
652-
else:
653-
position_ids = torch.Tensor([list(range(max_length))]).to(torch.int64)
654651

655-
new_sd["text_model.embeddings.position_ids"] = position_ids
652+
if "text_model.embeddings.position_ids" in new_sd:
653+
del new_sd["text_model.embeddings.position_ids"]
654+
656655
return new_sd
657656

658657

0 commit comments

Comments
 (0)