-
Notifications
You must be signed in to change notification settings - Fork 119
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove message of checking
apex.amp
module and add tests for featur…
…es of gradient accumulation/mixed precision training (#46) * MAINT: remove message of checking `apex.amp` module The original propose of that message is to let users know gradient accumulation and mixed precision training is supported but `apex` is required. With an attention brought up by issue #45, the following things are confirmed: - Gradient accumulation can still work properly without `apex.amp`. And that's why it would fall back on normal `loss.backward()` when `apex.amp` is not available or `amp.initialize()` wasn't called. - When mixed precision training is required, that is to say model and optimizer are wrapped by `amp.initialize()`, `amp.scale_loss()` will be adopted automatically in current implementation. Therefore, it seems that message of checking `apex.amp` module is not necessary anymore. * TST: parameter `batch_size` was not passed into `DataLoader` This mistake made batch size of every data loader become the default value: 1. Though it does not affect the correctness of all test case, it still needs to be corrected. However, `batch_size` of a `DataLoader` cannot be modified after it is initialized. Therefore, we can only determine it while generating tasks for test, and that's why `batch_size` and `steps` is moved to the signature of `__init__` of each `Task`. * TST: move model to device while post-initializing tasks This functionality was not added before, and it made all tests run on CPU even if the pytest argument `--cpu_only` is not specified. * TST: add tests for gradient accumulation and mixed precision training * BUILD: add pytest-mock to dependencies for tests * TST: change the import statement to import `amp` submodule directly
- Loading branch information
1 parent
98c4004
commit 23a23cf
Showing
5 changed files
with
127 additions
and
32 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
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