Skip to content

Bfloat16 zero2 - #1398

Merged
tjruwase merged 26 commits into
deepspeedai:masterfrom
raamjad:bfloat16_zero2
Nov 1, 2021
Merged

tjruwase merged 26 commits into
deepspeedai:masterfrom
raamjad:bfloat16_zero2

Conversation

@raamjad

@raamjad raamjad commented Sep 25, 2021

Copy link
Copy Markdown
Contributor

Enabling support for Bfloat16 with ZeRO-2 optimizer, partially resolving the issue#974
#974

Bfloat16 collective communication requires NCCL 2.10.3.

…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.
@ghost

ghost commented Sep 25, 2021 •

Copy link
Copy Markdown

CLA assistant check
All CLA requirements met.

@szhengac

szhengac commented Oct 4, 2021

Copy link
Copy Markdown
Contributor

@ShadenSmith can you help review this PR?

@tjruwase

Copy link
Copy Markdown
Contributor

@raamjad, apologies for the inaction here. I will take a closer look now.

@tjruwase

Copy link
Copy Markdown
Contributor

@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.

@raamjad

raamjad commented Oct 23, 2021

Copy link
Copy Markdown
Contributor Author

@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.
Thanks for checking it out. Sure, I will look at the unit test for fp16 and extend it for bfloat16

@raamjad

raamjad commented Oct 27, 2021

Copy link
Copy Markdown
Contributor Author

@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

Comment thread tests/unit/test_bf16.py Outdated

@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():

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't we need a nccl version check as well?

@raamjad raamjad Oct 28, 2021 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps deepspeed could help. See below

  1. 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'}
>>>
  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'}
>>>

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added additional conditions based on NCCL, CUDA and HW.

@tjruwase

Copy link
Copy Markdown
Contributor

@stas00 and @raamjad, we can continue the thread on a unified configuration support for different precision types.

Yes, @raamjad, I agree that the unified support can be a follow up PR. Thanks for helping with that.

@tjruwase

tjruwase commented Oct 27, 2021 •

Copy link
Copy Markdown
Contributor

Retrieving @stas00 proposals for dtype configuration. Please let me know if I captured everything correctly.

image

image

image

@tjruwase

Copy link
Copy Markdown
Contributor

@stas00, what I found in teams corresponds to your "first" approach. This is also my preference .

@raamjad

raamjad commented Oct 28, 2021

Copy link
Copy Markdown
Contributor Author

@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.

@raamjad

raamjad commented Nov 1, 2021

Copy link
Copy Markdown
Contributor Author

@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

@tjruwase

tjruwase commented Nov 1, 2021

Copy link
Copy Markdown
Contributor

@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.

@raamjad

raamjad commented Nov 1, 2021

Copy link
Copy Markdown
Contributor Author

@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!

@tjruwase
tjruwase merged commit 648f7bf into deepspeedai:master Nov 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants