-
Notifications
You must be signed in to change notification settings - Fork 393
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Experimental support for accelerate (#826)
Add support for mixed precision training and more with accelerate https://github.com/huggingface/accelerate The feature is treated as experimental for now. This is why we don't make it part of the core classes yet but instead have the user create a new class that inherits from the mixin. Mixed precision training was tested on Turing and Ampere architectures successfully. Some of the other accelerate features, such as DeepSpeed integration, were not tested. Implementation When using AMP, accelerate applies grad scaling under the hood using GradScaler. That does not support passing the train step as a closure to optimizer.step. Therefore, we need to step explicitly. We could use a more sophisticated approach of trying to figure out if grad scaler is actually being used and only stepping explicitly if needed. However, the need for the closure is quite rare and we want to treat accelerate as a black box instead of relying on implementation details (which we would have to in order to figure out when grad scaling is applied).
- Loading branch information
1 parent
f5bb1a5
commit c0df4d1
Showing
6 changed files
with
403 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
accelerate | ||
fire | ||
flaky | ||
future>=0.17.1 | ||
|
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.