Describe your use-case.
With Adam/AdamW, gradients and optimizer state appear to stay in bf16, which can lead to a loss of precision during the accumulation of gradients over many steps, potentially impacting training stability and final model quality. Adafactor already does the math/state in fp32 and only stochastic rounding on copy-back.
This proposal aims to align the Adam optimizer with this best practice, which should improve its performance in bfloat16 training scenarios.
What would you like to see as a solution?
I suggest modifying step_adam_parameter in modules/util/optimizer/adam_extensions.py (and adamw_extensions.py) to ensure internal calculations are performed in float32.
A simple way to achieve this would be to cast the gradient to float32 before it is used for state updates, similar to how it is handled in the Adafactor implementation.
Have you considered alternatives? List them here.
Describe your use-case.
With Adam/AdamW, gradients and optimizer state appear to stay in bf16, which can lead to a loss of precision during the accumulation of gradients over many steps, potentially impacting training stability and final model quality. Adafactor already does the math/state in fp32 and only stochastic rounding on copy-back.
This proposal aims to align the Adam optimizer with this best practice, which should improve its performance in bfloat16 training scenarios.
What would you like to see as a solution?
I suggest modifying
step_adam_parameterinmodules/util/optimizer/adam_extensions.py(andadamw_extensions.py) to ensure internal calculations are performed infloat32.A simple way to achieve this would be to cast the gradient to
float32before it is used for state updates, similar to how it is handled in the Adafactor implementation.Have you considered alternatives? List them here.
state_dtype = "fp32" | "param", defaulting to"fp32", so users can choose.