SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2205.10920 · ICLR · 2023

Test-Time Robust Personalization for Federated Learning

Tao Lin, Liangze Jiang

arXiv · PDF · Open in the Atlas

Code that ran

11 of 14 samples (functions and classes) lifted from this paper's linked repositories executed on a synthesized input in Syntology's jail (0 of them constructed an object rather than computing a result; 0 honoured the contract we drafted, 0 violated it and 11 have no contract verdict; 0 failures of our instrument; 3 no recorded run), measured 2026-11-23; repository links from the Papers with Code archive attributed under CC BY-SA, no affiliation; bodies inline only under a permissive licence as GitHub detects it. Not a reproduction of the paper's results.

"Ran" means the function executed on a synthesized input and returned a value. It is not a reproduction of the paper's results. This record, dated, as JSON: /api/ran/2205.10920.json · badge: /api/ran/2205.10920.svg

Each repository's role is a label: a classifier's output recorded on the link, or, where no role is recorded, what the Papers with Code archive marked. The line under it names its basis. Neither says who wrote the code.

RepositoryRoleRan
LINs-lab/FedTHE canonical (classifier label)
classifier basis not recorded on the link
11 ran · 3 no recorded run
FunctionStatusWhere it lives
build_non_iid_by_dirichlet Ran
ran on a synthesized input
LINs-lab/FedTHE/BRFL/partition_data.py
code served (permissive licence) · get_code("23af7c10d53271dd")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned list. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import numpy as np
from numpy.random import RandomState

# Create a random state object
random_state = RandomState(seed=42)

# Define parameters
num_classes = 3
num_indices = 12
n_workers = 5
non_iid_alpha = 0.5

# Create indices2targets
# This should be an array where each row contains [index, target_class]
# We need num_indices rows
indices2targets = np.array([
    [i, i % num_classes] for i in range(num_indices)
])

ARGS = {
    'random_state': random_state,
    'indices2targets': indices2targets,
    'non_iid_alpha': non_iid_alpha,
    'num_classes': num_classes,
    'num_indices': num_indices,
    'n_workers': n_workers
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type list — a list output has no array shape of its own; none is stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
build_script Ran
ran on a synthesized input
LINs-lab/FedTHE/run_exps.py
code served (permissive licence) · get_code("3050038b77105453")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned str. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import copy
import random
import time

class Config:
    def __init__(self):
        self.python_path = '/usr/bin/python3'
        self.hostfile = '/etc/hosts'
        self.learning_rate = 0.001
        self.batch_size = 32
        self.epochs = 10
        self.model_name = 'bert-base'

conf_root = Config()

replacement_dict = {
    'learning_rate': 0.0001,
    'batch_size': 64
}

ARGS = {
    'conf_root': conf_root,
    'idx': 5,
    'replacement': replacement_dict,
    'job_id': '/tmp/tmp_job_123'
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
none outside the standard library — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type str — a str output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a str output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
determine_arch Ran
ran on a synthesized input
LINs-lab/FedTHE/pcode/create_model.py
code served (permissive licence) · get_code("8cb1bca3828633f8")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned SimpleModel. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import torch.nn as nn

torch.manual_seed(0)

# Small stand-in model
class SimpleModel(nn.Module):
    def __init__(self):
        super().__init__()
        self.linear = nn.Linear(4, 3)
    
    def forward(self, x):
        return self.linear(x)

# Create example architectures
master_arch = SimpleModel()
worker_arch_1 = SimpleModel()
worker_arch_2 = SimpleModel()

# Test case 1: use_complex_arch=False, simple path
ARGS = {
    'client_id': 0,
    'n_clients': 4,
    'arch': master_arch,
    'use_complex_arch': False,
    'arch_info': {
        'master': master_arch,
        'worker': [worker_arch_1, worker_arch_2],
        'num_clients_per_model': 2
    }
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type SimpleModel — a SimpleModel output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a SimpleModel output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
environ Ran
ran on a synthesized input
LINs-lab/FedTHE/env/utils.py
code served (permissive licence) · get_code("b01fd6c2ed0b59ca")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned str. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import os

# The environ function takes one parameter: env
# It calls os.getenv(env) which retrieves an environment variable by name
# We need to pass a string representing an environment variable name

# Set up a test environment variable
os.environ['TEST_VAR'] = 'test_value'

ARGS = {
    'env': 'TEST_VAR'
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
none outside the standard library — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type str — a str output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a str output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
gaussian_noise Ran
ran on a synthesized input
LINs-lab/FedTHE/BRFL/corr_data.py
code served (permissive licence) · get_code("aa8d742f576ad186")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned ndarray, ndim 4, dtype family float, shape (2, 4, 3, 3) as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import numpy as np

# Create a random state object
random_state = np.random.RandomState(42)

# Create a small image array (batch of 2, 4x3 images with 3 channels)
x = np.random.randint(0, 256, size=(2, 4, 3, 3), dtype=np.uint8)

# Define ARGS dict with all required parameters
ARGS = {
    "x": x,
    "random_state": random_state,
    "severity": 1
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type ndarray, ndim 4, dtype family float, shape (2, 4, 3, 3) — shape (2, 4, 3, 3) as a later run recorded it
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
import_string Ran
ran on a synthesized input
LINs-lab/FedTHE/run_exps.py
code served (permissive licence) · get_code("805f87452deac36d")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned type. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import sys
import six
import importlib

# Test with a valid dotted path that exists in the standard library
# We'll use 'os.path' which will import the 'path' module from 'os'
# But since os.path is special, let's use something more straightforward

# Valid example: 'collections.OrderedDict'
ARGS = {
    'dotted_path': 'collections.OrderedDict'
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
six — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type type — a type output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a type output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
inter_client_non_iid_partition Ran
ran on a synthesized input
LINs-lab/FedTHE/BRFL/partition_data.py
code served (permissive licence) · get_code("64b6613d8b1f461b")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned dict. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import numpy as np
from unittest.mock import Mock

# Create a minimal dataset-like object
class FakeDataset:
    def __init__(self, targets, indices):
        self.targets = targets
        self.indices = indices

# Set random seed for reproducibility
np.random.seed(42)
random_state = np.random.RandomState(42)

# Create small dataset with 4 samples, 3 classes
num_samples = 4
num_classes = 3
targets = np.array([0, 1, 2, 0])  # 4 samples, 3 classes
indices = np.array([0, 1, 2, 3])  # All indices included

# Create the dataset object
dataset = FakeDataset(targets=targets, indices=indices)

# Define parameters
non_iid_alpha = 0.5
num_clients = 2

ARGS = {
    "dataset": dataset,
    "non_iid_alpha": non_iid_alpha,
    "random_state": random_state,
    "num_clients": num_clients,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type dict — a dict output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a dict output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
intra_client_uniform_partition Ran
ran on a synthesized input
LINs-lab/FedTHE/BRFL/partition_data.py
code served (permissive licence) · get_code("8af58a2e0cf92656")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned dict. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import numpy as np

# Create a random state object with shuffle method
random_state = np.random.RandomState(42)

# Create indices dict with sample data
# Each key maps to a list of indices that will be partitioned
indices = {
    0: list(range(20)),  # 20 samples for client 0
    1: list(range(15, 35)),  # 20 samples for client 1
    2: list(range(30, 50)),  # 20 samples for client 2
}

# Define train/test/val split ratios
local_tr_ratio = 0.6   # 60% for training
local_te_ratio = 0.2   # 20% for testing
local_val_ratio = 0.2  # 20% for validation (implicit, remainder)

ARGS = {
    'indices': indices,
    'random_state': random_state,
    'local_tr_ratio': local_tr_ratio,
    'local_te_ratio': local_te_ratio,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type dict — a dict output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a dict output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
load_yaml Ran
ran on a synthesized input
LINs-lab/FedTHE/env/utils.py
code served (permissive licence) · get_code("fcdbee2f89a2dda2")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned dict. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import tempfile
import os
import yaml

# Create a temporary YAML file with some test data
temp_dir = tempfile.mkdtemp()
yaml_file = os.path.join(temp_dir, "test.yaml")

# Write a simple YAML structure to the file
test_data = {
    "model": "test_model",
    "learning_rate": 0.001,
    "batch_size": 32,
    "layers": [1, 2, 3]
}

with open(yaml_file, 'w') as f:
    yaml.dump(test_data, f)

# Define ARGS with the file path
ARGS = {
    "file": yaml_file
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
yaml — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type dict — a dict output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a dict output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
shot_noise Ran
ran on a synthesized input
LINs-lab/FedTHE/BRFL/corr_data.py
code served (permissive licence) · get_code("6b1dc63007fce5cf")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned ndarray, ndim 3, dtype family float, shape (2, 4, 3) as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import numpy as np

np.random.seed(0)
random_state = np.random.RandomState(42)

x = np.random.randint(0, 256, size=(2, 4, 3), dtype=np.uint8)

ARGS = {
    "x": x,
    "random_state": random_state,
    "severity": 1
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type ndarray, ndim 3, dtype family float, shape (2, 4, 3) — shape (2, 4, 3) as a later run recorded it
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
transform_data_batch Ran
ran on a synthesized input
LINs-lab/FedTHE/BRFL/prepare_data.py
code served (permissive licence) · get_code("4b629456a8ba1323")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned tuple. The image it ran in was not recorded. The code mentions cuda, and the harness aliases cuda to the CPU for every sample; whether this run needed that is not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import torchvision.transforms as transforms
from PIL import Image

torch.manual_seed(0)

# Create a small valid image tensor (batch_size=2, channels=3, height=32, width=32)
# The function expects a PIL Image or tensor that can be normalized
_input = torch.randint(0, 256, (2, 3, 32, 32), dtype=torch.uint8).float() / 255.0

# Create target tensor (batch_size=2, with class indices)
_target = torch.tensor([0, 1], dtype=torch.long)

ARGS = {
    "_input": _input,
    "_target": _target,
    "is_training": True
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
PIL, torch, torchvision — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type tuple — a tuple output has no array shape of its own; none is stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
define_imagenet_variant_folder Not yet run
unverified (harvested, no recorded run)
LINs-lab/FedTHE/BRFL/loaders/imagenet_variant_folder.py
code served (permissive licence) · get_code("cb1cbd4c31520eae")
How it ran

no invocation recorded.

impulse_noise Not yet run
unverified (harvested, no recorded run)
LINs-lab/FedTHE/BRFL/corr_data.py
code served (permissive licence) · get_code("f67930386b129f43")
How it ran

no invocation recorded.

read_replacements_from_python_class Not yet run
unverified (harvested, no recorded run)
LINs-lab/FedTHE/run_exps.py
code served (permissive licence) · get_code("321a3028137d8890")
How it ran

no invocation recorded.

Also present in other papers' code

Of 14 samples lifted from this paper's linked repositories, 14 carry a function identity and 0 do not. Of the 14 distinct functions with an identity, 0 are also present in other papers whose code we hold (0 with at least one paper dated earlier, 0 the same month, 0 later) and 14 are only here among the 52,977 papers whose code Syntology holds (as of 2026-09-26).

Only here means: among the 52,977 papers whose code Syntology holds (51,887 with lifted samples, 1,090 through their assemblies only), as of 2026-09-26, no other paper's lifted samples or current assembly bricks contain an identical function body after normalisation.

Presence, not direction: an identical function body in two papers' repositories does not say who wrote it, which came from which, or that either paper's method rests on it. Matching is exact after normalisation, so a renamed or edited function is not matched. Dates are when papers appeared, not when code was written. Only .py files the harvester lifted are covered; notebooks are not read. A new-style arXiv id YYMM.NNNN dates a paper to the month 20YY-MM; otherwise Paper.year dates it to the year; otherwise it is undated. Dates are when the paper appeared, not when the code was written. Read 2026-11-23.

Repositories linked to this paper

Some links come from the archived Papers with Code dataset (CC BY-SA 4.0): attribution and licence.

Abstract

Federated Learning (FL) is a machine learning paradigm where many clients collaboratively learn a shared global model with decentralized training data. Personalized FL additionally adapts the global model to different clients, achieving promising results on consistent local training and test distributions. However, for real-world personalized FL applications, it is crucial to go one step further: robustifying FL models under the evolving local test set during deployment, where various distribution shifts can arise. In this work, we identify the pitfalls of existing works under test-time distribution shifts and propose Federated Test-time Head Ensemble plus tuning (FedTHE+), which personalizes FL models with robustness to various test-time distribution shifts. We illustrate the advancement of FedTHE+ (and its computationally efficient variant FedTHE) over strong competitors, by training various neural architectures (CNN, ResNet, and Transformer) on CIFAR10 and ImageNet with various test distributions. Along with this, we build a benchmark for assessing the performance and robustness of personalized FL methods during deployment. Code: https://github.com/LINs-lab/FedTHE.

For agents

The same record, over MCP at https://syntology.ai/mcp:

get_harvested_code_for_paper("2205.10920")
get_code_for_paper("2205.10920")
have("2205.10920")

The run record, dated, one paper per request, free:

curl https://syntology.ai/api/ran/2205.10920.json

A badge for a README (the split and the date, never a ratio):

[![Syntology run record](https://syntology.ai/api/ran/2205.10920.svg)](https://syntology.ai/paper/2205.10920)

Connect an agent — have() is free.