[Dev] Support bf16 pricision optimizer store bf16 ckeckpoint #2790
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem Description
Currently in the codebase, when the low-precision optimizer is enabled, optimizer states are saved in FP32 format when storing checkpoints. We implemented saving the optimizer states in low precision rather than fp32 when the low-precision optimizer is enabled to reduce disk space usage, and this change has no impact on accuracy.
Our Solution
We use a dedicated function to save the optimizer states according to the optimizer state dtype specified in the config.
At the same time, to remain compatible with
TransformerEngine, we check the concrete dtype when loading the optimizer states and perform the corresponding format conversion in function_set_main_param_and_optimizer_states.Experiment
All the experiments below start from random initialization and run for 20 iterations. A checkpoint is saved at the 10th iteration using the corresponding optimizer precision. We then load the checkpoint and resume training from the 11th iteration to verify correctness.
parameter settings:
For the dsv2lite model, after saving the optimizer states in BF16, the disk usage is reduced from 222 GB to 164 GB, a reduction of approximately 27%.