Repository navigation
Bfloat16 zero2 - #1398
Bfloat16 zero2#1398
Conversation
…eed to go over certain new logical changes for FP16
Merging Changes for bfloat16 support with ZeRO-2 optimizer into the latest master branch for PR. Bfloat16 Support requires NCCL 2.10.3 which provides BFloat16 communication support.
|
@ShadenSmith can you help review this PR? |
|
@raamjad, apologies for the inaction here. I will take a closer look now. |
|
@raamjad, can you please add some unit tests since this feature is prone to subtle correctness issues. If it makes sense you can either extend the current fp16 unit tests or add a corresponding one for bfloat. |
|
Have added the tests for bfloat16 following the ones in test_fp16.py. Since bfloat16 is only enabled for ZeRo-2 currently the range of tests is also limited to the ones relevant for that scenario |
|
|
||
| @pytest.mark.parametrize('zero_stage, use_cpu_offload', [(2, False)]) | ||
| def test_zero_empty_partition(tmpdir, zero_stage, use_cpu_offload): | ||
| if not bf16_required_torch_version(): |
There was a problem hiding this comment.
Don't we need a nccl version check as well?
There was a problem hiding this comment.
Yes and also for HW since only certain GPU architectures support it. Checking NCCL version can be done pretty similarly as torch but I am not sure how to condition on whether the HW supports BF16 or not.
Pytorch does it in cpp as follows
https://github.com/pytorch/pytorch/blob/6696c59af4bbb0164e2c5365bd4f139af9684019/torch/csrc/distributed/c10d/ProcessGroupNCCL.cpp#L80
and
https://github.com/pytorch/pytorch/blob/354363b57a8bf37ab7be5bf5e4deb0cd5f29eb86/torch/csrc/cuda/nccl.cpp#L93
Not sure how that can be done in the python code for unit testing. Any suggestions will be welcome.
There was a problem hiding this comment.
Perhaps deepspeed could help. See below
- On CUDA system
Type "help", "copyright", "credits" or "license" for more information.
>>> import deepspeed
>>> from deepspeed.git_version_info import torch_info
>>> torch_info
{'version': '1.8', 'cuda_version': '11.1'}
>>>- On ROCm system
Type "help", "copyright", "credits" or "license" for more information.
>>> import deepspeed
f>>> from deepspeed.git_version_info import torch_info
>>> torch_info
{'version': '1.9', 'cuda_version': '0.0', 'hip_version': '4.3'}
>>>There was a problem hiding this comment.
Added additional conditions based on NCCL, CUDA and HW.
|
Retrieving @stas00 proposals for dtype configuration. Please let me know if I captured everything correctly. |
|
@stas00, what I found in teams corresponds to your "first" approach. This is also my preference . |
This looks good, we can introduce in a later PR to refactor the configuration. |
…loat16_zero2 Merging Bfloat16 unit test conditions
…loat16_zero2 Merging inconsistent NCCL version check for BF16 unit tests
|
@tjruwase Seems like all the tests have successfully passed/skipped. I did notice that I didn't update the skip message based on additional checks I introduced so I will update that. Is there anything else that is needed before merging this PR? Thanks for your help |
@raamjad, thanks for your hard work on this PR. I have approved the changes and was hoping to merge over the weekend until the tests started failing, which you have now fixed. All that is left now for a successful test run, and I will merge. |
Thanks! |



Enabling support for Bfloat16 with ZeRO-2 optimizer, partially resolving the issue#974
#974
Bfloat16 collective communication requires NCCL 2.10.3.