This project aimed at designing and implementing a general framework for energy-aware federated learning, supporting both simulations and physical deployments. The framework is evaluated through multiple case studies, that showcase the benefits of the architectural design and feature set. This includes a case study of running a previously proposed carbon-aware client selection algorithm (FedZero) with real-time energy measurements. Skim through the accompanying thesis for more details on the architecture, case studies and limitations of the approach.
- Each FL Client runs its training, but is able to speak to its (local) energy system via a socket API (TCP/Unix) providing a stateless HTTP (REST) service.
- Each Client reports back on its energy consumption, battery level, etc. (which it collected through the HTTP service).
- The FL Server / Coordinator archives the information received by the clients and may take (selection) decisions based on it.
- In principle, the HTTP service of each Client could run anywhere. In a real-world scenario it would probably run on the same system as the Client, or in the same local network.
- In our case, the energy systems are simulated through
flessimbut can also include real-time measurements of the physical hardware. A central thread simulates all microgrids via Vessim, and a separate API instance is created for each microgrid that runs in a separate thread.
fleaf is the name of the framework devised in this thesis project. There are 3 components:
-
fleafapiis a low-dependency collection of interfaces that describe which methods a service should support in order to be interoperable withfleaf. -
fleaf: Federated Learning Energy-Aware FrameworkThe
fleafcomponent provides an easy-to-use integration into theflwrframework. This is done by- providing extensions to FL clients that allow them to interact with a service (cohering to the semantics of
fleafapi) to make queries about their energy usage and carbon footprint. - providing a
Strategywrapper which collects and aggregates measurements from FL clients.
- providing extensions to FL clients that allow them to interact with a service (cohering to the semantics of
-
flessim:fleafapi+vessimflessimis an implementation of afleafapiHTTP service. It provides details about the energy dynamics of a user-defined energy network through simulation usingvessim.
fleaf and flessim are independent of each other, each only depending on fleafapi.
Yet, they complement each other, making it easy to prototype energy- and carbon-aware solutions to federated learning.
- clone the repository via
git clone https://github.com/Impelon/fleaf.git - optionally use
virtualenvto make a virtual environment for python-packages - open the
codedirectory in a terminal - install requirements for
fleafandflessimviapip3 install -r fleaf/requirements.txt -r flessim/requirements.txt - install requirements for the
examplesviapip3 install -r examples/requirements.txt - start a
flessiminstance, providing a HTTP service to query about energy dynamics:python3 -m examples.flessim_simple - start an example with
flwr, demonstrating howfleafcan be used inside a federated learning project:python3 -m examples.fleaf_simple
See code/examples/fedzero for a more intricate example of how to use fleaf with an existing carbon-aware FL algorithm.