You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Then when saving the model after Training, In the finetune.py line 275, use the model.save_pretrained() function, which is implemented by the PeftModel.save_pretrained(). Inside the PeftModel.save_pretrained(), get_peft_model_state_dict() is used again.
However, because the model.state_dict is already changed! The dict returened by it is regularized (changed keys' name), the the get_peft_model_state_dict() inside the PeftModel.save_pretrained() will remove all the parameter whose keys string doesn't contain the adapter_name, which is all! It will result in the final state_dict to be save is None!!! to_return = {k: v for k, v in to_return.items() if (("lora_" in k and adapter_name in k) or ("bias" in k))}
The text was updated successfully, but these errors were encountered:
yea, I just realized that this morning after all-night training lol
DragonMengLong
changed the title
Bug:there is a bug in the finetune.py, that would result to an empyt adapter checkpoint after training!!!
Bug : there is a bug in the finetune.py, that would result to an empyt adapter checkpoint after training!!!
May 25, 2023
I have tried to fix some of these issues in my QLoRA fork of alpaca-lora https://github.com/vihangd/alpaca-qlora Feel free to give it a go and report any issues that you might encounter.
In the finetune.py, lin line 246, where the original
model.state_dict
is changed into a lambda function ofget_peft_model_state_dict()
get_peft_model_state_dict()
will retuen a dict of only the Lora parameter and the keys of the parameter is regularized, theadapter_name
in the key string is removed.to_return = {k.replace(f".{adapter_name}", ""): v for k, v in to_return.items()}
Then when saving the model after Training, In the finetune.py line 275, use the
model.save_pretrained()
function, which is implemented by thePeftModel.save_pretrained()
. Inside thePeftModel.save_pretrained()
,get_peft_model_state_dict()
is used again.However, because the
model.state_dict
is already changed! The dict returened by it is regularized (changed keys' name), the theget_peft_model_state_dict()
inside thePeftModel.save_pretrained()
will remove all the parameter whose keys string doesn't contain theadapter_name
, which is all! It will result in the final state_dict to be save is None!!!to_return = {k: v for k, v in to_return.items() if (("lora_" in k and adapter_name in k) or ("bias" in k))}
The text was updated successfully, but these errors were encountered: