Interactive paperOct 2026arXiv preprint

FedReason: Large Language Models as Weight-Space Meta-Aggregators for Heterogeneous Federated Learning

A large language model reads the client models in a restricted server-side sandbox and writes the aggregation program itself, six times in a 60-round run, with no training on the server and no weight tensor ever leaving it. It beat FedAvg in 10 of 12 paired label-skew runs, was the most accurate server-side rule on CIFAR-100, and excluded every sign-flipping client from the first round.

Ali Mohammadi Ruzbahani1, Abbas Yazdinejad2, Hadis Karimipour1

1 Smart Cyber-Physical Systems (SCPS) Lab, University of Calgary   2 DCAILab, University of Regina

Interactive simulation

The server writes its own aggregation program

Pick one of the paper’s five settings. At rounds 1, 11, 21, 31, 41 and 51 the LLM reads printed sandbox output, spends up to six proxy evaluations, and submits aggregate(ctx), which must pass a dry run before it aggregates a single round.

Setting
Round
01/ 60
Active program
FedAvgdefault
Clients excluded
0/ 10
Simulated gap vs FedAvg
+0.00pts

An illustrative, real-time model of the method. The figures reported below come from the paper's experiments.

01

Results

Reading the client models beat FedAvg in 10 of 12 paired label-skew runs and an equal-budget selector of standard rules in 9, made FedReason the most accurate server-side rule on CIFAR-100, and shut sign-flipping clients out from the first round.

+1.26pp

Mean gain over FedAvg across 12 paired label-skew runs (95% CI 0.38 to 2.14), with 10 wins.

+1.08pp

Over ProxySel, which spends the same three proxy evaluations per round choosing among standard rules (9 wins, 1 tie).

1.00F1

Sign-flipping clients excluded from round 1 in both seeds with no honest client excluded; they received 0.43% of the aggregate, against 29.11% under FedAvg.

0.79USD

Average API cost of a 60-round run with six invocations (0.56 to 1.26 USD); one invocation cost 0.13 USD.

Reported results

Transcribed from Tables 2 to 5

Final test accuracy (%) after 60 rounds, mean of three seeds (Table 2). Each panel has its own zoomed axis. Hollow marks (†) change the clients; every other rule changes only the server.

CIFAR-10, α = 0.1
  1. FedReason66.53
  2. FedAvg
  3. FedProx†
  4. FedAvgM
  5. FedAdam
  6. FedNova
  7. SCAFFOLD†
  8. FedAdp
  9. ProxySel
CIFAR-10, α = 0.5
  1. FedReason87.77
  2. FedAvg
  3. FedProx†
  4. FedAvgM
  5. FedAdam
  6. FedNova
  7. SCAFFOLD†
  8. FedAdp
  9. ProxySel
CIFAR-100, α = 0.1
  1. FedReason62.26
  2. FedAvg
  3. FedProx†
  4. FedAvgM
  5. FedAdam
  6. FedNova
  7. SCAFFOLD†
  8. FedAdp
  9. ProxySel
CIFAR-100, α = 0.5
  1. FedReason67.72
  2. FedAvg
  3. FedProx†
  4. FedAvgM
  5. FedAdam
  6. FedNova
  7. SCAFFOLD†
  8. FedAdp
  9. ProxySel
Final test accuracy (%) under label skew, mean ± standard deviation over three seeds (Table 2).
MethodCIFAR-10, α = 0.1CIFAR-10, α = 0.5CIFAR-100, α = 0.1CIFAR-100, α = 0.5Mean
FedReason66.53 ± 6.3487.77 ± 0.9562.26 ± 1.3567.72 ± 0.8871.07
FedAvg65.72 ± 4.8087.34 ± 0.3459.95 ± 1.0766.24 ± 0.1769.81
FedProx†67.65 ± 4.1887.14 ± 0.5759.03 ± 0.9165.90 ± 0.7569.93
FedAvgM67.18 ± 2.4387.87 ± 0.6959.68 ± 1.3365.00 ± 0.1469.93
FedAdam66.59 ± 3.4987.13 ± 0.4359.23 ± 0.7665.41 ± 0.1769.59
FedNova46.59 ± 15.5187.23 ± 1.4659.88 ± 1.1566.16 ± 0.7564.97
SCAFFOLD†70.52 ± 2.7288.22 ± 0.3762.39 ± 0.8868.09 ± 0.5272.31
FedAdp58.61 ± 7.0785.38 ± 1.8659.64 ± 1.3766.20 ± 0.2367.46
ProxySel65.69 ± 5.6087.31 ± 0.0160.26 ± 0.8866.70 ± 0.0869.99

Paired over 12 setting and seed pairs, FedReason beat FedAvg by 1.26 pp (95% CI 0.38 to 2.14, 10 wins), ProxySel by 1.08 pp (9 wins, 1 tie) and FedAdp in all 12 pairs (+3.61 pp). On CIFAR-100 it was the most accurate rule that changes only the server.

Evaluated with Claude Opus 5.5 on CIFAR-10 and CIFAR-100 with ResNet-18, K = 10 clients, 60 rounds and full participation, in 168 runs against 14 baselines: FedAvg, FedProx, FedAvgM, FedAdam, FedNova, SCAFFOLD, FedAdp and ProxySel under label skew; HeteroFL and FedRolex for mixed widths; the coordinate-wise median, the trimmed mean, Krum and FLTrust under attack. Every one of the 150 invocations in the 24 FedReason runs ended with a program that passed its dry run at the first submission, and no round fell back to FedAvg. FedReason did not beat SCAFFOLD, which changes the clients and could be combined with it.

02

How it works

Meta-aggregation: the server chooses the aggregation operator during training, as a sequence of programs written from the observed client models.

01

Invoke every ten rounds

At rounds 1, 11, 21, 31, 41 and 51 the server opens a new tool-use conversation of at most ten model requests. Its brief carries the setting, client metadata, the proxy history, the previous program with its rationale, and the LLM’s own notes.

02

Read the weights in a sandbox

The python tool runs code on read-only copies of G, W, U and the metadata and returns only printed output, cut to 6,000 characters. summary() reports norms with robust z-scores, leave-one-out cosines and the classes each classifier moved most. Label histograms, attacker identities and the test set are never exposed.

03

Score a few candidates

proxy_eval scores candidate models on 500 class-balanced proxy images, at most six times per invocation, and a program may use three evaluations per round. Nothing is fitted by gradient descent on the server.

04

Dry-run, then check every round

submit_policy sends aggregate(ctx) with a rationale and notes; it must pass a dry run on the current round, with up to three submissions. Every round its output is checked for keys and shapes, finite values, non-negative running variances and an update norm of at most ten times the largest client update; a failing round uses FedAvg and rolls back ctx.memory.

03

Inside the programs

Across the 120 programs accepted in the 20 main runs, the LLM settled on a consistent toolkit, and every decision is stored as code with its rationale.

98%

clipped update norms.

91%

down-weighted clients whose update direction disagreed with the others.

100%

kept per-client suspicion counters in ctx.memory and returned FedAvg from an exception handler.

92%

of the programs in the width-heterogeneous settings used width-aware weighting.

45%

selected among candidates on the proxy set.

38%

aggregated the classifier rows class by class.

35%

used server momentum, never in the Byzantine runs.

0.95of 3

per-round proxy evaluations used on average: 74 per run including analysis, against 180 for ProxySel.

Listing 1 · policy_001 of the sign-flip run (seed 0), as submitted at round 1
def aggregate(ctx):
    torch, np = ctx.torch, ctx.np
    K = ctx.num_clients
    n = np.array([m['num_samples'] for m in ctx.meta], dtype=float)
    cids = [m['cid'] for m in ctx.meta]
    w0 = n / n.sum()
    try:
        M = ctx.update_matrix()
        Gm = M @ M.T
        nr = Gm.diag().clamp_min(1e-12).sqrt()
        C = (Gm / (nr[:, None] * nr[None, :])).numpy().astype(float)
        np.fill_diagonal(C, np.nan)
        medcos = np.nanmedian(C, axis=1)
        norms = nr.numpy().astype(float)
        mednorm = float(np.median(norms))
        gmed = float(np.median(medcos))
        flag = (norms > 3.0 * mednorm) | ((medcos < 0.0) & (medcos < gmed - 0.05))
        mem = ctx.memory.setdefault('susp', {})
        for i, c in enumerate(cids):
            h = mem.setdefault(str(c), [0, 0])
            h[0] += int(flag[i]); h[1] += 1
        excl = flag.copy()
        for i, c in enumerate(cids):
            h = mem[str(c)]
            if h[0] >= 3 and h[0] >= 0.5 * h[1]:
                excl[i] = True
        if (~excl).sum() < 3:
            excl = norms > 3.0 * mednorm
            if (~excl).sum() < 3:
                excl = np.zeros(K, dtype=bool)
        w = w0.copy(); w[excl] = 0.0
        w = w / w.sum()
        # clip accepted updates to the median norm of accepted clients
        accn = norms[~excl]
        cap = float(np.median(accn))
        scale = np.minimum(1.0, cap / np.maximum(norms, 1e-12))
        coef = torch.as_tensor(w * scale, dtype=torch.float32)
        upd = (coef[:, None] * M).sum(0)
        d = ctx.unflatten(upd)
        bn_keys = [k for k, _, kind, _ in ctx.layers if kind == 'bn_stat']
        new = ctx.weighted_average(w, keys=bn_keys)
        new = dict(new)
        for k, v in d.items():
            new[k] = ctx.G[k] + v
        print(f'excl={[cids[i] for i in range(K) if excl[i]]} medcos={np.round(medcos,2).tolist()}')
        return new, {'weights': w.tolist()}
    except Exception as exc:
        print(f'fallback FedAvg: {exc}')
        return ctx.fedavg(), {'weights': w0.tolist()}

The program flags a client whose update norm exceeds three times the median norm, or whose median cosine with the other clients is negative and at least 0.05 below the median over all clients; it counts flags in ctx.memory, clips accepted updates to their median norm and returns FedAvg if anything raises an exception. Its successors kept the exclusion rule and added class-evidence weighting of the classifier rows (round 11), a proxy-checked choice between server steps of 1.0 and 1.3 (round 31) and a proxy-checked moving average of global models for the last rounds (round 51).

04

Why it matters

Each aggregation rule in common use encodes one assumption about what goes wrong: label skew, sub-models of different widths, or malicious clients. A deployment rarely knows in advance which assumption holds. FedReason lets the server read the client models it actually received and write the rule the evidence supports, as a program it can replace every ten rounds, without fitting a single parameter on the server. The rows of a classifier reveal which classes a client has seen, and the size and direction of an update reveal whether it agrees with the others; a weighted average throws that information away.

The design is practical by construction. The clients run ordinary local training and nothing changes on their side. Full weight tensors never leave the server, every program is dry-run before it aggregates a round and checked in every round with a FedAvg fallback, and each decision is stored as code together with its rationale so it can be audited after training. A 60-round run needs six invocations at 0.13 USD and about 41 seconds each, a cost fixed in advance that grows with neither the model size nor the number of rounds between invocations.

05

Cite this work

@misc{mohammadiruzbahani2026fedreason,
  title         = {{FedReason}: Large Language Models as Weight-Space Meta-Aggregators for Heterogeneous Federated Learning},
  author        = {Mohammadi Ruzbahani, Ali and Yazdinejad, Abbas and Karimipour, Hadis},
  year          = {2026},
  eprint        = {2611.08383},
  archivePrefix = {arXiv},
  doi           = {10.48550/arXiv.2611.08383},
  url           = {https://arxiv.org/abs/2611.08383}
}