Skip to content

Commit 7ba16a0

Browse files
committed
Fix compatible error (#201)
(cherry picked from commit 1826394)
1 parent 87b6355 commit 7ba16a0

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

requirements/framework.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ nltk
77
numpy
88
optimum
99
pandas
10-
peft>=0.6.0
10+
peft>=0.6.0,<=0.6.2
1111
requests
1212
rouge
1313
safetensors

swift/tuners/base.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -316,12 +316,17 @@ def from_pretrained(cls,
316316
for k, v in state_dict.items()
317317
}
318318
if any(['loramodule' in key for key in state_dict]):
319+
# Compatible with old checkpoints before ms-swift:1.5.0
319320
state_dict = {
321+
key.replace(f'loramodule_{_name}.lora_A', 'lora_A')
322+
if f'loramodule_{_name}.lora_A.{_name}' in key else
320323
key.replace(f'loramodule_{_name}.lora_A',
321324
f'lora_A.{_name}.weight'): value
322325
for key, value in state_dict.items()
323326
}
324327
state_dict = {
328+
key.replace(f'loramodule_{_name}.lora_B', 'lora_B')
329+
if f'loramodule_{_name}.lora_B.{_name}' in key else
325330
key.replace(f'loramodule_{_name}.lora_B',
326331
f'lora_B.{_name}.weight'): value
327332
for key, value in state_dict.items()

0 commit comments

Comments
 (0)