Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

when resume from peft checkpoint, the model should be trainable #24463

Merged
merged 1 commit into from
Jun 26, 2023

Conversation

sywangyi
Copy link
Contributor

model.training is false after model.load_adapter of peft. see https://github.com/huggingface/peft/blob/main/src/peft/peft_model.py#L402, default value of is_trainable is False

@sywangyi
Copy link
Contributor Author

@younesbelkada please help review

@HuggingFaceDocBuilderDev
Copy link

HuggingFaceDocBuilderDev commented Jun 25, 2023

The documentation is not available anymore as the PR was closed or merged.

Copy link
Contributor

@younesbelkada younesbelkada left a comment

Choose a reason for hiding this comment

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

Thank you for adding this, this looks good, however I am not sure whether we should merge this as in any case it'll lead to the same behavior (i.e. I don't think the PR is technically fixing an issue). the impact of is_trainable is to activate dropout: https://github.com/huggingface/peft/blob/8af8dbd2ec9b4b8f664541e9625f898db7c7c78f/src/peft/peft_model.py#L513 which can be activated by just doing model.train() which is done anyway by the trainer here: https://github.com/huggingface/transformers/blob/main/src/transformers/trainer.py#L2632

cc @pacman100 as well

EDIT: this seems great, some PEFT adapters have inference_mode in the config that freezes the adapter layers: https://github.com/huggingface/peft/blob/8af8dbd2ec9b4b8f664541e9625f898db7c7c78f/src/peft/peft_model.py#L197 So this PR definitely fixes an issue IMO

Copy link
Contributor

@younesbelkada younesbelkada left a comment

Choose a reason for hiding this comment

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

This looks great IMO, updated my comment above! Thanks!

@younesbelkada younesbelkada requested a review from pacman100 June 25, 2023 10:57
Copy link
Collaborator

@sgugger sgugger left a comment

Choose a reason for hiding this comment

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

Thanks for the fix!

@sgugger sgugger merged commit c8aff1d into huggingface:main Jun 26, 2023
@sywangyi sywangyi deleted the resume_peft branch June 26, 2023 13:11
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.

4 participants