fl4health.servers.fedpm_server module

class FedPmServer(client_manager, fl_config, strategy, reporters=None, checkpoint_and_state_module=None, on_init_parameters_config_fn=None, server_name=None, accept_failures=True, reset_frequency=1)[source]

Bases: FlServer

__init__(client_manager, fl_config, strategy, reporters=None, checkpoint_and_state_module=None, on_init_parameters_config_fn=None, server_name=None, accept_failures=True, reset_frequency=1)[source]

Custom FL Server for the FedPM algorithm to allow for resetting the beta priors in Bayesian aggregation, as specified in http://arxiv.org/pdf/2209.15328.

Parameters:
  • client_manager (ClientManager) – Determines the mechanism by which clients are sampled by the server, if they are to be sampled at all.

  • fl_config (Config) – _description_

  • strategy (FedPm) – The aggregation strategy to be used by the server to handle client updates and other information potentially sent by the participating clients. This strategy must be of SCAFFOLD type.

  • reporters (Sequence[BaseReporter] | None, optional) – A sequence of FL4Health reporters which the server should send data to before and after each round.

  • checkpoint_and_state_module (LayerNamesServerCheckpointAndStateModule | None, optional) – This module is used to handle both model checkpointing and state checkpointing. The former is aimed at saving model artifacts to be used or evaluated after training. The latter is used to preserve training state (including models) such that if FL training is interrupted, the process may be restarted. If no module is provided, no checkpointing or state preservation will happen. Defaults to None.

  • on_init_parameters_config_fn (Callable[[int], dict[str, Scalar]] | None, optional) – Function used to configure how one asks a client to provide parameters from which to initialize all other clients by providing a Config dictionary. If this is none, then a blank config is sent with the parameter request (which is default behavior for flower servers). Defaults to None.

  • server_name (str | None, optional) – An optional string name to uniquely identify server. This name is also used as part of any state checkpointing done by the server. Defaults to None.

  • accept_failures (bool, optional) – Determines whether the server should accept failures during training or evaluation from clients or not. If set to False, this will cause the server to shutdown all clients and throw an exception. Defaults to True.

  • reset_frequency (int, optional) – Determines the frequency with which the beta priors are reset. Defaults to 1.

fit_round(server_round, timeout)[source]

This function is called at each round of federated training. The flow is generally the same as a flower server, where clients are sampled and client side training is requested from the clients that are chosen. This function simply adds a bit of logging, post processing of the results

Parameters:
  • server_round (int) – Current round number of the FL training. Begins at 1

  • timeout (float | None) – Time that the server should wait (in seconds) for responses from the clients. Defaults to None, which indicates indefinite timeout.

Returns:

The results of training

on the client sit. The first set of parameters are the AGGREGATED parameters from the strategy. The second is a dictionary of AGGREGATED metrics. The third component holds the individual (non-aggregated) parameters, loss, and metrics for successful and unsuccessful client-side training.

Return type:

tuple[Parameters | None, dict[str, Scalar], FitResultsAndFailures] | None