[zero-1] ignore overlap/contiguous_gradients flags#1246
Merged
Conversation
tjruwase
approved these changes
Jul 23, 2021
samyam
approved these changes
Jul 26, 2021
Contributor
samyam
left a comment
There was a problem hiding this comment.
LGTM and makes sense to do this. Since none of the backward hooks are triggered by stage 1, there is no overlapping or contiguous gradients.
jeffra
added a commit
that referenced
this pull request
Jul 29, 2021
Co-authored-by: Olatunji Ruwase <olruwase@microsoft.com>
What should we do if we want to realize the overlapping of communication and computing in Zero1? |
github-merge-queue bot
pushed a commit
that referenced
this pull request
Jan 5, 2024
…4887) The `overlap_comm` and `contiguous_gradients` options have been ignored in ZeRO stage 1 since #1246. Back in that time, ZeRO 1 and 2 are separately implemented (see https://github.com/microsoft/DeepSpeed/tree/6ae756c03f12674f17aef90622e7664a8af9d2af/deepspeed/runtime/zero). ZeRO 1 does not have gradient hooks registered to overlap backward and gradient all-reduce, so it's fine to ignore `overlap_comm` and `contiguous_gradients`. However, in the current implementation, ZeRO 1 and 2 share almost the same implementation (`stage_1_and_2.py`). Features like `overlap_comm` and `contiguous_gradients` can also be enabled for ZeRO 1 (Please correct me if I made a mistake). With this PR, turning on `overlap_comm` and `contiguous_gradients` for ZeRO 1 on the [SFT task](https://github.com/microsoft/DeepSpeedExamples/tree/master/applications/DeepSpeed-Chat/training/step1_supervised_finetuning) produces exactly the same training curve as the latest master.  I also see a ~1.05x e2e speedup by overlapping backward and gradient all-reduce. I can confirm by the trace that backward and all-reduce do overlap, and the separate gradients are indeed copied to a flat buffer. These options are also effective for ZeRO 1.   Related issue: #2295 Co-authored-by: Olatunji Ruwase <olruwase@microsoft.com>
mauryaavinash95
pushed a commit
to mauryaavinash95/DeepSpeed
that referenced
this pull request
Feb 17, 2024
…eepspeedai#4887) The `overlap_comm` and `contiguous_gradients` options have been ignored in ZeRO stage 1 since deepspeedai#1246. Back in that time, ZeRO 1 and 2 are separately implemented (see https://github.com/microsoft/DeepSpeed/tree/6ae756c03f12674f17aef90622e7664a8af9d2af/deepspeed/runtime/zero). ZeRO 1 does not have gradient hooks registered to overlap backward and gradient all-reduce, so it's fine to ignore `overlap_comm` and `contiguous_gradients`. However, in the current implementation, ZeRO 1 and 2 share almost the same implementation (`stage_1_and_2.py`). Features like `overlap_comm` and `contiguous_gradients` can also be enabled for ZeRO 1 (Please correct me if I made a mistake). With this PR, turning on `overlap_comm` and `contiguous_gradients` for ZeRO 1 on the [SFT task](https://github.com/microsoft/DeepSpeedExamples/tree/master/applications/DeepSpeed-Chat/training/step1_supervised_finetuning) produces exactly the same training curve as the latest master.  I also see a ~1.05x e2e speedup by overlapping backward and gradient all-reduce. I can confirm by the trace that backward and all-reduce do overlap, and the separate gradients are indeed copied to a flat buffer. These options are also effective for ZeRO 1.   Related issue: deepspeedai#2295 Co-authored-by: Olatunji Ruwase <olruwase@microsoft.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Uh oh!
There was an error while loading. Please reload this page.