wikillm

Paper · 2020-12-08 · cs.LG, stat.ML

Ditto: Fair and Robust Federated Learning Through Personalization

Ditto trains one personal model per device, pulled toward the shared global model by an L2 term weighted by lambda. The global model uses any federated solver (FedAvg in the experiments). Authors report about 6% higher benign accuracy than the strongest robust baseline under attack, and about 10% lower accuracy variance than a fair baseline (TERM).

Personalized federated learningFederated learningAlgorithmic fairnessAdversarial robustnessfederated-learningpersonalizationfairnessrobustness

arXivPDFCodeMarkdown12 min read

AI-compiled by claude-haiku-5-5 on 2026-10-24, not yet reviewed by a human. Every claim cites its source; check it when a detail matters.

In plain words

Federated learning trains one shared model on data that stays on many separate devices. Each device's data can look quite different from the others, so one shared model may serve some devices well and others badly. A few devices that send bad updates can also spoil the shared model.

Ditto keeps the shared model and gives each device its own personal copy as well. The personal copy learns from that device's data, but it is pulled back toward the shared model. A single setting controls the pull. With no pull, each device just trains alone. With a very strong pull, every device effectively uses the shared model. The authors argue that a setting in between makes the results more accurate, more even across devices, and more robust to attacks than methods built only for fairness or only for robustness.

TL;DR

Ditto is a lightweight personalization layer for federated learning. Each device trains a personal model with an L2 pull toward the current global model, and the global model is trained by an ordinary federated solver such as FedAvg. The authors report that this matches or beats recent personalization methods on accuracy, and beats robust and fair baselines on robustness and fairness. A closed-form analysis covers only linear problems.

Problem

Federated learning must satisfy accuracy, fairness and robustness at once. Fairness here means that accuracy is even across devices, measured as the standard deviation of test accuracy across devices §2. Robustness means that the mean test accuracy on benign devices stays high under training-time attacks on data or updates §2. Robust aggregators, gradient clipping and fair reweighting methods each address one of these, and the authors show that they can work against each other. Fair methods that upweight rare or hard devices can overfit to corrupted devices, and robust methods can discard informative updates from unusual devices §1; §4.3; fig. 4; fig. 5. The paper considers attacks A1 (label poisoning), A2 (random Gaussian updates) and A3 (model replacement with scaled updates) §2.

Method

Objective. Ditto adds one personal model v_k per device k. It minimises the device's local loss plus a pull toward the optimal global model w^*:

\min_{v_k}\; F_k(v_k) + \frac{\lambda}{2}\left\|v_k - w^*\right\|^2 \quad \text{s.t.} \quad w^* \in \arg\min_w G\big(F_1(w),\dots,F_K(w)\big) §3.1

Here G is the global objective, and FedAvg uses a weighted average of local losses for it §3.1. When \lambda = 0 the personal models are purely local. As \lambda grows, the objective approaches the global one §3.1.

Solver. The paper optimises the global and personal models jointly and alternately, not one after the other §3.2. In each round:

  1. The server samples a subset of devices and sends them the current global model w^t alg. 1.
  2. Each selected device updates the global model with the solver for G, starting from w^t. With FedAvg this is r local SGD steps on F_k app. B, alg. 2.
  3. Each device updates its personal model for s local steps with v_k \leftarrow v_k - \eta\,(\nabla F_k(v_k) + \lambda(v_k - w^t)) §3.2; alg. 1; app. B. The pull is toward w^t, the global model at the start of the round, not the device's own global update.
  4. The device sends only its global update back. Personal models never leave the device, so the communication matches that of the global solver §3.2.
  5. The server aggregates the global updates into w^{t+1} alg. 1.

The method for the personal step, in the FedAvg case used for most experiments:

Pseudocode
# Ditto round with FedAvg as the global solver  [app. B, alg. 2]
# w: global model w^t; personal[k]: personal model v_k of device k
# grad_F(model, k): mini-batch gradient of F_k  [§3.2]

def ditto_round(w, personal, devices, lam, lr, r, s):
    # Server selects the devices S_t and sends them w^t  [alg. 1]
    updates = []
    for k in selected(devices):
        # Global part: r local SGD steps on F_k from w^t  [app. B, alg. 2]
        w_k = w
        for _ in range(r):
            w_k = w_k - lr * grad_F(w_k, k)
        # Personal part: s steps on F_k + lam/2 * ||v - w^t||^2  [§3.2]
        for _ in range(s):
            pull = lam * (personal[k] - w)
            personal[k] = personal[k] - lr * (grad_F(personal[k], k) + pull)
        # Only the global update is sent back  [§3.2; alg. 1]
        updates.append(w_k - w)
    # Server averages the global updates  [app. B, alg. 2]
    w = w + mean(updates)
    return w, personal

Choosing λ. The paper treats λ as a per-device hyperparameter. Each device selects λ from a small candidate set using its own validation data §4 Setup; app. D.2. The candidate grids depend on whether the attack is treated as strong (defined in app. D.2). Section 3.3 gives closed-form values of λ* for linear regression: λ* = σ²/(nτ²) without adversaries, and an adversarial version that decreases as the number of adversaries and the attack strength grow §3.3; app. A. Here τ measures how related the devices are and σ the noise. A device does not know τ, so the closed form cannot be used directly, and the paper does not give an estimator for it.

Convergence. If the global model converges at rate g(t), the personal models converge at a rate C\,g(t) §3.2; app. B. With FedAvg as the global solver this gives O(1/t) for the personal models app. B. The analysis assumes strong convexity, bounded stochastic gradients and bounded heterogeneity M app. B.

Robust aggregation. Robust aggregators can replace the averaging step on the server, for example clipping or multi-Krum, and this can improve Ditto further §4.4; app. D.3.

Hyperparameters

NameValueWhereNotes
Global solverFedAvg in most experiments§3.2; alg. 1; app. BTable 3 uses robust aggregators instead §3.2
Personal local steps s, global local steps rnot statedapp. B, alg. 2Released code uses one local_iters for both; see Paper vs code
λ (fixed)1 in released run scriptsrun_fashion_clean_ditto_lam1.shdynamic_lam=0 in these scripts
λ candidate grid, strong attacks{0.05, 0.1, 0.2}app. D.2devices with more than 5 validation points
λ candidate grid, other attacks{0.1, 1, 2}app. D.2devices with more than 5 validation points
λ, very few validation points0.1 (strong attacks), 1 (other)app. D.2devices with fewer than 4 points; 4 and 5 points are not covered
λ grid, StackOverflowstrong {0.01, 0.05, 0.1}; other {0.05, 0.1, 0.3}app. D.2
Strong attackA3 with updates scaled by more than 10×, or more than half of devices corruptedapp. D.2
Learning rate0.1 (FEMNIST, CelebA, Vehicle); 0.05 (Fashion MNIST); 0.01 (StackOverflow)app. D.4Vehicle script uses 0.01 run_vehicle_clean_ditto_lam1.sh
Batch size16 (CelebA, Fashion MNIST); 32 (FEMNIST, Vehicle); 100 (StackOverflow)app. D.4Matches run scripts
Communication roundsfixed by a clean FedAvg run per datasetapp. D.4Scripts use 5000 (Fashion MNIST) and 600 (Vehicle) run_fashion_clean_ditto_lam1.sh; run_vehicle_clean_ditto_lam1.sh
Devices per round10run_fashion_clean_ditto_lam1.shNot stated in the paper
Device samplingweighted by number of training samplesrun_fashion_clean_ditto_lam1.sh; fedbase.pyPaper says devices are selected randomly alg. 1
Train / validation / test split72% / 8% / 20%app. D.4Main text says only "random" §4 Setup
Devices in the datasetVehicle 23; FEMNIST 205; CelebA 515; Fashion MNIST 500; StackOverflow 400; FEMNIST skewed 100app. C.1
ModelsVehicle: linear SVM; FEMNIST, CelebA, Fashion MNIST: CNN; StackOverflow: logistic regressionapp. C.1
Corrupted devices, 50% Fashion MNIST250 of 500run_fashion_a1_50_ditto_lam1.sh
Corrupted devices, 50% Vehicle11 of 23 (about 48%)run_vehicle_a1_50_ditto_lam1.sh
Local steps2 (Fashion MNIST script), 1 (Vehicle script)run_fashion_clean_ditto_lam1.sh; run_vehicle_clean_ditto_lam1.shNot stated in the paper
Finetuning baseline50 epochs of SGD per device from w^*§4.4; app. D.4Baseline, not the Ditto solver
EWC and SKL baselines50 epochs of local finetuning§4.4
Fair baselineTERM with t = 1 in Table 1; t = 1, 2, 5 in Figure 4§4.2; §4.3
Boosting factor for A3malicious update multiplied by devices per round (10 in scripts)ditto.pyPaper gives no factor; see Pitfalls

Results

Author-reported. Setup: federated benchmarks Fashion MNIST and FEMNIST, plus CelebA, Vehicle and StackOverflow in the appendix; attacks A1, A2 and A3 with several adversary ratios; metrics are mean accuracy on benign devices and its standard deviation §4 Setup; app. C.1; app. D.4.

Headline claims (author-reported):

  • Robustness: about 6% absolute higher mean benign accuracy than the strongest robust baseline, averaged over datasets and attacks §1; §4.1; app. D.4.
  • Fairness: about 10% lower variance across devices than the fair baseline TERM, while accuracy on clean data is about 5% higher §1; §4.2.
  • Personalization: similar or better accuracy than other personalized methods, with slightly lower standard deviation §4.4; tab. 2.

Table 1: average (standard deviation) of test accuracy, Fashion MNIST and FEMNIST tab. 1. The Ditto row matches the dynamic-λ row of app. D.2, but the caption does not say how λ was chosen for this table.

Fashion MNISTcleanA1 20%A1 50%A1 80%A2 20%A2 50%A2 80%A3 10%A3 20%A3 50%
global.911 (.08).897 (.08).855 (.10).753 (.13).900 (.08).882 (.09).857 (.10).753 (.10).551 (.13).275 (.12)
local.876 (.10).874 (.10).876 (.11).879 (.10).874 (.10).876 (.11).879 (.10).877 (.10).874 (.10).876 (.11)
fair (TERM, t=1).909 (.07).751 (.12).637 (.13).547 (.11).731 (.13).637 (.14).635 (.14).653 (.13).601 (.12).131 (.16)
Ditto.943 (.06).944 (.07).937 (.07).907 (.10).938 (.07).930 (.08).913 (.09).921 (.09).902 (.09).873 (.11)
FEMNISTcleanA1 20%A1 50%A1 80%A2 20%A2 50%A2 80%A3 10%A3 15%A3 20%
global.804 (.11).773 (.11).727 (.12).574 (.15).774 (.11).703 (.14).636 (.15).517 (.14).487 (.14).314 (.13)*
local.628 (.15).620 (.14).627 (.14).607 (.14).620 (.14).627 (.14).607 (.14).622 (.14).621 (.14).620 (.14)
fair (TERM, t=1).809 (.11).636 (.15).562 (.13).478 (.12).440 (.15).336 (.12).363 (.12).353 (.12).316 (.12).299 (.11)
Ditto.834 (.09).802 (.10).762 (.11).672 (.13).801 (.09).700 (.15).675 (.14).685 (.15).650 (.14).613 (.13)

* app. D.4 reports .364 (.13) for this cell. See Pitfalls.

Table 2: other personalization methods, FEMNIST and CelebA tab. 2. Ditto values here differ slightly from Table 1 (see Pitfalls).

MethodFEMNIST cleanCelebA cleanFEMNIST A1 50%CelebA A1 50%
global.804 (.11).911 (.19).727 (.12).538 (.28)
local.628 (.15).692 (.27).627 (.14).682 (.27)
plain finetuning.815 (.09).912 (.18).734 (.12).721 (.28)
L2SGD.817 (.10).899 (.18).732 (.15).725 (.25)
EWC.810 (.11).910 (.18).756 (.12).642 (.26)
SKL.820 (.10).915 (.16).752 (.12).708 (.27)
Per-FedAvg (HF).827 (.09).907 (.17).604 (.14).756 (.26)
mapper.792 (.12).773 (.25).726 (.13).704 (.27)
APFL.811 (.11).911 (.17).750 (.11).710 (.27)
Ditto.836 (.10).914 (.18).767 (.10).721 (.27)

Table 3: Ditto with robust baselines, FEMNIST tab. 3. Ditto with clipping is best in five of six columns. Plain Ditto is best at A1 80%.

MethodA1 20%A1 80%A2 20%A2 80%A3 10%A3 20%
global.773.574.774.636.517.364
clipping.791.408.791.656.795.061
Ditto.803.669.792.681.695.650
Ditto + clipping.810.645.808.684.813.672

Figures (described; no images are used on this card):

  • fig. 1: toy point-estimation problem. The λ given by the theory gives the lowest error and standard deviation among Ditto's solutions.
  • fig. 2: as devices become more related, global beats local; Ditto with λ* beats both.
  • fig. 3: mean benign accuracy under A1 on Fashion MNIST and FEMNIST. Ditto is the most robust under almost all attacks, especially at high adversary ratios.
  • fig. 4: fair methods with larger t lose more accuracy under attack on FEMNIST and CelebA.
  • fig. 5: robust baselines are either robust but unfair, or not robust. Ditto sits in the robust and fair corner.
  • fig. 6: under A3 at 20% adversaries, joint optimisation beats finetuning from w^*.

Paper vs code

Official repository: github.com/litian96/ditto, MIT licence, commit 26d9b29a62f3872dcdf071be08e897607c283bb4 LICENSE. The paper links it in §4 Setup. Discrepancies, each checked against both sides:

  • λ selection differs. The paper selects λ per device on validation data, using the grids in app. D.2. The code selects λ at every local step: it tries each candidate in {0.1, 1, 2}, takes one lookahead step, and keeps the candidate with the lowest validation loss ditto.py. The same grid is used for every attack. The strong-attack grid and the small-validation rule of app. D.2 are not implemented. The released scripts set dynamic_lam=0 and λ=1 run_fashion_clean_ditto_lam1.sh, so reproducing the dynamic-λ numbers needs --dynamic_lam=1.
  • Device sampling differs. The paper says devices are selected randomly alg. 1. The code samples without replacement with probability proportional to the number of training samples fedbase.py, and the scripts pass --sampling=2 run_fashion_clean_ditto_lam1.sh.
  • Local steps are shared. The paper uses r global steps and s personal steps app. B, alg. 2. The code has one local_iters for both. Each iteration takes a personal gradient step ditto.py and then a global step on the same mini-batch ditto.py.
  • Step size is constant. The convergence lemma uses a decaying step size 2/((t+1)(\mu+\lambda)p_k) app. B. The code uses the constant learning_rate for the personal update ditto.py, and the model's TensorFlow training op for the global update cnn.py.
  • Vehicle learning rate differs. The text says 0.1 for all datasets other than StackOverflow and Fashion MNIST app. D.4. The Vehicle script uses 0.01 run_vehicle_clean_ditto_lam1.sh.
  • Boosting factor is set by the code. Model replacement multiplies the malicious update by clients_per_round ditto.py. With the scripts' value of 10 this is a factor of 10. The paper gives no factor in the main text, only ">10×" as the strong-attack threshold app. D.2.
  • Random-update attack. Malicious updates are Gaussian with a standard deviation computed from the honest update ditto.py. This matches §2 (A2).
  • Label attacks match the paper. Corrupted labels are flipped for CelebA and Vehicle and drawn uniformly at random for FEMNIST and Fashion MNIST ditto.py. This matches the threat model in §2 (A1).
  • Corrupted devices are fixed by seed. The corrupted set comes from np.random.seed(1234567 + seed) ditto.py.

Only the Ditto trainer and the run scripts were read in detail. The baseline trainers were not reviewed.

Pitfalls

  • λ grid gap. The rules cover devices with fewer than 4 and more than 5 validation points app. D.2. A device with exactly 4 or 5 is covered by neither rule. The paper does not say what those devices should use.
  • Per-step λ selection costs more. Each local iteration runs two mini-batch gradient computations, one for the personal model and one for the global model ditto.py, plus one loss call ditto.py. In dynamic mode it also runs three validation-loss evaluations ditto.py. The paper reports no wall-clock or FLOP cost.
  • Stateful devices. Each device must keep its personal model between the rounds in which it is selected §3.2. A device that is not selected for a long time uses a stale personal model. In simulation, the code keeps all personal models on the server in self.local_models ditto.py.
  • Closed-form λ is not usable in practice.* The formulas need τ, σ, the adversary count and their spread §3.3. The analysis assumes Gaussian data, X_i^\top X_i = \beta I and a uniform prior app. A. The paper does not give an estimator, and the experiments tune λ on validation data instead.
  • Convergence does not transfer to the experiments. The theory assumes strong convexity and a decaying step size app. B. The experiments use non-convex CNNs with a constant step, and the released code does the same.
  • Numbers differ between tables. Ditto's clean FEMNIST accuracy is .834 (.09) in Table 1 and .836 (.10) in Table 2; its A1 50% value is .762 (.11) in Table 1 and .767 (.10) in Table 2 tab. 1; tab. 2. Table 1 gives global A3 20% FEMNIST as .314 (.13), while app. D.4 gives .364 (.13). Table 3 shows Ditto A1 80% as .669 and app. D.4 as .672 tab. 3. The λ used in Table 2 is not stated. Use the appendix tables for implementation targets, and expect small differences.
  • The "about 10%" variance reduction is ambiguous. The paper does not say whether it is relative or absolute §1; §4.2.
  • Vehicle attack ratio is approximate. The script's "50%" run corrupts 11 of 23 devices, which is about 48% run_vehicle_a1_50_ditto_lam1.sh.
  • Joint optimisation matters. Finetuning from w^* is worse under attack, and the paper notes that stopping early requires a choice that is hard to make without knowing which devices are benign §3.2; app. D.1; fig. 6.
  • Clipping threshold. Clipping uses the median update norm of each round app. D.4. This was not verified in the code, which calls l2_clip at ditto.py.

Lineage

  • Builds on: FedAvg as the default global solver §3.1; mean-regularised multi-task learning, which Ditto differs from by regularising toward the global model rather than the average personal model §2; FedProx's L2 term, which resembles Ditto's but yields a single global model §3.1, remark.
  • Compared against: fair methods q-FFL and TERM §4.2; robust aggregators (median, Krum, multi-Krum, clipping, k-norm, k-loss) and FedMGDA+ §4.1; personalization methods L2SGD, MOCHA, EWC, SKL, Per-FedAvg, mapper and APFL §4.4; app. C.2.
  • Superseded by: not known from content in this wiki.

Source and license

Adapted from “Ditto: Fair and Robust Federated Learning Through Personalization” by Tian Li, Shengyuan Hu, Ahmad Beirami, Virginia Smith (arXiv:2012.04221), used under CC BY 4.0. Changes: condensed and restructured for implementation, with tables, equations and algorithms taken from the paper and its code, each cited to its source. Not affiliated with or endorsed by the authors. Code citations refer to https://github.com/litian96/ditto at commit 26d9b29a62f3 (MIT). Any quoted code is shown under that license.