Skip to Content
DocumentationFederated learning

Federated learning

mllabiome includes a federated learning system that allows model training across multiple sites without centralising raw data. The coordinator runs on a central server. Each participating client keeps its data locally and contributes to the global model through parameter aggregation.

The federated layer is built on top of the Flower  framework and supports XGBoost and general scikit-learn compatible models.

Architecture

Training workflow

1. Client registration

Each client site registers with the coordinator, providing a summary of its local data (number of samples, features, class distribution, sparsity):

MethodPathDescription
POST/api/clients/registerRegister a client with data summary
GET/api/clientsList registered clients
POST/api/clients/{client_id}/heartbeatSignal that the client is alive

An optional whitelist (expected_client_ids in the server configuration) restricts which client IDs are accepted.

2. Local data analysis

Each client loads its profile and metadata files locally in the browser. The frontend computes quality metrics (sparsity, class distribution, feature coverage) from the parsed file content and sends only those summary statistics to the server during registration. Raw data never leaves the client machine.

3. Feature alignment

Before training starts, the coordinator analyses the features available across all registered clients:

MethodPathDescription
GET/api/training/analyzeReturns union and intersection of client features, common metadata columns

The training request specifies a feature_strategy ("intersection" or "union") to determine the shared feature set.

Training sessions follow a consent-based protocol. The coordinator creates a proposal containing the model type, target column, number of rounds, and a code_preview showing the exact code that each client will execute:

MethodPathDescription
POST/api/training/startCreate a training proposal
POST/api/training/sessions/{id}/consentClient submits consent (accept or reject)
GET/api/training/sessionsList all training sessions

A session enters the awaiting_consent state. Each client reviews the code preview and submits a consent decision. When auto_start=true in the session configuration, training begins automatically once all expected clients have consented.

5. Training execution

When all consents are collected, the coordinator launches a Flower server. Clients connect and participate in the specified number of federated rounds:

MethodPathDescription
POST/api/training/sessions/{id}/executeManually start training
GET/api/analytics/session/{id}Session metrics, convergence status

Each round:

  1. The server distributes the current global model parameters.
  2. Each client trains locally on its own data.
  3. Clients send updated parameters back to the server.
  4. The server aggregates updates (FedAvg) into a new global model.

6. Analytics

The analytics engine tracks training progress:

MetricDescription
Feature importanceAggregated across rounds
Training curvesPer-round loss and accuracy
Client performancePer-client contribution metrics
Convergence statusWhether the global model has stabilised

Session configuration

{ "model_name": "xgboost", # "xgboost" or "random_forest" "task_type": "binary", "num_rounds": 10, "target_column": "disease", "feature_strategy": "intersection", # "intersection" or "union" "sample_id_column": "Sample", "federated_strategy": "model_aggregation", "auto_start": True, }
ParameterDescription
model_nameModel type to train across clients.
num_roundsNumber of federated aggregation rounds.
target_columnThe target variable column name in each client’s metadata.
feature_strategy"intersection" uses only features present at all sites. "union" includes all features (missing features are zero-filled).
auto_startWhen true, training starts automatically once every client has consented.

Session states

StateMeaning
pendingSession created, not yet proposed to clients
awaiting_consentProposal sent, waiting for all client consents
runningFlower server active, training in progress
completedAll rounds finished
failedAn error occurred during training
rejectedOne or more clients declined the proposal

Persistent state

The coordinator persists its state to federated_state.json in the backend directory. This file contains the client registry, active sessions, and completed session history. The state is loaded on server startup, so restarting the backend does not lose registered clients or session history.

Last updated on