Skip to content

Commit

Permalink
added valueerror to mappings
Browse files Browse the repository at this point in the history
  • Loading branch information
d-kleine committed Nov 11, 2024
1 parent a86d6f8 commit d3e36eb
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/peft/mapping.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,11 @@ def get_peft_model(
# note: PeftMixedModel does not support autocast_adapter_dtype, so don't pass it
return PeftMixedModel(model, peft_config, adapter_name=adapter_name)

if peft_config.task_type not in MODEL_TYPE_TO_PEFT_MODEL_MAPPING.keys() and not peft_config.is_prompt_learning:
return PeftModel(model, peft_config, adapter_name=adapter_name, autocast_adapter_dtype=autocast_adapter_dtype)
if peft_config.task_type not in MODEL_TYPE_TO_PEFT_MODEL_MAPPING.keys():
if not peft_config.is_prompt_learning:
return PeftModel(model, peft_config, adapter_name=adapter_name, autocast_adapter_dtype=autocast_adapter_dtype)
else:
raise ValueError(f"Invalid task type: '{peft_config.task_type}'. Must be one of the following task types: {list(MODEL_TYPE_TO_PEFT_MODEL_MAPPING.keys())}.")

if peft_config.is_prompt_learning:
peft_config = _prepare_prompt_learning_config(peft_config, model_config)
Expand Down

0 comments on commit d3e36eb

Please sign in to comment.