Skip to content

Commit

Permalink
Added liger_kernel compatibility with PeftModel (huggingface#35680)
Browse files Browse the repository at this point in the history
* Added liger_kernel compatibility with `PeftModel`

* Amending based on review comments

* Amending based on review comments
  • Loading branch information
ambroser53 authored Jan 17, 2025
1 parent df6d42a commit add5f05
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/transformers/trainer.py
Original file line number Diff line number Diff line change
Expand Up @@ -522,6 +522,9 @@ def __init__(
if isinstance(model, PreTrainedModel):
# Patch the model with liger kernels. Use the default kernel configurations.
_apply_liger_kernel_to_instance(model=model)
elif hasattr(model, "get_base_model") and isinstance(model.get_base_model(), PreTrainedModel):
# Patch the base model with liger kernels where model is a PeftModel. Use the default kernel configurations.
_apply_liger_kernel_to_instance(model=model.get_base_model())
else:
logger.warning(
"The model is not an instance of PreTrainedModel. No liger kernels will be applied."
Expand Down

0 comments on commit add5f05

Please sign in to comment.