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

How the ranks of a distributed training exchange numbers. More...

#include <communicator.h>

Inheritance diagram for ppo_distributed::Communicator:

Public Member Functions

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.

Detailed Description

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.

Constructor & Destructor Documentation

◆ ~Communicator()

Member Function Documentation

◆ all_gather()

virtual std::vector< std::string > bitrl::rl::distributed::Communicator::all_gather ( const std::string & mine)
pure virtual

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

◆ all_reduce_sum()

template<typename T>
void bitrl::rl::distributed::Communicator::all_reduce_sum ( std::vector< T > & values)

Replace values with the sum of every rank's values.

◆ barrier()

Return once every rank has called it.

◆ broadcast() [1/2]

virtual std::string bitrl::rl::distributed::Communicator::broadcast ( const std::string & bytes,
uint_t root )
pure virtual

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

◆ broadcast() [2/2]

template<typename T>
void bitrl::rl::distributed::Communicator::broadcast ( std::vector< T > & values,
uint_t root )

Replace values with root's.

◆ rank()

virtual uint_t bitrl::rl::distributed::Communicator::rank ( ) const
pure virtualnoexcept

◆ world_size()

virtual uint_t bitrl::rl::distributed::Communicator::world_size ( ) const
pure virtualnoexcept

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