bitsim
Model, simulate, estimate and control robots in C++
Loading...
Searching...
No Matches
ppo_distributed::TCPStoreCommunicator Class Referencefinal

A Communicator through c10d::TCPStore, the key-value store that comes with libtorch. More...

#include <communicator.h>

Inheritance diagram for ppo_distributed::TCPStoreCommunicator:
Collaboration diagram for ppo_distributed::TCPStoreCommunicator:

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.

Detailed Description

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.

Constructor & Destructor Documentation

◆ TCPStoreCommunicator()

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) )
Parameters
hostwhere rank 0 runs the store
portits port
timeouthow long a call waits for the other ranks

◆ ~TCPStoreCommunicator()

Member Function Documentation

◆ all_gather()

std::vector< std::string > bitrl::rl::distributed::TCPStoreCommunicator::all_gather ( const std::string & mine)
overridevirtual

What every rank gave, in the order of the ranks.

Implements bitrl::rl::distributed::Communicator.

◆ broadcast()

std::string bitrl::rl::distributed::TCPStoreCommunicator::broadcast ( const std::string & bytes,
uint_t root )
overridevirtual

What root gave; the other ranks' bytes are ignored.

Implements bitrl::rl::distributed::Communicator.

◆ rank()

◆ world_size()


The documentation for this class was generated from the following file: