bitsim
Model, simulate, estimate and control robots in C++
Loading...
Searching...
No Matches
bitrl::rl::distributed Namespace Reference

Namespaces

namespace  detail

Classes

class  Communicator
 How the ranks of a distributed training exchange numbers. More...
class  TCPStoreCommunicator
 A Communicator through c10d::TCPStore, the key-value store that comes with libtorch. More...

Functions

std::vector< float > flatten_parameters (const std::vector< torch::Tensor > &parameters)
 The values of the parameters, one after the other.
std::vector< float > flatten_gradients (const std::vector< torch::Tensor > &parameters)
 The gradients of the parameters, one after the other; 0 where a parameter has none.
void set_parameters (const std::vector< torch::Tensor > &parameters, const std::vector< float > &values)
 Copy values, as flatten_parameters() gives them, into the parameters.
void set_gradients (const std::vector< torch::Tensor > &parameters, const std::vector< float > &values)
 Copy values, as flatten_gradients() gives them, into the gradients.
void average_gradients (Communicator &communicator, const std::vector< torch::Tensor > &parameters)
 Replace the gradients of every rank with their mean over the ranks.
void broadcast_parameters (Communicator &communicator, const std::vector< torch::Tensor > &parameters, uint_t root=0)
 Give every rank the parameters of root.
std::uint64_t parameters_checksum (const std::vector< torch::Tensor > &parameters)
 A checksum of the parameters, to tell that the ranks have the same.

Function Documentation

◆ average_gradients()

void bitrl::rl::distributed::average_gradients ( Communicator & communicator,
const std::vector< torch::Tensor > & parameters )
inline

Replace the gradients of every rank with their mean over the ranks.

◆ broadcast_parameters()

void bitrl::rl::distributed::broadcast_parameters ( Communicator & communicator,
const std::vector< torch::Tensor > & parameters,
uint_t root = 0 )
inline

Give every rank the parameters of root.

◆ flatten_gradients()

std::vector< float > bitrl::rl::distributed::flatten_gradients ( const std::vector< torch::Tensor > & parameters)
inline

The gradients of the parameters, one after the other; 0 where a parameter has none.

◆ flatten_parameters()

std::vector< float > bitrl::rl::distributed::flatten_parameters ( const std::vector< torch::Tensor > & parameters)
inline

The values of the parameters, one after the other.

◆ parameters_checksum()

std::uint64_t bitrl::rl::distributed::parameters_checksum ( const std::vector< torch::Tensor > & parameters)
inline

A checksum of the parameters, to tell that the ranks have the same.

◆ set_gradients()

void bitrl::rl::distributed::set_gradients ( const std::vector< torch::Tensor > & parameters,
const std::vector< float > & values )
inline

Copy values, as flatten_gradients() gives them, into the gradients.

◆ set_parameters()

void bitrl::rl::distributed::set_parameters ( const std::vector< torch::Tensor > & parameters,
const std::vector< float > & values )
inline

Copy values, as flatten_parameters() gives them, into the parameters.