Jump to content

Federated Learning: Difference between revisions

From Edge Computing Wiki
No edit summary
Line 1: Line 1:
=== Overview ===
=== Overview ===
Federated Learning (FL) is a machine learning paradigm that enables multiple clients—such as smartphones, IoT devices, and edge sensors—to collaboratively train a shared model while retaining all data locally. Instead of transferring raw data to a central server, FL allows each device to compute updates based on its own data and send only model parameters (such as gradients or weights) to an aggregator.
Federated Learning (FL) is a decentralized learning framework where multiple clients—such as smartphones, IoT devices, or sensors—collaboratively train a machine learning model without exchanging their raw data. Instead, model updates are exchanged and aggregated, which significantly improves data privacy and reduces network congestion.


Edge Computing (EC), on the other hand, brings computational power closer to the source of data generation. When FL is deployed within EC environments, it enables intelligent, low-latency, and privacy-preserving model training across a highly distributed infrastructure.
When deployed in Edge Computing (EC) environments, FL allows training to occur close to where data is generated, enabling real-time, low-latency, and privacy-aware intelligence across a distributed infrastructure [1].


FL in edge computing is particularly relevant for applications involving sensitive data, intermittent connectivity, and massive device heterogeneity, such as in healthcare, autonomous systems, smart cities, and industrial automation [1].
=== Background ===
In traditional machine learning, all data must be collected and stored centrally before training begins. This is impractical for edge devices, where bandwidth is limited, privacy is crucial, and latency is sensitive. FL solves this by keeping data local and only sharing learned parameters.


=== Background ===
The FL process follows an iterative pattern:
# The server initializes a global model.
# Edge devices download the model and train it locally on their private datasets.
# Devices send their learned model parameters to the server.
# The server aggregates these updates and redistributes a new global model.
# The process repeats for multiple rounds until the model converges.
 
This process is mathematically formalized using global and local loss functions, which are optimized collaboratively across all clients.
 
=== Architectures ===
FL can follow different system structures depending on the deployment setting.
 
'''Centralized''': A single central server orchestrates the learning process. It distributes the model and collects updates. While easy to manage, this introduces a single point of failure [1].
 
'''Decentralized''': Clients communicate directly using peer-to-peer protocols. This removes reliance on a central server but complicates synchronization and increases communication cost [2].
 
'''Hierarchical''': Intermediate edge servers aggregate updates from nearby clients and send these to the cloud. This balances scalability and communication efficiency, especially in smart cities and industrial systems [1][3].


Traditional machine learning typically relies on centralizing data in cloud servers for model training. However, this approach becomes infeasible in edge environments due to high communication costs, latency constraints, and regulatory concerns related to user privacy.
=== Aggregation Algorithms ===


To address these limitations, FL introduces a decentralized alternative. The FL pipeline usually proceeds as follows:
The most foundational mathematical concept in FL is the global optimization objective. Let \( F(w) \) be the global loss function, where \( w \) is the model parameter vector. This objective is defined as a weighted average of the loss functions of all participating clients:
* A global model is initialized and sent to participating edge devices.
* Each device trains the model locally using its own dataset.
* Devices send updated model parameters to a central or distributed aggregator.
* The server aggregates the updates and distributes a new global model.
* The process repeats for several rounds until convergence.


This decentralized approach significantly reduces the amount of data that must be transmitted, minimizes privacy risks, and enables real-time local intelligence [1][3].
:<math>F(w) = \sum_{k=1}^{N} \lambda_k F_k(w)</math>


=== Architectures ===
Here, \( F_k(w) \) is the local loss function for client \( k \), and \( \lambda_k = \frac{n_k}{n} \) represents the weight for each client, proportional to the number of local data samples \( n_k \) [3].


FL in edge computing can be structured using various system architectures depending on deployment goals and infrastructure capabilities.
The most widely used aggregation method is **Federated Averaging (FedAvg)**, where each client performs multiple steps of local gradient descent before sending updates to the server. The server then performs a weighted average of all updates:


'''Centralized Architecture''': In this setup, a central server coordinates all client updates. Clients receive the global model from the server, train locally, and return model updates. While simple to implement, this architecture introduces a single point of failure and scalability concerns [1].
:<math>w^{t+1}_C = \sum_{k=1}^{K} \lambda_k w_k</math>


'''Decentralized Architecture''': In contrast, this model eliminates the central server entirely. Clients communicate directly using peer-to-peer protocols or blockchain mechanisms. Although this enhances fault tolerance and removes centralized trust requirements, it increases communication overhead and complexity [2].
This formula produces the next version of the global model \( w^{t+1}_C \), based on local updates \( w_k \) from \( K \) participating clients in round \( t \) [3].


'''Hierarchical Architecture''': This multi-level approach incorporates edge servers between clients and the cloud. Clients send their updates to a local edge server, which performs partial aggregation. The cloud server then completes the aggregation across edge nodes. This structure supports scalability, reduces latency, and optimizes communication costs [1][3].
However, FedAvg can struggle in scenarios where the data across clients is non-identically distributed (non-IID). To overcome this, **FedProx** introduces a proximity term into each client's objective to discourage divergence from the global model. This is formalized as:


=== Aggregation Algorithms ===
:<math>F_k(w) = \mathbb{E}_{x_k \sim D_k} [f(w_k; x_k)] + \rho \| w_k - w^t_C \|^2</math>


Once local model updates are received, an aggregator must combine them into a single global model. Several aggregation techniques exist, each with different assumptions and trade-offs.
The term \( \rho \| w_k - w^t_C \|^2 \) penalizes clients for straying too far from the global model \( w^t_C \). The parameter \( \rho \) controls the strength of this regularization [3].


'''FedAvg''': Federated Averaging is the foundational algorithm in FL. Each client performs local training and sends updated weights, which are averaged by the server. This method is simple and effective under balanced data conditions [3].
During local training, clients use this regularized loss to update their models using gradient descent:


'''FedProx''': An extension of FedAvg, FedProx introduces a proximal term to control how far local updates can deviate from the global model. It is better suited for heterogeneous data distributions and variable client capabilities [3].
:<math>w_k \leftarrow w_k - \eta \cdot \frac{1}{B} \sum_{x_i \in \mathcal{I}_k} \left( \nabla f(w_k; x_i) + 2\rho (w_k - w^t_C) \right)</math>


'''FedOpt''': This family of algorithms uses adaptive optimization techniques (e.g., FedAdam, FedYogi) at the server side to improve convergence, especially under non-IID data and unstable participation [3].
Where \( \mathcal{I}_k \) is a local mini-batch, \( \eta \) is the learning rate, and \( B \) is the batch size [3].


=== Communication Efficiency ===
=== Communication Efficiency ===
In edge computing scenarios, bandwidth is limited and transmission energy is costly. FL addresses this with several optimizations to reduce communication load.


Communication overhead is one of the primary bottlenecks in FL systems. Edge devices often have limited bandwidth and power, making it essential to reduce transmission costs.
Quantization reduces the size of transmitted updates by lowering numerical precision. Sparsification sends only the most important updates (e.g., top-k gradients), and periodic communication allows clients to perform several local updates before transmitting.


Several strategies address this issue:
Another common practice is **client sampling**, where only a fraction of clients are chosen to participate in each training round, balancing quality and cost.
* '''Quantization''': Compresses model updates by reducing their precision.
* '''Sparsification''': Sends only the most significant gradients or weights.
* '''Client Sampling''': Limits the number of devices participating in each round to balance quality and cost.
* '''Periodic Updates''': Devices perform several local training steps before communicating with the server [3].


These techniques ensure that FL remains viable even in bandwidth-constrained environments.
'''Comparison: Federated vs Traditional Learning'''
 
'''Table: Federated vs Traditional Machine Learning'''


{| class="wikitable"
{| class="wikitable"
|+ Key Differences
|+ Federated Learning vs Traditional ML
! Characteristic !! Federated Learning !! Traditional Learning
! Feature !! Federated Learning !! Traditional Learning
|-
|-
| Data Location || Remains on device || Centralized in cloud
| Data location || On-device || Central server
|-
|-
| Privacy Risk || Low || High
| Privacy risk || Low || High
|-
|-
| Communication Overhead || Low (model updates only) || High (full dataset transfer)
| Bandwidth usage || Low || High
|-
|-
| Latency || Low (local processing) || High (remote processing)
| Latency || Low (edge-based) || High (cloud-based)
|-
|-
| Failure Sensitivity || Medium to high || High (central point of failure)
| Trust model || Distributed || Centralized
|}
|}


=== Privacy and Security ===
=== Privacy and Security ===


Although FL enhances privacy by design, it is still susceptible to various attacks and leakages. Adversaries could attempt to infer private data from model updates or disrupt training through malicious contributions.
Although FL is designed with privacy in mind, it is still vulnerable to attacks like gradient leakage, model poisoning, and backdoor injection. To address this, various mathematical and cryptographic techniques are used.


To mitigate such risks, FL systems often implement the following security mechanisms:
'''Differential Privacy (DP)''' guarantees that the output of a computation is statistically similar regardless of whether any one individual’s data is included. The standard DP definition is:
* '''Differential Privacy''': Adds controlled noise to updates, making it mathematically improbable to reconstruct individual data points.
* '''Secure Aggregation''': Ensures that only the final aggregated model is visible to the server, not individual contributions.
* '''Homomorphic Encryption''': Allows the server to compute on encrypted updates without decrypting them, providing end-to-end privacy [1][4].


Additionally, trust models and anomaly detection algorithms are used to identify and exclude clients that submit poisoned or inconsistent updates [2].
:<math>P(A(D) \in S) \leq e^\epsilon P(A(D') \in S) + \delta</math>
 
Here, \( D \) and \( D' \) are datasets that differ by one user’s record, \( A \) is the algorithm, \( \epsilon \) is the privacy budget, and \( \delta \) is the failure probability [4].
 
'''Secure Aggregation''' ensures that the server cannot see any individual update, only the final sum. This can be achieved using homomorphic encryption. For example, in additive homomorphic schemes:
 
:<math>Enc(a) \cdot Enc(b) = Enc(a + b)</math>
 
This allows the server to perform aggregation directly on encrypted data without accessing the unencrypted updates [4].


=== Applications ===
=== Applications ===


The integration of FL into edge computing enables numerous real-world applications across domains:
In healthcare, hospitals use FL to build disease prediction and medical image analysis models without sharing patient records. This improves diagnosis while preserving compliance with laws such as GDPR and HIPAA [1].
 
In '''healthcare''', FL allows hospitals to collaboratively train models for disease prediction or medical imaging without exposing patient data. This ensures compliance with laws like HIPAA and GDPR while enabling higher diagnostic accuracy [1].


In the domain of '''autonomous vehicles''', each car can locally learn from its environment and contribute to a global driving policy, improving safety and adaptability without sharing sensitive sensor data.
Autonomous vehicles use FL to collaboratively learn driving models across a fleet. Each car collects data about road conditions and object recognition, trains a local model, and shares updates for global improvement—without transmitting any raw video or location data.


'''Smart cities''' use FL to enable intelligent coordination across traffic systems, environmental monitoring sensors, and surveillance infrastructure. These models are continuously refined based on localized data while preserving citizen privacy [1][4].
Smart cities implement FL across infrastructure like traffic lights, pollution sensors, and utility meters. Local learning reduces latency and enhances citizen privacy [1][4].


'''Personalized mobile applications''' such as keyboard prediction, voice assistants, and fitness tracking rely on FL to customize models per user without centralized data storage.
Mobile applications like keyboard prediction and fitness tracking benefit from personalized learning without compromising user data. Devices such as smartwatches and phones contribute to a shared model while maintaining user confidentiality.


'''Industrial IoT''' environments leverage FL for predictive maintenance, fault detection, and energy optimization using local machine data.
In the Industrial IoT (IIoT), FL allows for real-time fault detection and predictive maintenance using machine logs and sensor data. Proprietary information stays protected while models continue to improve collaboratively.


=== Challenges ===
=== Challenges ===


Despite its promise, federated learning faces several challenges in real-world deployment.
Despite its potential, FL faces several technical challenges.
 
'''Scalability''' is a key concern. Coordinating millions of edge clients, especially with intermittent connectivity and device churn, requires robust communication protocols and efficient update scheduling.


'''Data heterogeneity''' further complicates training, as devices have highly skewed, non-IID data. Standard aggregation methods may fail to produce generalized models under these conditions.
Scalability remains an issue due to variable device availability, network unreliability, and model complexity. Techniques like asynchronous updates and hierarchical aggregation are actively being researched.


'''Security vulnerabilities''' such as model poisoning, backdoor insertion, and gradient inversion attacks pose serious threats to FL systems. Continuous research into robust aggregation and client verification is necessary [2].
Client heterogeneity causes problems because not all devices are equal in terms of compute power, battery life, or data quality. Handling non-IID data and creating adaptive participation strategies are critical areas of focus.


'''Incentivization''' remains an open question. Since FL consumes device resources (CPU, memory, battery), mechanisms must be developed to reward honest participation, especially in voluntary deployments.
Security is a major concern. Adversaries may launch poisoning attacks by injecting malicious updates, or attempt gradient inversion to recover private training data. Countermeasures include robust aggregation, anomaly detection, and use of secure hardware enclaves [2].


'''Interoperability''' is another practical issue. FL must operate across devices with varying hardware, software, and network conditions. Standardized APIs, lightweight frameworks, and cross-platform tools are required for seamless deployment [1][3].
Incentivizing participation is another open problem. FL consumes device resources, so fair contribution tracking and reward mechanisms—such as token systems or FL marketplaces—are essential for long-term viability.


=== References ===
=== References ===

Revision as of 00:14, 2 April 2025

Overview

Federated Learning (FL) is a decentralized learning framework where multiple clients—such as smartphones, IoT devices, or sensors—collaboratively train a machine learning model without exchanging their raw data. Instead, model updates are exchanged and aggregated, which significantly improves data privacy and reduces network congestion.

When deployed in Edge Computing (EC) environments, FL allows training to occur close to where data is generated, enabling real-time, low-latency, and privacy-aware intelligence across a distributed infrastructure [1].

Background

In traditional machine learning, all data must be collected and stored centrally before training begins. This is impractical for edge devices, where bandwidth is limited, privacy is crucial, and latency is sensitive. FL solves this by keeping data local and only sharing learned parameters.

The FL process follows an iterative pattern:

  1. The server initializes a global model.
  2. Edge devices download the model and train it locally on their private datasets.
  3. Devices send their learned model parameters to the server.
  4. The server aggregates these updates and redistributes a new global model.
  5. The process repeats for multiple rounds until the model converges.

This process is mathematically formalized using global and local loss functions, which are optimized collaboratively across all clients.

Architectures

FL can follow different system structures depending on the deployment setting.

Centralized: A single central server orchestrates the learning process. It distributes the model and collects updates. While easy to manage, this introduces a single point of failure [1].

Decentralized: Clients communicate directly using peer-to-peer protocols. This removes reliance on a central server but complicates synchronization and increases communication cost [2].

Hierarchical: Intermediate edge servers aggregate updates from nearby clients and send these to the cloud. This balances scalability and communication efficiency, especially in smart cities and industrial systems [1][3].

Aggregation Algorithms

The most foundational mathematical concept in FL is the global optimization objective. Let \( F(w) \) be the global loss function, where \( w \) is the model parameter vector. This objective is defined as a weighted average of the loss functions of all participating clients:

<math>F(w) = \sum_{k=1}^{N} \lambda_k F_k(w)</math>

Here, \( F_k(w) \) is the local loss function for client \( k \), and \( \lambda_k = \frac{n_k}{n} \) represents the weight for each client, proportional to the number of local data samples \( n_k \) [3].

The most widely used aggregation method is **Federated Averaging (FedAvg)**, where each client performs multiple steps of local gradient descent before sending updates to the server. The server then performs a weighted average of all updates:

<math>w^{t+1}_C = \sum_{k=1}^{K} \lambda_k w_k</math>

This formula produces the next version of the global model \( w^{t+1}_C \), based on local updates \( w_k \) from \( K \) participating clients in round \( t \) [3].

However, FedAvg can struggle in scenarios where the data across clients is non-identically distributed (non-IID). To overcome this, **FedProx** introduces a proximity term into each client's objective to discourage divergence from the global model. This is formalized as:

<math>F_k(w) = \mathbb{E}_{x_k \sim D_k} [f(w_k; x_k)] + \rho \| w_k - w^t_C \|^2</math>

The term \( \rho \| w_k - w^t_C \|^2 \) penalizes clients for straying too far from the global model \( w^t_C \). The parameter \( \rho \) controls the strength of this regularization [3].

During local training, clients use this regularized loss to update their models using gradient descent:

<math>w_k \leftarrow w_k - \eta \cdot \frac{1}{B} \sum_{x_i \in \mathcal{I}_k} \left( \nabla f(w_k; x_i) + 2\rho (w_k - w^t_C) \right)</math>

Where \( \mathcal{I}_k \) is a local mini-batch, \( \eta \) is the learning rate, and \( B \) is the batch size [3].

Communication Efficiency

In edge computing scenarios, bandwidth is limited and transmission energy is costly. FL addresses this with several optimizations to reduce communication load.

Quantization reduces the size of transmitted updates by lowering numerical precision. Sparsification sends only the most important updates (e.g., top-k gradients), and periodic communication allows clients to perform several local updates before transmitting.

Another common practice is **client sampling**, where only a fraction of clients are chosen to participate in each training round, balancing quality and cost.

Comparison: Federated vs Traditional Learning

Federated Learning vs Traditional ML
Feature Federated Learning Traditional Learning
Data location On-device Central server
Privacy risk Low High
Bandwidth usage Low High
Latency Low (edge-based) High (cloud-based)
Trust model Distributed Centralized

Privacy and Security

Although FL is designed with privacy in mind, it is still vulnerable to attacks like gradient leakage, model poisoning, and backdoor injection. To address this, various mathematical and cryptographic techniques are used.

Differential Privacy (DP) guarantees that the output of a computation is statistically similar regardless of whether any one individual’s data is included. The standard DP definition is:

<math>P(A(D) \in S) \leq e^\epsilon P(A(D') \in S) + \delta</math>

Here, \( D \) and \( D' \) are datasets that differ by one user’s record, \( A \) is the algorithm, \( \epsilon \) is the privacy budget, and \( \delta \) is the failure probability [4].

Secure Aggregation ensures that the server cannot see any individual update, only the final sum. This can be achieved using homomorphic encryption. For example, in additive homomorphic schemes:

<math>Enc(a) \cdot Enc(b) = Enc(a + b)</math>

This allows the server to perform aggregation directly on encrypted data without accessing the unencrypted updates [4].

Applications

In healthcare, hospitals use FL to build disease prediction and medical image analysis models without sharing patient records. This improves diagnosis while preserving compliance with laws such as GDPR and HIPAA [1].

Autonomous vehicles use FL to collaboratively learn driving models across a fleet. Each car collects data about road conditions and object recognition, trains a local model, and shares updates for global improvement—without transmitting any raw video or location data.

Smart cities implement FL across infrastructure like traffic lights, pollution sensors, and utility meters. Local learning reduces latency and enhances citizen privacy [1][4].

Mobile applications like keyboard prediction and fitness tracking benefit from personalized learning without compromising user data. Devices such as smartwatches and phones contribute to a shared model while maintaining user confidentiality.

In the Industrial IoT (IIoT), FL allows for real-time fault detection and predictive maintenance using machine logs and sensor data. Proprietary information stays protected while models continue to improve collaboratively.

Challenges

Despite its potential, FL faces several technical challenges.

Scalability remains an issue due to variable device availability, network unreliability, and model complexity. Techniques like asynchronous updates and hierarchical aggregation are actively being researched.

Client heterogeneity causes problems because not all devices are equal in terms of compute power, battery life, or data quality. Handling non-IID data and creating adaptive participation strategies are critical areas of focus.

Security is a major concern. Adversaries may launch poisoning attacks by injecting malicious updates, or attempt gradient inversion to recover private training data. Countermeasures include robust aggregation, anomaly detection, and use of secure hardware enclaves [2].

Incentivizing participation is another open problem. FL consumes device resources, so fair contribution tracking and reward mechanisms—such as token systems or FL marketplaces—are essential for long-term viability.

References

  1. Abreha, H.G., Hayajneh, M., & Serhani, M.A. (2022). Federated Learning in Edge Computing: A Systematic Survey. Sensors, 22(2), 450.
  2. Lyu, L., Yu, H., & Yang, Q. (2020). Threats to Federated Learning: A Survey. arXiv preprint arXiv:2003.02133.
  3. Li, T., Sahu, A.K., Talwalkar, A., & Smith, V. (2020). Federated Learning: Challenges, Methods, and Future Directions. IEEE Signal Processing Magazine, 37(3), 50–60.
  4. Kairouz, P., et al. (2019). Advances and Open Problems in Federated Learning. arXiv preprint arXiv:1912.04977.