|
| virtual | ~Communicator ()=default |
| virtual uint_t | rank () const noexcept=0 |
| virtual uint_t | world_size () const noexcept=0 |
| virtual std::vector< std::string > | all_gather (const std::string &mine)=0 |
| | What every rank gave, in the order of the ranks.
|
| virtual std::string | broadcast (const std::string &bytes, uint_t root)=0 |
| | What root gave; the other ranks' bytes are ignored.
|
| template<typename T> |
| void | broadcast (std::vector< T > &values, uint_t root) |
| | Replace values with root's.
|
| template<typename T> |
| void | all_reduce_sum (std::vector< T > &values) |
| | Replace values with the sum of every rank's values.
|
| void | barrier () |
| | Return once every rank has called it.
|
How the ranks of a distributed training exchange numbers.
There are world_size() ranks, numbered from 0. Every call is collective: every rank must make the same calls, in the same order, with values of the same size, and each call returns once every rank has made it. all_reduce_sum() adds the values of the ranks in the order of the ranks, so every rank gets exactly the same sum, to the last bit, which keeps the networks of the ranks alike.
A derived class only moves bytes, with all_gather() and broadcast(); TCPStoreCommunicator moves them through libtorch's TCPStore.