fedlab_core.client.topology

Module Contents

Classes

ClientCommunicationTopology

Abstract class

ClientSyncTop

Synchronise communication class

class fedlab_core.client.topology.ClientCommunicationTopology(backend_handler, server_addr, world_size, rank, dist_backend)

Bases: torch.multiprocessing.Process

Abstract class

If you want to define your own Network Topology, please be sure your class should subclass it and OVERRIDE its methods.

Example

please read the code of ClientSyncTop

abstract run(self)

Please override this function

abstract on_receive(self, sender, message_code, payload)

Please override this function

abstract synchronize(self)

Please override this function

class fedlab_core.client.topology.ClientSyncTop(backend_handler, server_addr, world_size, rank, dist_backend='gloo', logger_file='clientLog', logger_name='')

Bases: fedlab_core.client.topology.ClientCommunicationTopology

Synchronise communication class

This is the top class in our framework which is mainly responsible for network communication of CLIENT! Synchronize with server following agreements defined in run().

Parameters
  • backend_handler – Subclass of ClientBackendHandler, manages training and evaluation of local model on each

  • client.

  • server_addr (tuple) – Address of server in form of (SERVER_ADDR, SERVER_IP)

  • world_size (int) – Number of client processes participating in the job for torch.distributed initialization

  • rank (int) – Rank of the current client process for torch.distributed initialization

  • dist_backend (str or Backend) – backend of torch.distributed. Valid values include mpi, gloo,

  • nccl. Default (and) – "gloo"

  • logger_file (str, optional) – Path to the log file for all clients of ClientSyncTop class. Default: "clientLog"

  • logger_name (str, optional) – Class name to initialize logger

:raises Errors raised by torch.distributed.init_process_group():

Example

TODO

run(self)

Main procedure of each client is defined here: 1. client waits for data from server 2. after receiving data, client will train local model 3. client will synchronize with server actively

on_receive(self, sender, message_code, payload)

Actions to perform on receiving new message, including local training

Parameters
  • sender (int) – Index of sender

  • message_code (MessageCode) – Agreements code defined in MessageCode class

  • payload (torch.Tensor) – Serialized model parameters

synchronize(self)

Synchronize local model with server actively

Parameters

buffer – Serialized model parameters

Returns

None

Raises

None

_waiting(self)