-
Notifications
You must be signed in to change notification settings - Fork 42
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
Suggestion: AMP support #200
Comments
Thank you for your suggestion! I haven't used it before. How effective is it? |
AMP is support for Automatic Mixed Precision. It was made native to torch 1.6 in mid-2020 by replacing Nvidia's Apex extension two years after it was introduced. I try to use it wherever I can for practical needs. I haven't tried to patch HandyRL with it. Pytorch declares some benchmarks here [0]. They say accuracy impact is generally <0.1% on standard benchmarks and speed up impact is generally 1.5-2x. You can usually almost double batch sizes. That accords with my experience using a 2080 TI. Adding AMP is straightforward. The minimal steps are Declare a scaler for the life of the session
Wrap all forward calls with the autocaster and scales losses
Pytorch provide some examples here [1]. If you accumulate gradients, or modify gradients before they are scaled, or work with DataParellel, there are additional nominal steps. Implementations sometimes offer USE_PARALLEL and USE_AMP as configurable parameters for users. This is just a suggestion. With RL most users would probably be CPU rather than GPU bound. For those with 32+ cores and 1 GPU, it may be useful. [0] https://pytorch.org/blog/accelerating-training-on-nvidia-gpus-with-pytorch-automatic-mixed-precision/ |
Thanks for the details. That is awesome! Through your comments, I feel that it would be convenient to use Thanks |
It would be useful to have native amp mixd precision support for those with limited GPU
https://pytorch.org/docs/stable/amp.html
The text was updated successfully, but these errors were encountered: