Repository navigation
Average sparse gradients by world size regardless of gradient_predivide_factor - #8772
Draft
vineethsaivs wants to merge 1 commit into
Draft
vineethsaivs wants to merge 1 commit into
vineethsaivs wants to merge 1 commit into
Conversation
sparse_allreduce scaled values by gradient_predivide_factor / dp_world_size under postscale, but unlike allreduce_bucket it never predivided before the all-gather, so with a factor other than 1 sparse gradients came out that many times the average. Signed-off-by: Vineeth Sai <vineethsai4444@gmail.com>
This branch has not been deployed
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.
With
gradient_predivide_factorset to anything but 1, sparse gradients (for examplenn.Embedding(sparse=True)) come out that many times the data-parallel average. Dense gradients are fine.allreduce_bucketdivides by the factor before the all-reduce and multiplies byfactor / world_sizeafter it.sparse_allreducecopies only the second half: it multiplies byfactor / world_sizeand then all-gathers, with no predivide.Fix: an all-gather just concatenates, so there is nothing to protect from overflow. Scale sparse values by
1 / world_size, the same as the prescale branch already does.Test:
test_averaging_sparse_gradients.pyis now parametrized over factor 1.0 and 2.0. At 2.0 it fails on master and passes with this change. The wholesparse_tensordirectory passes (3 tests, 2 CPU ranks). yapf and flake8 are clean.