Fix reducescatter() and grouped_reducescatter() to raise clean exceptions for scalar inputs #3699
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.
Checklist before submitting
Description
This fixes Horovod crashing when scalar inputs are passed to
hvd.reducescatter
orhvd.grouped_reducescatter
. Attempts to do so now raise exceptions that users can deal with appropriately.Initially I thought it would be a good idea to have
hvd.reducescatter(3.14)
do exactly the same thing ashvd.reducescatter([3.14])
, i.e., return a single-element 1D tensor on rank 0 and an empty 1D tensor on the other ranks. However, having given this some consideration, I feel that it would be confusing and potentially error prone if zero-rank inputs produced higher ranked outputs. It seems less surprising to deal with such a possibility explicitly in user code if necessary (just as it is the case withhvd.allgather
).Fixes #3698.