-
Notifications
You must be signed in to change notification settings - Fork 366
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
support adam bf16 state #1465
base: main
Are you sure you want to change the base?
support adam bf16 state #1465
Conversation
035e623
to
89477f9
Compare
Signed-off-by: XiaobingSuper <[email protected]>
298ee6f
to
990507e
Compare
for more information, see https://pre-commit.ci
@timmoon10 please help review it, thanks. |
DISPATCH_DOUBLE_FLOAT_HALF_AND_BFLOAT( | ||
m_in_type, 2, "adam", | ||
DISPATCH_DOUBLE_FLOAT_HALF_AND_BFLOAT( | ||
v_in_type, 3, "adam", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will involve increasing the number of template instantiations by 16x. As an alternative approach, how about we cast the Adam state to FP32 and reuse the existing template instantiations? This is the approach we use for FP16 state. We can consider alternative approaches like JIT compilation if the memory and compute overhead become burdensome.
elif dtype == torch.bfloat16: | ||
assert state[state_name].dtype == torch.bfloat16 | ||
unscaled = state[state_name] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's odd that the FP16 case involves per-tensor scaling while the BF16 case does not. This is not necessarily a problem with this PR, but it is a sign that the per-tensor scaling logic does not generalize and that its design should be improved.
Description
This PR supports Adam bf16 state to reduce memory usage, we have tested some smaller models or largest models (LLM models), and we get a similar convergence even with this bf16 lower precision state. For the deepseek-v3 report, they also used the bf16 state to reduce training memory usage.
Type of change
Changes
Please list the changes introduced in this PR:
Checklist: