server#

Package Contents#

SynchronousServerManager

Synchronous communication

AsynchronousServerManager

Asynchronous communication network manager for server

class SynchronousServerManager(network: fedlab.core.network.DistNetwork, handler: fedlab.core.server.handler.ServerHandler, mode: str = 'LOCAL', logger: fedlab.utils.Logger = None)#

Bases: ServerManager

Synchronous communication

This is the top class in our framework which is mainly responsible for network communication of SERVER!. Synchronously communicate with clients following agreements defined in main_loop().

Parameters:
  • network (DistNetwork) – Network configuration and interfaces.

  • handler (ServerHandler) – Backend calculation handler for parameter server.

  • logger (Logger, optional) – Object of Logger.

main_loop()#

Actions to perform in server when receiving a package from one client.

Server transmits received package to backend computation handler for aggregation or others manipulations.

Loop:
  1. activate clients for current training round.

  2. listen for message from clients -> transmit received parameters to server handler.

Note

Communication agreements related: user can overwrite this function to customize communication agreements. This method is key component connecting behaviors of ServerHandler and NetworkManager.

Raises:

Exception – Unexpected MessageCode.

shutdown()#

Shutdown stage.

activate_clients()#

Activate subset of clients to join in one FL round

Manager will start a new thread to send activation package to chosen clients’ process rank. The id of clients are obtained from handler.sample_clients(). And their communication ranks are are obtained via coordinator.

shutdown_clients()#

Shutdown all clients.

Send package to each client with MessageCode.Exit.

Note

Communication agreements related: User can overwrite this function to define package for exiting information.

class AsynchronousServerManager(network: fedlab.core.network.DistNetwork, handler: fedlab.core.server.handler.ServerHandler, logger: fedlab.utils.Logger = None)#

Bases: ServerManager

Asynchronous communication network manager for server

This is the top class in our framework which is mainly responsible for network communication of SERVER!. Asynchronously communicate with clients following agreements defined in mail_loop().

Parameters:
  • network (DistNetwork) – Network configuration and interfaces.

  • handler (ServerHandler) – Backend computation handler for parameter server.

  • logger (Logger, optional) – Object of Logger.

main_loop()#

Communication agreements of asynchronous FL.

  • Server receive ParameterRequest from client. Send model parameter to client.

  • Server receive ParameterUpdate from client. Transmit parameters to queue waiting for aggregation.

Raises:

ValueError – invalid message code.

shutdown()#

Shutdown stage.

Close the network connection in the end.

updater_thread()#

Asynchronous communication maintain a message queue. A new thread will be started to keep monitoring message queue.

shutdown_clients()#

Shutdown all clients.

Send package to clients with MessageCode.Exit.