Implement the save_pretrained for AdaLoRA

This commit is contained in:
Qingru Zhang
2023-03-30 01:59:26 -04:00
committed by Zhang
parent 300abd1439
commit e3b4cd4671
+5 -1
View File
@@ -70,8 +70,12 @@ def set_peft_model_state_dict(model, peft_model_state_dict):
model ([`PeftModel`]): The Peft model.
peft_model_state_dict (`dict`): The state dict of the Peft model.
"""
if model.peft_config.peft_type is PeftType.ADALORA:
rank_pattern = model.peft_config.rank_pattern
if rank_pattern:
model.base_model.resize_modules_by_rank_pattern(rank_pattern)
model.load_state_dict(peft_model_state_dict, strict=False)
if model.peft_config.peft_type not in (PeftType.LORA, PeftType.ADALORA):
model.prompt_encoder.embedding.load_state_dict(
{"weight": peft_model_state_dict["prompt_embeddings"]}, strict=True