-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
27 changed files
with
1,029 additions
and
228 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
FEDn is using sphinx with reStructuredText. | ||
|
||
sphinx-apidoc --ext-autodoc --module-first -o _source ../fedn/fedn ../*tests* ../*exceptions* ../*common* ../ ../fedn/fedn/network/api/server.py ../fedn/fedn/network/controller/controlbase.py | ||
sphinx-build . _build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,53 +1,63 @@ | ||
Architecture overview | ||
===================== | ||
|
||
Constructing a federated model with FEDn amounts to a) specifying the details of the client-side training code and data integrations, and b) deploying the reducer-combiner network. A FEDn network, as illustrated in the picture below, is made up of three main components: the *Reducer*, one or more *Combiners*, and a number of *Clients*. The combiner network forms the backbone of the FedML orchestration mechanism, while the Reducer provides discovery services and provides controls to coordinate training over the combiner network. By horizontally scaling the combiner network, one can meet the needs of a growing number of clients. | ||
Constructing a federated model with FEDn amounts to a) specifying the details of the client-side training code and data integrations, and b) deploying the federated network. A FEDn network, as illustrated in the picture below, is made up of components into three different tiers: the *Controller* tier (1), one or more *Combiners* in second tier (2), and a number of *Clients* in tier (3). | ||
The combiners forms the backbone of the federated ML orchestration mechanism, while the Controller tier provides discovery services and controls to coordinate training over the federated network. | ||
By horizontally scaling the number of combiners, one can meet the needs of a growing number of clients. | ||
|
||
.. image:: img/overview.png | ||
.. image:: img/FEDn_network.png | ||
:alt: FEDn network | ||
:width: 100% | ||
:align: center | ||
|
||
Main components | ||
--------------- | ||
|
||
Client | ||
...... | ||
|
||
A Client is a data node, holding private data and connecting to a Combiner to receive model update requests and model validation requests during training rounds. Importantly, clients do not require any open ingress ports. A client receives the code to be executed from the Reducer upon connecting to the network, and thus they only need to be configured prior to connection to read the local datasets during training and validation. Python3 client implementation is provided out of the box, and it is possible to write clients in a variety of languages to target different software and hardware requirements. | ||
|
||
Combiner | ||
........ | ||
The clients: tier 1 | ||
................... | ||
|
||
A combiner is an actor whose main role is to orchestrate and aggregate model updates from a number of clients during a training round. When and how to trigger such orchestration rounds are specified in the overall *compute plan* laid out by the Reducer. Each combiner in the network runs an independent gRPC server, providing RPCs for interacting with the alliance subsystem it controls. Hence, the total number of clients that can be accommodated in a FEDn network is proportional to the number of active combiners in the FEDn network. Combiners can be deployed anywhere, e.g. in a cloud or on a fog node to provide aggregation services near the cloud edge. | ||
A Client (gRPC client) is a data node, holding private data and connecting to a Combiner (gRPC server) to receive model update requests and model validation requests during training sessions. | ||
Importantly, clients uses remote procedure calls (RPC) to ask for model updates tasks, thus the clients not require any open ingress ports! A client receives the code (called package or compute package) to be executed from the *Controller* | ||
upon connecting to the network, and thus they only need to be configured prior to connection to read the local datasets during training and validation. The package is based on entry points in the client code, and can be customized to fit the needs of the user. | ||
This allows for a high degree of flexibility in terms of what kind of training and validation tasks that can be performed on the client side. Such as different types of machine learning models and framework, and even programming languages. | ||
A python3 client implementation is provided out of the box, and it is possible to write clients in a variety of languages to target different software and hardware requirements. | ||
|
||
Reducer | ||
....... | ||
The combiners: tier 2 | ||
..................... | ||
|
||
The reducer fills three main roles in the FEDn network: 1.) it lays out the overall, global training strategy and communicates that to the combiner network. It also dictates the strategy to aggregate model updates from individual combiners into a single global model, 2.) it handles global state and maintains the *model trail* - an immutable trail of global model updates uniquely defining the FedML training timeline, and 3.) it provides discovery services, mediating connections between clients and combiners. For this purpose, the Reducer exposes a standard REST API. | ||
A combiner is an actor whose main role is to orchestrate and aggregate model updates from a number of clients during a training session. | ||
When and how to trigger such orchestration are specified in the overall *compute plan* laid out by the *Controller*. | ||
Each combiner in the network runs an independent gRPC server, providing RPCs for interacting with the federated network it controls. | ||
Hence, the total number of clients that can be accommodated in a FEDn network is proportional to the number of active combiners in the FEDn network. | ||
Combiners can be deployed anywhere, e.g. in a cloud or on a fog node to provide aggregation services near the cloud edge. | ||
|
||
Services and communication | ||
-------------------------- | ||
The controller: tier 3 | ||
...................... | ||
|
||
The figure below provides a logical architecture view of the services provided by each agent and how they interact. | ||
Tier 3 does actually contain several components and services, but we tend to associate it with the *Controller* the most. The *Controller* fills three main roles in the FEDn network: | ||
|
||
.. image:: img/FEDn-arch-overview.png | ||
:alt: FEDn architecture overview | ||
:width: 100% | ||
:align: center | ||
1. it lays out the overall, global training strategy and communicates that to the combiner network. | ||
It also dictates the strategy to aggregate model updates from individual combiners into a single global model, | ||
2. it handles global state and maintains the *model trail* - an immutable trail of global model updates uniquely defining the federated ML training timeline, and | ||
3. it provides discovery services, mediating connections between clients and combiners. For this purpose, the *Controller* exposes a standard REST API both for RPC clients and servers, but also for user interfaces and other services. | ||
|
||
Tier 3 also contain a *Reducer* component, which is responsible for aggregating combiner-level models into a single global model. Further, it contains a *StateStore* database, | ||
which is responsible for storing various states of the network and training sessions. The final global model trail from a traning session is stored in the *ModelRegistry* database. | ||
|
||
|
||
Control flows and algorithms | ||
---------------------------- | ||
Notes on aggregating algorithms | ||
............................... | ||
|
||
FEDn is designed to allow customization of the FedML algorithm, following a specified pattern, or programming model. Model aggregation happens on two levels in the system. First, each Combiner can be configured with a custom orchestration and aggregation implementation, that reduces model updates from Clients into a single, *combiner level* model. Then, a configurable aggregation protocol on the Reducer level is responsible for combining the combiner-level models into a global model. By varying the aggregation schemes on the two levels in the system, many different possible outcomes can be achieved. Good staring configurations are provided out-of-the-box to help the user get started. | ||
FEDn is designed to allow customization of the FedML algorithm, following a specified pattern, or programming model. | ||
Model aggregation happens on two levels in the network. First, each Combiner can be configured with a custom orchestration and aggregation implementation, that reduces model updates from Clients into a single, *combiner level* model. | ||
Then, a configurable aggregation protocol on the *Controller* level is responsible for combining the combiner-level models into a global model. By varying the aggregation schemes on the two levels in the system, | ||
many different possible outcomes can be achieved. Good starting configurations are provided out-of-the-box to help the user get started. See API reference for more details. | ||
|
||
Hierarchical Federated Averaging | ||
................................ | ||
|
||
The currently implemented default scheme uses a local SGD strategy on the Combiner level aggregation and a simple average of models on the reducer level. This results in a highly horizontally scalable FedAvg scheme. The strategy works well with most artificial neural network (ANNs) models, and can in general be applied to models where it is possible and makes sense to form mean values of model parameters (for example SVMs). Additional FedML training protocols, including support for various types of federated ensemble models, are in active development. | ||
The currently implemented default scheme uses a local SGD strategy on the Combiner level aggregation and a simple average of models on the reducer level. | ||
This results in a highly horizontally scalable FedAvg scheme. The strategy works well with most artificial neural network (ANNs) models, | ||
and can in general be applied to models where it is possible and makes sense to form mean values of model parameters (for example SVMs). | ||
|
||
|
||
.. image:: img/HFedAvg.png | ||
:alt: FEDn architecture overview | ||
:width: 100% | ||
:align: center |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
fedn.network.api package | ||
======================== | ||
|
||
.. automodule:: fedn.network.api | ||
:members: | ||
:undoc-members: | ||
:show-inheritance: | ||
|
||
Submodules | ||
---------- | ||
|
||
fedn.network.api.client module | ||
------------------------------ | ||
|
||
.. automodule:: fedn.network.api.client | ||
:members: | ||
:undoc-members: | ||
:show-inheritance: | ||
|
||
fedn.network.api.interface module | ||
--------------------------------- | ||
|
||
.. automodule:: fedn.network.api.interface | ||
:members: | ||
:undoc-members: | ||
:show-inheritance: | ||
|
||
fedn.network.api.network module | ||
------------------------------- | ||
|
||
.. automodule:: fedn.network.api.network | ||
:members: | ||
:undoc-members: | ||
:show-inheritance: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
fedn.network.clients package | ||
============================ | ||
|
||
.. automodule:: fedn.network.clients | ||
:members: | ||
:undoc-members: | ||
:show-inheritance: | ||
|
||
Submodules | ||
---------- | ||
|
||
fedn.network.clients.client module | ||
---------------------------------- | ||
|
||
.. automodule:: fedn.network.clients.client | ||
:members: | ||
:undoc-members: | ||
:show-inheritance: | ||
|
||
fedn.network.clients.connect module | ||
----------------------------------- | ||
|
||
.. automodule:: fedn.network.clients.connect | ||
:members: | ||
:undoc-members: | ||
:show-inheritance: | ||
|
||
fedn.network.clients.package module | ||
----------------------------------- | ||
|
||
.. automodule:: fedn.network.clients.package | ||
:members: | ||
:undoc-members: | ||
:show-inheritance: | ||
|
||
fedn.network.clients.state module | ||
--------------------------------- | ||
|
||
.. automodule:: fedn.network.clients.state | ||
:members: | ||
:undoc-members: | ||
:show-inheritance: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
fedn.network.combiner.aggregators package | ||
========================================= | ||
|
||
.. automodule:: fedn.network.combiner.aggregators | ||
:members: | ||
:undoc-members: | ||
:show-inheritance: | ||
|
||
Submodules | ||
---------- | ||
|
||
fedn.network.combiner.aggregators.aggregatorbase module | ||
------------------------------------------------------- | ||
|
||
.. automodule:: fedn.network.combiner.aggregators.aggregatorbase | ||
:members: | ||
:undoc-members: | ||
:show-inheritance: | ||
|
||
fedn.network.combiner.aggregators.fedavg module | ||
----------------------------------------------- | ||
|
||
.. automodule:: fedn.network.combiner.aggregators.fedavg | ||
:members: | ||
:undoc-members: | ||
:show-inheritance: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
fedn.network.combiner package | ||
============================= | ||
|
||
.. automodule:: fedn.network.combiner | ||
:members: | ||
:undoc-members: | ||
:show-inheritance: | ||
|
||
Subpackages | ||
----------- | ||
|
||
.. toctree:: | ||
:maxdepth: 4 | ||
|
||
fedn.network.combiner.aggregators | ||
|
||
Submodules | ||
---------- | ||
|
||
fedn.network.combiner.connect module | ||
------------------------------------ | ||
|
||
.. automodule:: fedn.network.combiner.connect | ||
:members: | ||
:undoc-members: | ||
:show-inheritance: | ||
|
||
fedn.network.combiner.interfaces module | ||
--------------------------------------- | ||
|
||
.. automodule:: fedn.network.combiner.interfaces | ||
:members: | ||
:undoc-members: | ||
:show-inheritance: | ||
|
||
fedn.network.combiner.modelservice module | ||
----------------------------------------- | ||
|
||
.. automodule:: fedn.network.combiner.modelservice | ||
:members: | ||
:undoc-members: | ||
:show-inheritance: | ||
|
||
fedn.network.combiner.round module | ||
---------------------------------- | ||
|
||
.. automodule:: fedn.network.combiner.round | ||
:members: | ||
:undoc-members: | ||
:show-inheritance: | ||
|
||
fedn.network.combiner.server module | ||
----------------------------------- | ||
|
||
.. automodule:: fedn.network.combiner.server | ||
:members: | ||
:undoc-members: | ||
:show-inheritance: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
fedn.network.controller package | ||
=============================== | ||
|
||
.. automodule:: fedn.network.controller | ||
:members: | ||
:undoc-members: | ||
:show-inheritance: | ||
|
||
Submodules | ||
---------- | ||
|
||
fedn.network.controller.control module | ||
-------------------------------------- | ||
|
||
.. automodule:: fedn.network.controller.control | ||
:members: | ||
:undoc-members: | ||
:show-inheritance: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
fedn.network.dashboard package | ||
============================== | ||
|
||
.. automodule:: fedn.network.dashboard | ||
:members: | ||
:undoc-members: | ||
:show-inheritance: | ||
|
||
Submodules | ||
---------- | ||
|
||
fedn.network.dashboard.plots module | ||
----------------------------------- | ||
|
||
.. automodule:: fedn.network.dashboard.plots | ||
:members: | ||
:undoc-members: | ||
:show-inheritance: | ||
|
||
fedn.network.dashboard.restservice module | ||
----------------------------------------- | ||
|
||
.. automodule:: fedn.network.dashboard.restservice | ||
:members: | ||
:undoc-members: | ||
:show-inheritance: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
fedn.network.loadbalancer package | ||
================================= | ||
|
||
.. automodule:: fedn.network.loadbalancer | ||
:members: | ||
:undoc-members: | ||
:show-inheritance: | ||
|
||
Submodules | ||
---------- | ||
|
||
fedn.network.loadbalancer.firstavailable module | ||
----------------------------------------------- | ||
|
||
.. automodule:: fedn.network.loadbalancer.firstavailable | ||
:members: | ||
:undoc-members: | ||
:show-inheritance: | ||
|
||
fedn.network.loadbalancer.leastpacked module | ||
-------------------------------------------- | ||
|
||
.. automodule:: fedn.network.loadbalancer.leastpacked | ||
:members: | ||
:undoc-members: | ||
:show-inheritance: | ||
|
||
fedn.network.loadbalancer.loadbalancerbase module | ||
------------------------------------------------- | ||
|
||
.. automodule:: fedn.network.loadbalancer.loadbalancerbase | ||
:members: | ||
:undoc-members: | ||
:show-inheritance: |
Oops, something went wrong.