-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Autocast adapter weights if fp16/bf16 (#1706)
As discussed internally, we want to automatically cast the weights of the adapter to float32 when using float16. Float16 is not conducive to stable training and raises errors when used with AMP. Previously, we had to recommend to users to manually cast the weights if they loaded the base model in float16, because PEFT would choose the same dtype for the adapter as for the base weights. Forgetting this is a common source of errors, so we choose to automate this. If this causes trouble, users can prevent the behavior by passing autocast_adapter_dtype=False to get_peft_model, PeftModel.from_pretrained, or PeftModel.load_adapter. This PR should be reviewed carefully, as it has the potential to break existing code if something important was missed. We also need to add a note for the upcoming release text about this change in behavior.
- Loading branch information
1 parent
2535036
commit ae1ae20
Showing
5 changed files
with
344 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.