Skip to content

Commit

Permalink
Minor fixes after review
Browse files Browse the repository at this point in the history
  • Loading branch information
Andreas Hellander committed Apr 30, 2024
1 parent 25b7499 commit 2c1b794
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
8 changes: 3 additions & 5 deletions docs/aggregators.rst
Original file line number Diff line number Diff line change
Expand Up @@ -86,17 +86,15 @@ A developer can extend FEDn with his/her own Aggregator(s) by implementing the i
**on_model_update**

The ``on_model_update`` callback recieves the model update messages from clients (including all metadata) and can be used to perform validation and
potential transformation of the model update before it is places on the aggregation queue (see image above).
The base class implements a default callback that checks that all metadata assumed by the aggregation algorithms FedAvg and FedOpt
is available. The callback could also be used to implement custom pre-processing and additional checks including strategies
potential transformation of the model update before it is placed on the aggregation queue (see image above).
The base class implements a default callback that checks that all metadata assumed by the aggregation algorithms FedAvg and FedOpt is available. The callback could also be used to implement custom pre-processing and additional checks including strategies
to filter out updates that are suspected to be corrupted or malicious.

**combine_models**

When a certain criteria is met, e.g. if all clients have sent updates, or the round has times out, the ``combine_model_update`` method
processes the model update queue, producing an aggregated model. This is the main extension point where the
numerical details of the aggregation scheme is implemented. The best way to understand how to implement this method
is to study the built-in aggregation algorithms:
numerical details of the aggregation scheme is implemented. The best way to understand how to implement this method is to study the built-in aggregation algorithms:

- :py:mod:`fedn.network.combiner.aggregators.fedavg` (weighted average of parameters)
- :py:mod:`fedn.network.combiner.aggregators.fedopt` (compute pseudo-gradients and apply a server-side optmizer)
Expand Down
3 changes: 2 additions & 1 deletion fedn/fedn/network/combiner/aggregators/fedopt.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ def __init__(self, storage, server, modelservice, round_handler):
super().__init__(storage, server, modelservice, round_handler)

self.name = "fedopt"
# To store momentum
self.v = None
self.m = None

Expand Down Expand Up @@ -148,7 +149,7 @@ def combine_models(self, helper=None, delete_models=True, parameters=None):
model = self.serveropt_adagrad(helper, pseudo_gradient, model_old, parameters)
else:
logger.error("Unsupported server optimizer passed to FedOpt.")
return
return None, data

data['nr_aggregated_models'] = nr_aggregated_models

Expand Down

0 comments on commit 2c1b794

Please sign in to comment.