|
bitsim
Model, simulate, estimate and control robots in C++
|
A Communicator through c10d::TCPStore, the key-value store that comes with libtorch. More...
#include <communicator.h>


Public Member Functions | |
| TCPStoreCommunicator (const std::string &host, uint_t port, uint_t rank, uint_t world_size, std::chrono::milliseconds timeout=std::chrono::seconds(60)) | |
| ~TCPStoreCommunicator () override | |
| uint_t | rank () const noexcept override |
| uint_t | world_size () const noexcept override |
| std::vector< std::string > | all_gather (const std::string &mine) override |
| What every rank gave, in the order of the ranks. | |
| std::string | broadcast (const std::string &bytes, uint_t root) override |
| What root gave; the other ranks' bytes are ignored. | |
| Public Member Functions inherited from bitrl::rl::distributed::Communicator | |
| virtual | ~Communicator ()=default |
| template<typename T> | |
| void | all_reduce_sum (std::vector< T > &values) |
| Replace values with the sum of every rank's values. | |
| template<typename T> | |
| void | broadcast (std::vector< T > &values, uint_t root) |
| Replace values with root's. | |
| void | barrier () |
| Return once every rank has called it. | |
A Communicator through c10d::TCPStore, the key-value store that comes with libtorch.
Rank 0 runs the store on port of host, and every rank, rank 0 included, connects to it, so the ranks can be threads, processes, or machines that reach host. Every value a rank sends goes through the store, so every rank receives world_size() messages per call: plenty for the networks of RL, which have thousands of weights, not for networks of millions, which want a ring all-reduce such as Gloo's or MPI's behind this same interface.
The store keeps only the last two calls of every rank. On destruction every rank tells the others it is done, and rank 0 keeps the store until all have.
| bitrl::rl::distributed::TCPStoreCommunicator::TCPStoreCommunicator | ( | const std::string & | host, |
| uint_t | port, | ||
| uint_t | rank, | ||
| uint_t | world_size, | ||
| std::chrono::milliseconds | timeout = std::chrono::seconds(60) ) |
| host | where rank 0 runs the store |
| port | its port |
| timeout | how long a call waits for the other ranks |
|
overridevirtual |
What every rank gave, in the order of the ranks.
Implements bitrl::rl::distributed::Communicator.
|
overridevirtual |
What root gave; the other ranks' bytes are ignored.
Implements bitrl::rl::distributed::Communicator.
|
inlineoverridevirtualnoexcept |
Implements bitrl::rl::distributed::Communicator.
|
inlineoverridevirtualnoexcept |
Implements bitrl::rl::distributed::Communicator.