mirror of
https://github.com/wassname/peft.git
synced 2026-09-09 11:28:32 +08:00
Implement the save_pretrained for AdaLoRA
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user