Skip to content

Conversation

@BenjaminBossan
Copy link
Member

What does this PR do?

In the notebook, get_peft_model(model) is called, which mutates the base model. Then the same model is passed to SFTTrainer with a PEFT config, which leads to another call to get_peft_model under the hood and thus to PEFT being applied twice.

This fix removes the manual get_peft_model call and lets trl handle this. We lose the ability to inspect the number of trainable parameters but IMO this is the simplest solution.

In the notebook, get_peft_model(model) is called, which mutates the base
model. Then the same model is passed to SFTTrainer with a PEFT config,
which leads to another call to get_peft_model under the hood and thus to
PEFT being applied twice.

This fix removes the manual get_peft_model call and lets trl handle
this. We lose the ability to inspect the number of trainable parameters
but IMO this is the simplest solution.
@review-notebook-app
Copy link

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

@HuggingFaceDocBuilderDev

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

@BenjaminBossan
Copy link
Member Author

@sergiopaniego

Copy link
Member

@sergiopaniego sergiopaniego left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@sergiopaniego sergiopaniego merged commit e11fbe4 into huggingface:main Nov 7, 2025
1 check passed
@BenjaminBossan BenjaminBossan deleted the fix-fine-tuning-vlm-peft-trl branch November 7, 2025 15:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants