client#

Package Contents#

ClientManager

Base class for ClientManager.

ActiveClientManager

Active communication NetworkManager for client in asynchronous FL pattern.

PassiveClientManager

Passive communication NetworkManager for client in synchronous FL pattern.

ORDINARY_TRAINER = 0#
SERIAL_TRAINER = 1#
class ClientManager(network: fedlab.core.network.DistNetwork, trainer: fedlab.core.model_maintainer.ModelMaintainer)#

Bases: fedlab.core.network_manager.NetworkManager

Base class for ClientManager.

ClientManager defines client activation in different communication stages.

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

  • trainer (ModelMaintainer) – Subclass of ClientTrainer or SerialClientTrainer. Provides local_process() and uplink_package. Define local client training procedure.

setup()#

Initialization stage.

ClientManager reports number of clients simulated by current client process.

class ActiveClientManager(network: fedlab.core.network.DistNetwork, trainer: fedlab.core.client.trainer.ClientTrainer, logger: fedlab.utils.Logger = None)#

Bases: ClientManager

Active communication NetworkManager for client in asynchronous FL pattern.

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

  • trainer (ClientTrainer) – Subclass of ClientTrainer. Provides local_process() and uplink_package. Define local client training procedure.

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

main_loop()#

Actions to perform on receiving new message, including local training.

  1. client requests data from server (ACTIVELY).

  2. after receiving data, client will train local model.

  3. client will synchronize with server actively.

request()#

Client request.

synchronize()#

Synchronize with server.

class PassiveClientManager(network: fedlab.core.network.DistNetwork, trainer: fedlab.core.model_maintainer.ModelMaintainer, logger: fedlab.utils.Logger = None)#

Bases: ClientManager

Passive communication NetworkManager for client in synchronous FL pattern.

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

  • trainer (ModelMaintainer) – Subclass of ClientTrainer or SerialClientTrainer. Provides local_process() and uplink_package. Define local client training procedure.

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

main_loop()#

Actions to perform when receiving a new message, including local training.

Main procedure of each client:
  1. client waits for data from server (PASSIVELY).

  2. after receiving data, client start local model training procedure.

  3. client synchronizes with server actively.

synchronize()#

Synchronize with server.