Skip to content

Commit

Permalink
check correctly for condition (huggingface#668)
Browse files Browse the repository at this point in the history
  • Loading branch information
younesbelkada authored and Andrew Lapp committed May 10, 2024
1 parent cbfad7f commit 1610baf
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion trl/trainer/sft_trainer.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,8 @@ def __init__(
"You passed a `DataCollatorForCompletionOnlyLM` to the SFTTrainer. This is not compatible with the `packing` argument."
)

supported_classes = (PreTrainedModel,) if not is_peft_available() else (PreTrainedModel, PeftModel)

if is_peft_available() and peft_config is not None:
if not isinstance(peft_config, PeftConfig):
raise ValueError(
Expand All @@ -151,7 +153,7 @@ def __init__(

if callbacks is None:
callbacks = [PeftSavingCallback]
elif not isinstance(model, (PreTrainedModel, PeftModel)):
elif not isinstance(model, supported_classes):
model = AutoModelForCausalLM.from_pretrained(model)

if tokenizer is None:
Expand Down

0 comments on commit 1610baf

Please sign in to comment.