Federated Learning deployment: Fed-BioMed

3IA Côte d'Azur
7 min readOct 5, 2023

--

In the first article of the series, we found out about what federated learning is and its potential in healthcare. In this article, we will dig into the practical deployment of a federated model.

Deploying Federated Learning from scratch is a task with multifaceted challenges. This is especially true in the healthcare domain, when hospitals are involved, due to the sensible nature of data and the technical requirements needed in the deployment.

The foremost concern for hospitals is safeguarding patient privacy, as healthcare institutions deal with sensitive medical data subject to rigorous regulations like GDPR and HIPAA. Ensuring this data remains secure throughout the learning process, from local devices to model aggregation, is complex.

Limited technical resources within healthcare settings, combined with the need for seamless integration with existing systems, can highly impact hospital resources and be an obstacle in the deployment process.

Frameworks for Federated Learning (FL) exist to smooth the implementation and deployment of this complex and specialized machine learning approach. These frameworks address the unique challenges presented by FL, making it more accessible and feasible for a wide range of applications, making it possible also to non-FL experts to approach this training methodology.

In the healthcare domain, FedBiomed provides a pre-built platform tailored to healthcare needs, by managing the implementation process, addressing data privacy concerns, and offering a collaborative environment for hospitals, making it a valuable solution to overcome the hurdles of deploying Federated Learning in the healthcare sector.

Fed-BioMed Platform

The Fed-BioMed platform emerges as a facilitator for collaboration among medical investigators, data providers, and data scientists. Its core mission is to provide secure tools for the governance of personal biomedical data and the federated training of models on such data. An important aspect stays in creating interfaces that are user-friendly, effectively catering to the needs of both non-technical medical researchers and data providers.

In the pipeline of federated learning (FL) experiment’s lifecycle, the platform helps researchers and users in the creation of a collaborative system that is easy to deploy, effective, and secure.

In every FL system, the pipeline starts with the phases of data generation and preparation, often closely aligned with specific clinical investigations. This part is delicate because requires different entities to coordinate and agree on some ground-level aspects of data representation.

After this, the project moves into the model development phase, which involves federated data preprocessing, training, validation, and the fine-tuning of hyperparameters. Fed-BioMed supports the AI deployment and the translation of these deployments within the landscape of biomedical research by providing, in addition to all the FL necessary tools, different ready-to-use modules and integration with the most common libraries for ML, like scikit-learn, pytorch, and MONAI.

A graphical description of a typical pipeline for the deployment of an FL project, from data collection to model deployment and use. Fed-BioMed provides all the tools to manage the green-shadowed steps. It also provides support to the model deployment and the inference phase.

A graphical description of a typical pipeline for the deployment of an FL project, from data collection to model deployment and use. Fed-BioMed provides all the tools to manage the green-shadowed steps. It also provides support to the model deployment and the inference phase.

Fed-BioMed main components

To provide the features described above, Fed-BioMed works with three different components, which will interact during the whole FL process: the node, the researcher, and the network. Let’s meet them one by one.

Fed-BioMed Node

Nodes are used in Fed-BioMed to represent the clients. A node stores datasets, upon which the Federated Learning Model will be trained, and executes the local training phase, upon request by the researcher.
A node requires a conda environment to be able to run. This environment provides necessary Python modules for both the task management part and the model training part. To define a new client, you need to create a node, assign it some data, and start it: your client is ready to join the collaboration now.

Fed-BioMed Researcher

A Researcher is an entity that defines the FL model and orchestrates the training.

To define a model, Researcher has to have 3 elements:

  • A TrainingPlan, containing the model definition and a method to load/pre-process data. Fed-BioMed provides standard implementations depending on the used framework (Pytorch, SKlearn…). This simplifies the coding by only requiring you to override the methods that define the specific characteristics of your experiment.
  • A Strategy, which defines how nodes are sampled in each round. If no sampling is done, this can be left empty.
  • An Aggregator, which contains the function used by the researcher itself to merge local models into the global one. For this, you can decide to define your own aggregator or use those provided by Fed-BioMed. You can find a plug-and-play version of FedAvg, FedProx, and SCAFFOLD.

Fed-BioMed Network

To connect the researcher to the nodes, Fed-BioMed uses the Network component. It is composed of a Restful HTTP server, used for sending TrainingPlan and model weights between Nodes and Researcher, and an MQTT server, used for short and fast message and Requests exchange between Node and Researcher. So once you start the network, all the communications are automatically managed by Fed-BioMed, and you don’t have to worry about it.

Fed-BioMed Workflow

Now that you know more about what Fed-BioMed is and what are its components, you may be wondering how to use it.

Pipeline representing the workflow of a Fed-BioMed experiment.

Pipeline representing the workflow of a Fed-BioMed experiment.

Details about how to install Fed-BioMed on your computer can be found on the official website at this link. The installation is based on conda and docker, and you have a step-by-step guide for all the operating systems.

Then, once the installation is completed, you can start your first FL project!

The process to set up and execute an FL training through Fed-BioMed can be summarized in 5 steps, composing what we will call the Fed-BioMed workflow:

  1. Setting up the Network and Nodes
    To set up the system, begin by starting the component, then connect one or more nodes. Each node will then connect to the system. You can launch the network by running:
    ${FEDBIOMED_DIR}/scripts/fedbiomed_run network
    While a node can be started by:
    ${FEDBIOMED_DIR}/scripts/fedbiomed_run node start
  2. Deploying dataset on Nodes
    After setting up the network, it’s essential to initiate and configure individual nodes to supply datasets for the experiments. By default, a Fed-BioMed node doesn’t contribute any datasets to experiments. By assigning datasets to a node, you specify the data that a Fed-BioMed node will offer for training future models during experiments. Each node can contain one or more datasets, which can be added by using:
    ${FEDBIOMED_DIR}/scripts/fedbiomed_run node config config.ini add
    that start an interactive process through which you can select the type of data and the data source.
  3. Write a Federated Model
    As we said above, in Fed-BioMed we have to define a training plan, a strategy, and an aggregator. This is done using the Experiment interface, which belongs to the Researcher. To do this, you need to start the Researcher:
    ${FEDBIOMED_DIR}/scripts/fedbiomed_run researcher start
    This will open a Jupyter page, in which you can start coding your training plan.
  4. Run and monitor a Federated Model
    By running the Experiment, the whole training process of FL starts. The steps (local training, model sharing, aggregation, global model sharing) are orchestrated by the Researcher through the Network. The process is described graphically in the gif below.
    Moreover, Fed-BioMed provides integration with Tensorboard, which allows to follow the training by tracking some values like the loss or the accuracy.
  5. Model retrieval and evaluation
    At the end of a federated training, the final result is a single model that is the final “global model” obtained at the last round.
    In Fed-BioMed, the Researcher can access this model, and use it for validation and/or testing purposes.

As you saw, launching your first FL project is very easy: you only need to run some commands from the terminal, and Fed-BioMed takes care of putting up the whole infrastructure. More details and a step-by-step guide on how to add datasets to the nodes and start Fed-BioMed are available at this link.

An Open Source project

Fed-BioMed is an open source project originally developed by Inria (Institut National de Recherche en Informatique et Automatique), and Université Côte d’Azur (UniCA).
Fed-BioMed is an ongoing initiative, and the code is available on GitHub.
Any contribution is welcome, and we are always looking forward to new collaborations. If you want to be part of Fed-BioMed contact our team through the email on the website or through GitHub.

As anticipated in the first article, federated learning can be reinforced in security by using some techniques like secure aggregation, which adds a security layer to the whole infrastructure. If you are curious about it, don’t miss the next article of this series!

By Lucia Innocenti (Inria) and Riccardo Taiello (Inria & EURECOM), 3IA Côte d’Azur PhD students.

--

--

3IA Côte d'Azur

3IA Côte d’Azur is one of the four French “Interdisciplinary Institutes of Artificial Intelligence”. The Institute is specialized in Health & Smart Territories.