Skip to content
This repository has been archived by the owner on Nov 17, 2023. It is now read-only.

Barrier for Horovod KV Store API #21217

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions python/mxnet/kvstore/horovod.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
""" Key value store interface of MXNet for Horovod """
from __future__ import absolute_import
from .base import KVStoreBase
from ..ndarray import empty

__all__ = ['Horovod']

Expand Down Expand Up @@ -159,3 +160,16 @@ def local_rank(self):
def num_workers(self):
import horovod.mxnet as hvd
return hvd.size()

def _barrier(self):
"""Invokes global barrier among all worker nodes.

For example, assume there are `n` machines. We would like machine `0` to first
`init` the values and then have all the workers `pull` the initialized value.
Before pulling, we can place invoke `_barrier()` to guarantee that the
initialization is finished.
"""
import horovod.mxnet as hvd
request = empty(0)
hvd.allreduce_(request, name='_barrier')
request.wait_to_read()