nvflare.app_common.workflows.fedavg module

class FedAvg(*args, **kwargs)[source]

Bases: BaseFedAvg

Controller for FedAvg Workflow. Note: This class is based on the experimental ModelController. Implements [FederatedAveraging](https://arxiv.org/abs/1602.05629).

Provides the implementations for the run routine, controlling the main workflow:
  • def run(self)

The parent classes provide the default implementations for other routines.

Parameters:
  • min_clients (int, optional) – The minimum number of clients responses before Workflow starts to wait for wait_time_after_min_received. Note that the workflow will move forward when all available clients have responded regardless of this value. Defaults to 1000.

  • num_rounds (int, optional) – The total number of training rounds. Defaults to 5.

  • persistor_id (str, optional) – ID of the persistor component. Defaults to “persistor”.

  • ignore_result_error (bool, optional) – whether this controller can proceed if client result has errors. Defaults to False.

  • allow_empty_global_weights (bool, optional) – whether to allow empty global weights. Some pipelines can have empty global weights at first round, such that clients start training from scratch without any global info. Defaults to False.

  • task_check_period (float, optional) – interval for checking status of tasks. Defaults to 0.5.

  • persist_every_n_rounds (int, optional) – persist the global model every n rounds. Defaults to 1. If n is 0 then no persist.

FLModel based controller.

Parameters:
  • min_clients (int, optional) – The minimum number of clients responses before Workflow starts to wait for wait_time_after_min_received. Note that the workflow will move forward when all available clients have responded regardless of this value. Defaults to 1000.

  • num_rounds (int, optional) – The total number of training rounds. Defaults to 5.

  • persistor_id (str, optional) – ID of the persistor component. Defaults to “persistor”.

  • ignore_result_error (bool, optional) – whether this controller can proceed if client result has errors. Defaults to False.

  • allow_empty_global_weights (bool, optional) – whether to allow empty global weights. Some pipelines can have empty global weights at first round, such that clients start training from scratch without any global info. Defaults to False.

  • task_check_period (float, optional) – interval for checking status of tasks. Defaults to 0.5.

  • persist_every_n_rounds (int, optional) – persist the global model every n rounds. Defaults to 1. If n is 0 then no persist.

run() None[source]

Main run routine called by the Controller’s control_flow to execute the workflow.

Returns: None.