-
-
Notifications
You must be signed in to change notification settings - Fork 390
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
Apex support for mixed precision training #183
Conversation
@BloodAxe proposal: add fp16 flag to |
This need discussion. Apart from global enable/disable fp16 training mode flag, there are couple of flags that user may want to change (optimization level, flag to keep batch-norm in fp32, loss scaling flags, etc). |
@BloodAxe hmm, you are right...
|
@Scitator I think it's still make sense to have fast&quick option to turn on fp16 mode for SupervisedRunner. |
7d483b8
to
3a664bb
Compare
Makes mixed precision training as simple as possible:
Breaking changes (mostly internal, but still):
Experiment.get_optimizer
renamed toExperiment.get_optimizer_and_model
and returns optimizer and model as a tuple. Motivation: Apex requires two objects to initialize - a model and optimizer. A model must be already on GPU and not wrapped with DataParallel/DistributedDataParallel. This change was made to have clear amp initialization in one place.UtilsFactory.prepare_model
now does not wrap model with DataParallel since this will break Apex initialization. Instead, DataParallel applied inExperiment.get_optimizer_and_model
if fp16 is not enabled and more than one GPU is available.