manager#
Module Contents#
Base class of ServerManager. |
|
Synchronous communication |
|
Asynchronous communication network manager for server |
- DEFAULT_SERVER_RANK = 0#
- class ServerManager(network: fedlab.core.network.DistNetwork, handler: fedlab.core.server.handler.ServerHandler, mode: str = 'LOCAL')#
Bases:
fedlab.core.network_manager.NetworkManager
Base class of ServerManager.
- Parameters:
network (DistNetwork) – Network configuration and interfaces.
handler (ServerHandler) – Performe global model update procedure.
- setup()#
Initialization Stage.
Server accept local client num report from client manager.
Init a coordinator for client_id -> rank mapping.
- 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:
activate clients for current training round.
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
andNetworkManager
.- 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
.