🎉 75% of content is free forever — Unlock Premium from $10/mo →
CW
NEWSLIVESearch All Content
đŸ’ŧ Servicesâ„šī¸ Aboutâœ‰ī¸ ContactView Pricing Plansfrom $10

Federated Learning System

AI System DesignFederated LearningđŸŸĸ Free Lesson

Federated Learning System

What You'll Learn

  • 1Derive FedAvg weighting and compute the aggregated update for a client pool
  • 2Budget bytes per round and total communication for a federated training job
  • 3Translate a privacy target in epsilon into per-round noise
  • 4Diagnose non-IID divergence and client dropout in production federated training

Why This Matters

Federated learning enables training ML models across decentralized data sources without sharing raw data - critical for privacy in healthcare, finance, and mobile applications. Understanding its design is essential for building privacy-preserving ML systems at scale.


Architecture Overview

Federated Learning ArchitectureCentral Aggregation ServerModel AggregationSecure Agg.Client SelectionDP NoiseClient Devices (Data Never Leaves)Client 1Local DataLocal TrainingGradient UpdatesDifferential PrivacyClient 2Hospital ALocal TrainingModel UpdatesPrivacy ProtectionClient 3Bank BLocal TrainingGradient UpdatesFederated AveragingClient NPhone UsersOn-Device TrainingModel DeltasBandwidth LimitsPrivacy & Security LayerDifferential PrivacySecure AggregationHomomorphic Enc.Trusted ExecutionSecure MPCCommunication EfficiencyGradient CompressionQuantizationSparsificationLocal SGD StepsUpdated Global Model - Next Round

Core Components

1. Federated Averaging (FedAvg)

Federated Averaging is the foundational algorithm for federated learning:

  • Client selection: The server selects a subset of active clients each round, with selection probability proportional to dataset size.
  • Local training: Each selected client receives the global model, trains locally for several epochs on its private data, and computes model updates.
  • Weighted aggregation: The server aggregates client updates weighted by each client's dataset size: aggregated = sum(weight_i * update_i) where weight_i = samples_i / total_samples.
  • Differential privacy noise: Calibrated noise is added to the aggregated model based on sensitivity and epsilon (privacy budget).
  • Round-based iteration: This process repeats for many rounds until convergence.

2. Differential Privacy

Differential privacy protects individual data points in federated learning:

  • Gradient clipping: Limits the maximum contribution of any single data point by clipping gradient norms to a maximum threshold.
  • Noise addition: Adds calibrated noise (Gaussian or Laplace) to model updates. Noise scale = sensitivity * noise_multiplier / epsilon.
  • Privacy accountant: Tracks cumulative privacy budget consumption across rounds using advanced composition theorems.
  • Budget exhaustion: Halts training when the cumulative epsilon reaches the target privacy budget.

3. Communication Efficiency

Reducing communication overhead is critical for federated learning at scale:

  • Gradient compression (top-k sparsification): Keeps only the k largest gradients by magnitude, setting the rest to zero. Typical compression ratios are 0.1-1%.
  • Quantization: Reduces gradient precision from FP32 to INT8, achieving 4x compression with minimal accuracy loss.
  • Compression strategy selection: Based on bandwidth and model size - no compression for fast connections, quantization for moderate, sparsification+quantization for slow.
  • Local SGD: Performing multiple local training steps before communication reduces round frequency.

Sizing Communication and Privacy

Federated learning trades data movement for compute, so the first design number is bytes per round. With clients, parameters and bits per parameter, each selected client downloads the model and uploads its update:

A 10 million parameter model in FP32 is 40 MB, so 100 clients cost GB per round. Over 1,000 rounds that is 8 TB of egress, which is why mobile federated jobs shrink , reduce , or quantize updates to 8 bits (cutting the round to 2 GB), and why top-k sparsification at 1 percent of weights cuts the upload alone to 40 MB per round.

Aggregation itself is a weighted mean, and the weights are sample counts:

A client with 8,000 local samples and one with 2,000 contribute 0.8 and 0.2 of the update. Using equal weights instead silently gives a 2,000-sample client five times the influence it deserves, which both slows convergence and lets a small, unusual client pull the global model toward its distribution.

Privacy is a budget that degrades with rounds. Under standard composition, the total epsilon after rounds at per-round budget with failure probability behaves like:

With rounds, and , the term gives , which misses a typical target. Holding 6 requires near 0.04, which means more noise per update and slower learning. The practical levers are fewer rounds, more local work per round, and clipping strictly enough that the sensitivity stays small.

Failure Modes

Non-IID data is the one that does not show up in a demo: if every hospital's label mix differs, local updates disagree and the global model oscillates instead of converging. Mitigate with FedProx's proximal term, SCAFFOLD's control variates, or by clustering clients that look alike. Client dropout stalls a round if the aggregator waits for stragglers, so select 20 percent more clients than needed and close the round once a quorum reports. Poisoning is possible even without raw data, so validate each update's norm and direction before it enters the average, and use secure aggregation so the server never sees an individual update to attack.

Common Mistakes

Averaging client updates equally regardless of data volume

Fix: Weight by local sample counts, or a 2,000 sample client gets five times the influence of an 8,000 sample one.

Adding enough noise per round to satisfy privacy in isolation

Fix: Track the composed budget across rounds; 1,000 rounds at 0.1 per round composes to an epsilon near 15.

Waiting for every selected client before aggregating

Fix: Over-select clients and close the round on a quorum so a dropped phone does not stall training.

Best Practices

  • Report accuracy per client cohort, not only the global mean, to catch non-IID skew early
  • Compress updates with top-k or 8 bit quantization before upload and measure the accuracy cost
  • Pair secure aggregation with update norm checks so privacy does not hide poisoning

Key Takeaways

  • A 10M parameter FP32 model across 100 clients costs 8 GB per round and 8 TB over 1,000 rounds
  • FedAvg weights are w_i = n_i / sum n_j, so sample counts, not equal votes, set the aggregate
  • Privacy composes as roughly sqrt(2 T ln(1/delta)) x epsilon_step, so 1,000 rounds at 0.1 gives epsilon near 15
  • Non-IID data and client dropout are the two operational failure modes that no demo reveals

Frequently Asked Questions

Why is communication the bottleneck rather than local training?

Mobile and IoT links are slow and metered while local compute is already paid for. A 40 MB model download plus upload on a 5 Mbps link takes about 128 seconds per direction, so a round dominated by transfer wastes more time than the local epochs save. Compressing updates to 8 bits or keeping only the top 1 percent of gradients by magnitude cuts the round by 4x to 100x and is usually the single biggest win available.

What does a privacy budget of epsilon actually buy?

Epsilon bounds the log-likelihood ratio between two datasets that differ in one record: an attacker with the shared update cannot tell with much more than an odds factor of e to the epsilon whether any one person's data was present. Smaller epsilon means stronger privacy and more noise. In practice epsilon 1 to 8 with delta around 1e-5 is the common reporting range, and the budget must be composed across every round, not read per round.

How do you handle non-IID client data?

Four levers, in order of cost. Sample clients so each round is more representative, which costs nothing. Increase local epochs so each client's update is closer to its own optimum, then correct with FedProx's proximal penalty to keep clients near the global model. Cluster clients by distribution and train a model per cluster when populations genuinely differ. Finally, share a small public dataset that all clients mix into local training to anchor the objective.

Interview Questions

Q1: What is federated averaging and how does it work?

FedAvg selects a subset of clients each round, sends them the global model, lets each train for several epochs on local data, and averages the returned updates weighted by sample count: w_i = n_i / sum n_j. It repeats for many rounds. Local epochs cut communication roughly in proportion to the work done between syncs, up to the point where client drift starts to hurt.

Q2: How does differential privacy protect data in federated learning?

Each client clips its update to a bounded norm and adds calibrated Gaussian noise before upload, so no single record can move the shared update much. The noise scale is sensitivity times a noise multiplier, and the per-round epsilon composes across rounds via sqrt(2 T ln(1/delta)) times the step budget, which is why a 1,000 round job needs a per-round budget near 0.04 to stay under epsilon 6.

Q3: What is the communication bottleneck in federated learning?

Updates are large and links are weak: 10 million FP32 parameters is 40 MB each way, so 100 clients cost 8 GB per round. Solutions are quantization to 8 bits (4x), top-k sparsification at 1 percent (roughly 100x on the upload), more local SGD steps between rounds, and update differencing so clients send only what changed.

CW

ChatWhole Learn Editorial Team

Written by experienced data scientists, software engineers, and educators. All content is reviewed by industry professionals to ensure accuracy and relevance.

Last reviewed: 2026-10-07

—
☆☆☆☆☆
0 ratings

Rate & Feedback

Need Expert AI System Design Help?

Get personalized tutoring, project support, or professional consulting.

Advertisement