Skip to content

Commit

Permalink
Fix compatible error (#201)
Browse files Browse the repository at this point in the history
  • Loading branch information
tastelikefeet committed Dec 6, 2023
1 parent c6bf657 commit 1826394
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion requirements/framework.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ nltk
numpy
optimum
pandas
peft>=0.6.0
peft>=0.6.0,<=0.6.2
requests
rouge
safetensors
Expand Down
5 changes: 5 additions & 0 deletions swift/tuners/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -316,12 +316,17 @@ def from_pretrained(cls,
for k, v in state_dict.items()
}
if any(['loramodule' in key for key in state_dict]):
# Compatible with old checkpoints before ms-swift:1.5.0
state_dict = {
key.replace(f'loramodule_{_name}.lora_A', 'lora_A')
if f'loramodule_{_name}.lora_A.{_name}' in key else
key.replace(f'loramodule_{_name}.lora_A',
f'lora_A.{_name}.weight'): value
for key, value in state_dict.items()
}
state_dict = {
key.replace(f'loramodule_{_name}.lora_B', 'lora_B')
if f'loramodule_{_name}.lora_B.{_name}' in key else
key.replace(f'loramodule_{_name}.lora_B',
f'lora_B.{_name}.weight'): value
for key, value in state_dict.items()
Expand Down

0 comments on commit 1826394

Please sign in to comment.