Federated Learning

GATE DA Relevance: Federated learning is a cutting-edge topic combining distributed systems, optimization, and privacy. GATE DA questions may focus on the FedAvg algorithm, the distinction between horizontal and vertical FL, communication efficiency strategies, and the role of differential privacy. Understand the core algorithm and its convergence properties.

1. Motivation: Why Federated Learning?

Traditional machine learning requires centralizing all training data on a single server. This approach faces several critical challenges in the modern world:

  • Privacy Regulations: Laws like GDPR, HIPAA, and CCPA restrict how personal data can be collected, stored, and transferred.
  • Data Sensitivity: Medical records, financial data, and personal communications are too sensitive to centralize.
  • Data Volume: Edge devices (smartphones, IoT sensors) generate massive data volumes that are expensive to transmit.
  • Data Sovereignty: Data may be legally required to remain within national borders.
  • Competitive Concerns: Organizations may want to collaboratively train models without sharing proprietary data.
Federated Learning (FL): A machine learning paradigm where a model is trained across multiple decentralized devices or servers holding local data samples, without exchanging the raw data. Only model updates (gradients or parameters) are communicated to a central aggregation server.
Example — Google Keyboard (Gboard): Google uses federated learning to improve next-word prediction on mobile keyboards. Each phone trains a local model on the user’s typing data, sends only the model update to Google’s server, and the server aggregates updates from millions of phones. No user’s actual text messages ever leave their device.

2. Federated Averaging (FedAvg) Algorithm

FedAvg (McMahan et al., 2017) is the foundational algorithm for federated learning. It combines local SGD with periodic model averaging.

Algorithm: Federated Averaging (FedAvg)
  1. Server initializes global model parameters w0.
  2. For each round t = 1, 2, …, T:
    1. Server selects a random subset St of K clients (out of N total).
    2. Server broadcasts current global model wt to selected clients.
    3. Each client k ∈ St performs E epochs of SGD on its local dataset Dk:
      wkt+1 = wt − η · ∇L(wt; Dk) (repeated for E epochs)
    4. Each client sends updated model wkt+1 back to the server.
    5. Server aggregates by weighted averaging:
      wt+1 = ∑k ∈ St (nk / n) · wkt+1
      where nk = number of samples on client k, n = total samples across selected clients.
  3. Return final global model wT.

2.1 Key Hyperparameters

ParameterSymbolDescriptionEffect
Client FractionCFraction of clients selected per roundHigher C → better convergence, more communication
Local EpochsESGD epochs per client per roundHigher E → fewer rounds, but risk of client drift
Local Batch SizeBMini-batch size for local SGDSmaller B → more stochasticity, potentially better generalization
Learning RateηStep size for local SGDMust be tuned carefully; may need decay
Special Case: When E = 1 and B = ∞ (full batch), FedAvg reduces to Federated SGD (FedSGD), where each client performs exactly one gradient computation and sends the gradient (rather than updated weights) to the server.

3. Communication Efficiency

Communication is the primary bottleneck in federated learning. Transmitting millions of parameters each round over mobile networks is expensive. Several strategies address this.

3.1 Compression Techniques

  • Gradient Quantization: Reduce precision of transmitted values (e.g., from 32-bit floats to 8-bit or even 1-bit). SignSGD transmits only the sign of each gradient component.
  • Gradient Sparsification: Transmit only the top-k largest gradient components (by magnitude). Residuals are accumulated locally for future rounds.
  • Structured Updates: Restrict model updates to a low-rank subspace, reducing the number of parameters communicated.

3.2 Reducing Communication Rounds

  • Increase local computation (E): More local epochs before communication reduce the total number of rounds needed.
  • Adaptive aggregation: Only communicate when local models diverge significantly from the global model.
  • Knowledge distillation: Instead of transmitting model weights, clients send soft predictions on a shared public dataset.
Example — Communication Savings: A model with 10 million parameters requires ~40 MB per round (32-bit floats). With top-1% sparsification, only 100K parameters (~400 KB) are transmitted—a 100× reduction. With additional 8-bit quantization, this drops to ~100 KB per round.

4. Non-IID Data Challenges

In real-world FL, data across clients is typically non-IID (not independently and identically distributed). This is one of the most significant challenges in federated learning.

Non-IID Data: Data distributions differ across clients. Types of non-IID-ness include:
  • Label skew: Different clients have different label distributions (e.g., one hospital mostly sees cardiac cases, another sees respiratory).
  • Feature skew: Same labels but different feature distributions (e.g., photos from different climates).
  • Quantity skew: Clients have vastly different amounts of data.
  • Concept drift: The relationship between features and labels varies across clients.

4.1 Impact of Non-IID Data

  • Client drift: Local models diverge from each other and the optimal global model during local training.
  • Slow convergence: FedAvg may require many more rounds to converge compared to IID settings.
  • Accuracy degradation: The global model may perform poorly on individual clients with very different data distributions.

4.2 Solutions for Non-IID Data

  • FedProx: Adds a proximal term to the local objective: Lk(w) + (μ/2) · ||w − wt||², which prevents local models from drifting too far from the global model.
  • SCAFFOLD: Uses control variates to correct for client drift in gradient updates.
  • Per-FedAvg: Combines federated learning with MAML (Model-Agnostic Meta-Learning) for personalization.
  • Data sharing: Share a small amount of globally representative data with all clients.
  • Clustered FL: Group clients with similar data distributions and train separate models per cluster.
Key Insight: The non-IID problem is not just a theoretical concern. In production FL systems (e.g., mobile keyboard prediction), users in different regions, age groups, and professions have vastly different language patterns. Addressing this is essential for practical deployment.

5. Differential Privacy in Federated Learning

Even though FL avoids sharing raw data, model updates can still leak information about individual training examples. Differential privacy (DP) provides formal privacy guarantees.

(ε, δ)-Differential Privacy: A randomized mechanism M satisfies (ε, δ)-DP if for any two adjacent datasets D and D′ differing in one record, and for all measurable sets S:

P(M(D) ∈ S) ≤ eε · P(M(D′) ∈ S) + δ

ε (privacy budget) controls the privacy-utility trade-off; smaller ε means stronger privacy.

5.1 DP-FedAvg

The standard approach to DP in FL involves two steps applied to each client’s update before aggregation:

  1. Clipping: Bound the L2 norm of each client’s model update: Δwk → Δwk · min(1, C / ||Δwk||), where C is the clipping threshold.
  2. Noise addition: Add calibrated Gaussian noise to the aggregated update: wt+1 = wt + (1/K)(∑ Δwk + N(0, σ²C²I))

The noise scale σ is chosen based on the desired (ε, δ) guarantee using the moments accountant or Rényi DP composition.

Example — Privacy Budget: With ε = 1, the probability of any output changes by at most a factor of e1 ≈ 2.72 when any single user’s data is added or removed. With ε = 0.1, this factor is only e0.1 ≈ 1.105, providing much stronger privacy.

6. Secure Aggregation

Secure aggregation (SecAgg) ensures that the server can only see the aggregate of client updates, not individual updates, even if the server is curious.

6.1 How Secure Aggregation Works

  1. Each pair of clients (i, j) agrees on a random mask pij using Diffie-Hellman key exchange.
  2. Client i sends masked update: yi = wi + ∑j>i pij − ∑j<i pij
  3. When the server sums all masked updates, the pairwise masks cancel out: ∑i yi = ∑i wi
Key Property: SecAgg is orthogonal to differential privacy. SecAgg hides individual updates from the server; DP protects against inference attacks on the aggregate. In practice, both are often used together for defense in depth.

7. Horizontal vs Vertical Federated Learning

Federated learning architectures differ based on how data is partitioned across clients.

7.1 Horizontal FL (Sample-Partitioned)

Horizontal FL: Clients share the same feature space but have different data samples. Example: multiple hospitals with the same set of medical tests/features but different patient populations.

This is the most common FL setting. FedAvg is designed for horizontal FL.

7.2 Vertical FL (Feature-Partitioned)

Vertical FL: Clients have different features for the same set of samples. Example: a bank and an e-commerce company have different data about the same customers. The bank has financial data; the e-commerce platform has shopping behavior.

Vertical FL typically requires entity alignment (matching records across datasets) and uses techniques like split learning, where different parts of a model are trained on different clients.

7.3 Federated Transfer Learning

When clients differ in both feature space and sample space, federated transfer learning bridges the gap by learning shared representations that transfer across domains.

AspectHorizontal FLVertical FLFederated Transfer Learning
Feature SpaceSameDifferentDifferent
Sample SpaceDifferentSame (overlapping)Different
AlgorithmFedAvg, FedProxSplit Learning, SecureBoostTransfer + FL
ExampleMultiple hospitalsBank + retailerCross-lingual NLP

8. Applications of Federated Learning

8.1 Healthcare

FL enables training medical AI models across hospitals without sharing patient records. Applications include:

  • Tumor segmentation from distributed MRI data (FeTS initiative)
  • Drug discovery across pharmaceutical companies
  • Electronic health record analysis across hospital networks
  • Rare disease detection by pooling data from geographically dispersed institutions

8.2 Mobile Applications

  • Next-word prediction: Google Gboard trains on user typing patterns.
  • Voice recognition: Apple uses FL for Siri improvements.
  • Auto-complete & ranking: Personalized search suggestions.

8.3 Finance

  • Fraud detection across banks without sharing transaction data.
  • Credit risk modeling with data from multiple financial institutions.
  • Anti-money-laundering systems that pool patterns without exposing customer data.
Example — MELLODDY Project: Ten pharmaceutical companies (including Amgen, Novartis, and Merck) used federated learning to collaboratively train drug-discovery models. Each company kept its proprietary molecular data local while benefiting from the collective knowledge of all participants. The federated model outperformed individual company models by 5–15%.

9. Comparison with Centralized Learning

AspectCentralized LearningFederated Learning
Data LocationSingle serverDistributed across clients
PrivacyLow (data centralized)Higher (data stays local)
CommunicationData upload onceMultiple rounds of model exchange
ConvergenceStandard SGD guaranteesSlower, especially with non-IID data
Model QualityGenerally optimalCan approach centralized with enough rounds
ScalabilityLimited by server storage/computeScales to millions of clients
Regulatory ComplianceChallengingEasier (data doesn’t leave jurisdiction)
Convergence Result: For convex objectives, FedAvg converges to the global optimum at rate O(1/T) under IID data. For non-IID data, convergence is O(1/T) + O(Γ), where Γ quantifies the degree of data heterogeneity across clients. FedProx and SCAFFOLD reduce the Γ term.

10. Summary & GATE DA Key Takeaways

GATE DA Exam Tips:
  • Know the FedAvg algorithm steps: broadcast, local training, aggregation by weighted average.
  • Understand the difference between horizontal (same features, different samples) and vertical (different features, same samples) FL.
  • Know that non-IID data causes client drift and slows convergence.
  • Understand differential privacy: clipping + noise addition; the role of ε.
  • Communication efficiency: gradient compression (sparsification, quantization) and increasing local epochs.
  • FedSGD is the special case of FedAvg with E = 1 and full-batch gradient.
  • Secure aggregation hides individual updates; DP protects aggregate statistics.
Chapter Summary:
  • FL trains models without centralizing data, preserving privacy and regulatory compliance.
  • FedAvg: local SGD + weighted averaging; controlled by C, E, B, η.
  • Communication efficiency via compression, sparsification, and more local computation.
  • Non-IID data is the fundamental challenge; addressed by FedProx, SCAFFOLD, clustering.
  • Differential privacy (clip + noise) provides formal privacy guarantees.
  • Horizontal FL (sample split) vs Vertical FL (feature split) vs Federated Transfer Learning.
  • Applications span healthcare, mobile, finance, and cross-organizational collaboration.