How does FedAvg (federated averaging) train a shared model without centralising raw data, and what privacy risks remain? In one round, three clients with n1=100, n2=300 and n3=600 examples return scalar weights 0.8, 0.5 and 0.2: what is the aggregated weight, and how do secure aggregation, differential privacy and non-IID (non-independent and identically distributed) data affect the protocol?

ML systems and evaluation, Privacy
Level L3 Intermediate. Length Medium. Nature Th+Mat Both.

What's being asked

Whether you know the FedAvg (federated averaging) training loop, can compute the data-size-weighted server aggregation, understand why keeping raw data on device is not full privacy, and know how non-IID client data slows convergence.

Key idea

In FedAvg, a central server broadcasts global weights to participating clients, each client performs local SGD (stochastic gradient descent) epochs on its own data, and the server averages the returned weights in proportion to client dataset size nk/n. Raw training data stays on device, but shared model updates can still leak sensitive information unless paired with secure aggregation and differential privacy.

Steps

  1. Describe one round t of FedAvg: the server sends global weights wt to K selected clients; each client k runs E local SGD epochs on its local dataset of size nk to obtain wt+1(k); and the server aggregates wt+1=∑k=1Knkn wt+1(k),where n=∑k=1Knk. Taking several local steps before syncing greatly reduces communication rounds compared with sending every mini-batch gradient.
  2. Compute the worked example: total examples are n=100+300+600=1,000, giving client fractions 100/1000=0.1, 300/1000=0.3 and 600/1000=0.6. The weighted average is wt+1=0.1(0.8)+0.3(0.5)+0.6(0.2)=0.08+0.15+0.12=0.35. By contrast, an unweighted mean (0.8+0.5+0.2)/3=0.50 would over-weight the smallest client.
  3. Separate what raw-data locality protects from what still leaks: keeping raw examples on device avoids a central honeypot of user records, yet an honest-but-curious server seeing individual updates wt+1(k)−wt can run gradient-inversion attacks (reconstructing inputs) or membership-inference attacks (detecting whether a record was in client k's training data).
  4. Add cryptographic and DP (differential privacy) layers: secure aggregation uses cryptographic masking so the server learns only the aggregate sum and never sees an individual client's update; user-level DP clips each client's update and adds Gaussian noise so the global model cannot memorise a single user.
  5. Explain the effect of non-IID (non-independent and identically distributed) client data: when different clients hold skewed distributions (for example, hospitals serving distinct demographics), local SGD pulls each client towards its own local optimum ('client drift'), slowing global convergence and lowering accuracy if E is too large.

Common mistakes

How long your answer should be

3–4 minutes: FedAvg loop, worked weighted average (0.35), privacy gaps and defences, and non-IID client drift.

Read this

Previous in ML systems and evaluation: How do you use the two-sample KS (Kolmogorov–Smirnov) test to detect drift in a model's prediction scores? Suppose 6 reference scores are [0.10,0.20,0.30,0.40,0.50,0.75] and 6 live scores are [0.55,0.65,0.70,0.80,0.85,0.95]: what are the empirical CDFs (cumulative distribution functions), the KS statistic D, and the comparison against the large-sample α=0.05 critical value, and why do production teams alert on effect size rather than p-values?
Next in ML systems and evaluation: A new recommender model improves offline AUC on logged data, but an online A/B test shows no gain. What are the likely reasons, and how can you make offline evaluation more predictive of online results?