Skip to content

Commit

Permalink
torch: sync values_handle firstly in sparse_allreduce_async (#2965)
Browse files Browse the repository at this point in the history
Root cause hasn't been found out. But if values_handle is not synced
firstly, sparse_allreduce_async will be hanging in unit test.

Signed-off-by: Chongxiao Cao <chongxiaoc@uber.com>
  • Loading branch information
chongxiaoc committed Jun 10, 2021
1 parent ffcc655 commit b01bc54
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 4 additions & 1 deletion horovod/torch/mpi_ops.py
Expand Up @@ -518,8 +518,11 @@ def sparse_allreduce_async(tensor, name, op):
values_handle = allgather_async(t._values(), name=f'{name}.values')

def handle():
indices = synchronize(indices_handle)
# We need to sync values handle firstly for torch nightly >= 10.0
# Issue: https://github.com/horovod/horovod/issues/2961
values = synchronize(values_handle)
indices = synchronize(indices_handle)

values = (values / size()) if op == Average else values

if indices.dim() == 0 or values.dim() == 0:
Expand Down
2 changes: 0 additions & 2 deletions test/parallel/test_torch.py
Expand Up @@ -2421,8 +2421,6 @@ def forward(self, x):
loss.backward()
opt.step()

@pytest.mark.skipif(LooseVersion(torch.__version__) > LooseVersion('1.10.0'),
reason='https://github.com/horovod/horovod/issues/2961')
def test_async_sparse_allreduce(self):
"""Test that allgather over indices and values is equivalent to allreduce."""
hvd.init()
Expand Down

0 comments on commit b01bc54

Please sign in to comment.