APPFL Aggregator¶
Functionalities¶
The APPFL Aggregator is used for aggregating one or more client local model(s) to update the global model. Depending on the synchroneity of the FL algorithm, the aggregator can take
only one client model to update the global model (for asynchronous FL)
a list of client models to update the global model (for synchronous FL)
one or a list of client models to update the global model (for asynchronous FL)
The aggregator has the following three main functionalities.
class BaseAggregator:
@abc.abstractmethod
def aggregate(self, *args, **kwargs) -> Union[Dict, OrderedDict, Tuple[Union[Dict, OrderedDict], Dict]]:
"""
Aggregate local model(s) from clients and return the global model
"""
pass
@abc.abstractmethod
def get_parameters(self, **kwargs) -> Union[Dict, OrderedDict, Tuple[Union[Dict, OrderedDict], Dict]]:
"""
Return global model parameters
"""
pass
def set_client_sample_size(self, client_id: Union[str, int], sample_size: int):
"""
Set the sample size of a client
"""
if not hasattr(self, "client_sample_size"):
self.client_sample_size = {}
self.client_sample_size[client_id] = sample_size
To define a new aggregate, you need to inherit the BaseAggregator
class and implement the aggregate
and get_parameters
methods. You can also define additional methods as needed.
Available Aggregators¶
All available aggregators are defined in the appfl.algorithm.aggregator
module, including:
FedAvgAggregator
: [Synchronous] Federated Averaging (FedAvg) aggregatorFedAvgMAggregator
: [Synchronous] Federated Averaging with Momentum (FedAvgM) aggregatorFedYogiAggregator
: [Synchronous] Federated Yogi (FedYogi) aggregatorFedAdamAggregator
: [Synchronous] Federated Adam (FedAdam) aggregatorFedAdagradAggregator
: [Synchronous] Federated Adagrad (FedAdagrad) aggregatorFedAsyncAggregator
: [Asynchronous] Federated Asynchronous (FedAsync) aggregatorFedBuffAggregator
: [Asynchronous] Federated Buffered (FedBuff) aggregatorFedCompassAggregator
: [Asynchronous] FedCompass aggregatorICEADMMAggregator
: [Synchronous] ICEADMM aggregatorIIADMMAggregator
: [Synchronous] IIADMM aggregator