google / automl

Google Brain AutoML
Apache License 2.0
6.18k stars 1.45k forks source link

how to train model by lion optimizer with fp16? #1192

Open Geek-lixiang opened 1 year ago

Geek-lixiang commented 1 year ago

It says "Additional, Lion still requires momentum tracking in bfloat16, which can be expensive for training giant models. One potential solution is to factorize the momentum to save memory.", how to complete the "momentum tracking"? Thank you very much!

xiangning-chen commented 10 months ago

For momentum tracking with bfloat16, you can just cast the type of momentum into bfloat16, see the example here: https://github.com/deepmind/optax/blob/master/optax/_src/transform.py#L461.