Skip to content

FIX [PEFT / Trainer ] Handle better peft + quantized compiled models#29055

Merged
younesbelkada merged 6 commits into
huggingface:mainfrom
younesbelkada:fix-compile-peft
Feb 20, 2024
Merged

FIX [PEFT / Trainer ] Handle better peft + quantized compiled models#29055
younesbelkada merged 6 commits into
huggingface:mainfrom
younesbelkada:fix-compile-peft

Conversation

@younesbelkada

@younesbelkada younesbelkada commented Feb 16, 2024

Copy link
Copy Markdown
Contributor

What does this PR do?

Fixes: #29033

Even though quantized models + compile + peft is not really stable (might not work OTB for all users), the current way we deal with peft compiled models leads to errors that are hard to interpret to users such as the one described in #29033

I will run some tests on my see to check if torch.compile + qlora is supported

cc @amyeroberts

@younesbelkada younesbelkada changed the title [PEFT / handle peft + compiled models FIX [PEFT / Trainer ] Handle better peft + quantized compiled models Feb 16, 2024
@younesbelkada
younesbelkada marked this pull request as draft February 16, 2024 07:18
@HuggingFaceDocBuilderDev

Copy link
Copy Markdown

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.

@amyeroberts

Copy link
Copy Markdown
Contributor

LGTM! Let me know when it's out of draft and you want a final review

@amyeroberts

Copy link
Copy Markdown
Contributor

It would be good to add a test for compiled models alongside this change

@younesbelkada
younesbelkada marked this pull request as ready for review February 19, 2024 06:52
@younesbelkada

younesbelkada commented Feb 19, 2024

Copy link
Copy Markdown
Contributor Author

Thanks @amyeroberts ! This is ready for review !
Note currently QLoRA + torch.compile is not really supported as we need to make some changes to make 4bit layers from bnb compatible with torch.compile . Therefore I added a test that simply checks if the trainer is correctly initialized so that we don't get the unappropriate error from #29033 . Once compile + QLoRA will be supported, the integration will be seemless as users will simply have to update bitsandbytes to make it work

@amyeroberts amyeroberts left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for fixing and adding a test!

If it's still not yet possible to use a compiled model with bnb, then we should raise an error saying this to the user instead of letting things fail when they call .train

Comment thread tests/trainer/test_trainer.py Outdated
Comment on lines +912 to +913
# TODO: In the future (once we have bnb + compile support), uncomment this
# trainer.train()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

If this is the case - we should raise an explicit error if using bnb + compile with trainer.

@younesbelkada

Copy link
Copy Markdown
Contributor Author

Thanks @amyeroberts for the review! I just adapted the PR according to your suggestion, one concern I have with this new approach is that if bnb supports torch.compile in the next months we'll need to do some version check on trainer's init and make the code slightly bloated - though I am happy with this approach as well as I don't think this is that bad. What do you think? 🙏

@amyeroberts

Copy link
Copy Markdown
Contributor

@younesbelkada How soon and with what confidence do you think bnb will support this?

I agree we want to avoid bloat as much as possible, but I think it's better overall to be explict and have well defined behaviour for our users. The easiest way to avoid many version checks is to only support the latest version of bnb.

@amyeroberts amyeroberts left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for adding!

@younesbelkada

Copy link
Copy Markdown
Contributor Author

OK sounds good! I agree with that approach!
Currently we don't have any ETA :/ it might take a bit long, and it will also depend if the community will ask for it

@younesbelkada
younesbelkada merged commit efdd436 into huggingface:main Feb 20, 2024
@younesbelkada
younesbelkada deleted the fix-compile-peft branch February 20, 2024 11:45
@pharringtonp19

Copy link
Copy Markdown

@younesbelkada I would certainly be interested if bnb could support torch.compile!

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.

Trainer doesn't handle torch.compiled QLoRA models correctly

4 participants