分享使用最新的peft-0.4.0的一些实践。 #189
Qznan
started this conversation in
Show and tell
Replies: 4 comments 2 replies
-
|
请问我训练到一半,出现这个报错,AttributeError: 'LlamaForCausalLM' object has no attribute 'sava checkpoint'。是不是peft版本的问题。 |
Beta Was this translation helpful? Give feedback.
2 replies
-
|
请问如何在SavePeftModelCallback中调用save_pretrained时再显式传入state_dict=old_state_dict()呢,有代码可以参考吗~ |
Beta Was this translation helpful? Give feedback.
0 replies
-
|
您好,想請問TypeError: GenerationMixin._extract_past_from_model_output() got an unexpected keyword argument 'standardize_cache_format'這是什麼狀況呢? |
Beta Was this translation helpful? Give feedback.
0 replies
-
|
您好,您的来信我已收到,我会尽快处理。 祝好!
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
本项目要求使用的是
peft==0.3.0.dev0,但使用中若需要使用QLoRA等新功能时要求新版的peft(#144) 。同时旧版peft搭配最新deepspeed来resume_from_checkpoint时还可能需要修改deepspeed代码来适配(#161)。经修改,本人目前使用
peft==0.4.0可成功训练和推断,具体使用环境如下:具体修改:只需将
run_clm_pt_with_peft.py和run_clm_sft_with_peft.py中的以下的代码段去掉:这里作者替换了PeftModel模型实例的state_dict函数,让其只返回例如lora微调的参数。推测是想让deepspeed在保存模型checkpoint如
mp_rank_00_model_states.pt时,其中的module字段只保留lora微调参数,节省磁盘占用。而新版peft中,模型载入后对每个lora参数增加了
adapter_name后缀(默认为'default'),同时在每次保存PeftModel.save_pretrained也会调用get_peft_model_state_dict。这导致经过作者替换后的state_dict已经过滤了没有了default后缀,而新版的get_peft_model_state_dict却还要通过是否有default后缀来过滤参数,最终导致PeftModel.save_pretrained保留的是空的adapter.bin。故只要将以上替换state_dict的代码去掉就好,但此时deepspeed保存的checkpoint模型确实是全量的,太大。这里的一个解决想法是保持使用上述state_dict替换,但是old_state_dict保留,并且在SavePeftModelCallback中调用save_pretrained时再显式传入state_dict=old_state_dict()。用原始全量来调用save_pretrained以正确保存。
欢迎交流讨论😄
Beta Was this translation helpful? Give feedback.
All reactions