SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2012.04221 · ICML · 2021

Ditto: Fair and Robust Federated Learning Through Personalization

Tian Li, Virginia Smith, Shengyuan Hu, Ahmad Beirami

arXiv · PDF · Open in the Atlas

Code that ran

15 of 18 samples (functions and classes) lifted from this paper's linked repositories executed on a synthesized input in Syntology's jail (5 of them constructed an object rather than computing a result; 7 honoured the contract we drafted, 0 violated it and 5 have no contract verdict; 3 failures of our instrument; 3 no recorded run), measured 2026-11-21; 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/2012.04221.json · badge: /api/ran/2012.04221.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
litian96/ditto canonical (classifier label)
classifier basis: classifier_2025
12 ran · 2 no recorded run
TsingZ0/PFL-Non-IID community
Papers with Code archive
2 ran · 1 no recorded run
s-huu/pmtl community
Papers with Code archive
1 ran · 0 no recorded run
FunctionStatusWhere it lives
Client Ran
ran on a synthesized input · constructed an object; no result was computed
s-huu/pmtl/models/client.py
pointer only (licence: NONE) · get_code("a1556d3952f305a1")
How it ran

The body of this sample is withheld: GitHub detected no licence in this paper's repository, s-huu/pmtl when it was checked. The setup block that called it is withheld with it, because it is written against that body. source_path and origin say where the code lives, to read under the repository's own terms. A run is recorded.

Client Ran
ran on a synthesized input · constructed an object; no result was computed
litian96/ditto/flearn/trainers_MTL/ditto.py
code served (permissive licence) · get_code("28ccbe9b7b7704b0")
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 an instance of its own class, Client: the run constructed the object and did not call it, so no result was computed. 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
import numpy as np

torch.manual_seed(0)

# Define a minimal model that implements all methods called by Client
class SimpleModel(nn.Module):
    def __init__(self):
        super().__init__()
        self.linear = nn.Linear(4, 3)
        self.size = 100
        self.flops = 1000
    
    def set_params(self, model_params):
        """set model parameters"""
        pass
    
    def get_params(self):
        """get model parameters"""
        return [p.clone() for p in self.parameters()]
    
    def get_gradients(self, mini_batch_data):
        """get model gradient"""
        x, y = mini_batch_data['x'], mini_batch_data['y']
        if isinstance(x, list):
            x = torch.stack(x)
        if isinstance(y, list):
            y = torch.stack(y)
        output = self.linear(x)
        loss = nn.functional.mse_loss(output, y)
        loss.backward()
        return [p.grad.clone() if p.grad is not None else torch.zeros_like(p) for p in self.parameters()]
    
    def get_data_gradients(self, data):
        """get data gradients"""
        return self.get_gradients(data)
    
    def get_loss(self, data):
        """get loss on data"""
        x, y = data['x'], data['y']
        if isinstance(x, list):
            x = torch.stack(x)
        if isinstance(y, list):
            y = torch.stack(y)
        output = self.linear(x)
        loss = nn.functional.mse_loss(output, y)
        return loss.item()
    
    def test(self, data):
        """test model on data, return correct count and loss"""
        x, y = data['x'], data['y']
        if isinstance(x, list):
            x = torch.stack(x)
        if isinstance(y, list):
            y = torch.stack(y)
        output = self.linear(x)
        loss = nn.functional.mse_loss(output, y)
        tot_correct = torch.sum((output.argmax(dim=1) == y.argmax(dim=1))).item()
        return (tot_correct, loss.item())
    
    def get_softmax(self, data):
        """get softmax output"""
        x, y = data['x'], data['y']
        if isinstance(x, list):
            x = torch.stack(x)
        output = self.linear(x)
        return torch.nn.functional.softmax(output, dim=1)
    
    def get_kl_gradients(self, data, output2):
        """get KL divergence gradients"""
        return self.get_gradients(data)
    
    def solve_inner(self, data, num_epochs=1, batch_size=10):
        """solve inner optimization problem"""
        x, y = data['x'], data['y']
        if isinstance(x, list):
            x = torch.stack(x)
        if isinstance(y, list):
            y = torch.stack(y)
        output = self.linear(x)
        loss = nn.functional.mse_loss(output, y)
        soln = [p.clone() for p in self.parameters()]
        comp = self.flops * len(x) * num_epochs
        return (soln, comp)
    
    def solve_sgd(self, mini_batch_data):
        """run one iteration of SGD"""
        x, y = mini_batch_data['x'], mini_batch_data['y']
        if isinstance(x, list):
            x = torch.stack(x)
        if isinstance(y, list):
            y = torch.stack(y)
        output = self.linear(x)
        loss = nn.functional.mse_loss(output, y)
        loss.backward()
        grads = [p.grad.clone() if p.grad is not None else torch.zeros_like(p) for p in self.parameters()]
        weights = [p.clone() for p in self.parameters()]
        return (grads, loss.item(), weights)

# Create sample data
x_train = [torch.randn(4) for _ in range(2)]
y_train = [torch.randn(3) for _ in range(2)]
x_eval = [torch.randn(4) for _ in range(2)]
y_eval = [torch.randn(3) for _ in range(2)]

train_data = {'x': x_train, 'y': y_train}
eval_data = {'x': x_eval, 'y': y_eval}

model = SimpleModel()

ARGS = {
    'id': 'client_0',
    'group': 'group_1',
    'train_data': train_data,
    'eval_data': eval_data,
    'dynamic_lam': 0,
    'model': model
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Client — the run constructed an instance of its own class and did not call it; no shape is stated — the instrument coerces any output to an array; for a Client 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
Client Ran
ran on a synthesized input · constructed an object; no result was computed
TsingZ0/PFL-Non-IID/system/flcore/clients/clientditto.py
code served (permissive licence) · get_code("32af92c541fa7fd4")
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 an instance of its own class, Client: the run constructed the object and did not call it, so no result was computed. 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
import copy

torch.manual_seed(0)

class SimpleModel(nn.Module):
    def __init__(self, num_classes=10):
        super(SimpleModel, self).__init__()
        self.fc1 = nn.Linear(4, 8)
        self.fc2 = nn.Linear(8, num_classes)
    
    def forward(self, x):
        if isinstance(x, (list, tuple)):
            x = x[0]
        x = x.view(x.size(0), -1)
        x = torch.relu(self.fc1(x))
        x = self.fc2(x)
        return x

class Args:
    def __init__(self):
        self.model = SimpleModel(num_classes=10)
        self.algorithm = "fedavg"
        self.dataset = "CIFAR10"
        self.device = torch.device("cpu")
        self.save_folder_name = "test_folder"
        self.num_classes = 10
        self.batch_size = 2
        self.local_learning_rate = 0.01
        self.local_epochs = 1
        self.few_shot = 0
        self.learning_rate_decay_gamma = 0.99
        self.learning_rate_decay = False

ARGS = {
    'args': Args(),
    'id': 0,
    'train_samples': 10,
    'test_samples': 5,
    'train_slow': False,
    'send_slow': False,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, sklearn, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Client — the run constructed an instance of its own class and did not call it; no shape is stated — the instrument coerces any output to an array; for a Client 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
Metrics Ran
ran on a synthesized input · constructed an object; no result was computed
litian96/ditto/flearn/trainers_MTL/ditto.py
code served (permissive licence) · get_code("233b429a0a949b47")
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 an instance of its own class, Metrics: the run constructed the object and did not call it, so no result was computed. 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
import os

class Client:
    def __init__(self, id):
        self.id = id

clients = [Client(0), Client(1), Client(2)]

params = {
    'num_rounds': 5,
    'dataset': 'mnist',
    'eval_every': 1,
    'learning_rate': 0.01,
    'mu': 0.1,
    'num_epochs': 3,
    'batch_size': 32,
    'seed': 42,
    'optimizer': 'sgd'
}

ARGS = {
    'clients': clients,
    'params': params
}
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 Metrics — the run constructed an instance of its own class and did not call it; no shape is stated — the instrument coerces any output to an array; for a Metrics 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
PerturbedGradientDescent Ran
ran on a synthesized input · constructed an object; no result was computed
TsingZ0/PFL-Non-IID/system/flcore/clients/clientditto.py
code served (permissive licence) · get_code("9854d9cf40e3f076")
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 an instance of its own class, PerturbedGradientDescent: the run constructed the object and did not call it, so no result was computed. 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
from torch.optim import Optimizer

torch.manual_seed(0)

# Create a simple model with parameters
class SimpleModel(nn.Module):
    def __init__(self):
        super().__init__()
        self.linear1 = nn.Linear(4, 3)
        self.linear2 = nn.Linear(3, 2)
    
    def forward(self, x):
        x = self.linear1(x)
        x = self.linear2(x)
        return x

# Instantiate the model
model = SimpleModel()

# Create parameters list from model
params = list(model.parameters())

# Initialize gradients for the parameters
for p in params:
    p.grad = torch.randn_like(p)

# Create global_params as a copy of current parameters
global_params = [p.data.clone() for p in params]

# Create device (CPU only)
device = torch.device('cpu')

# Build ARGS dictionary
ARGS = {
    'params': params,
    'lr': 0.01,
    'mu': 0.5,
}
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 PerturbedGradientDescent — the run constructed an instance of its own class and did not call it; no shape is stated — the instrument coerces any output to an array; for a PerturbedGradientDescent 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
_one_hot Ran
ran, honoured the contract we drafted
litian96/ditto/flearn/trainers_MTL/ditto.py
code served (permissive licence) · get_code("aa23df8a70a46151")
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, ndim 1, dtype family int; no output shape is stated. The image it ran in was not recorded. If your copy returns the same type and ndim 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 numpy as np

torch.manual_seed(0)

# Analyze the function:
# - index: used as int(index), should be a number in range [0, size)
# - size: used in range(size), should be a positive integer

index = 2
size = 5

ARGS = {
    "index": index,
    "size": size,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type list, ndim 1, dtype family int — a list output has no array shape of its own; none is stated
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
gen_batch Ran
ran; our contract draft was wrong, not the code
litian96/ditto/flearn/trainers_MTL/ditto.py
code served (permissive licence) · get_code("1a363a8bc16a6fb6")
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 generator. 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 sample data
data = {
    'x': np.random.randn(10, 4),  # 10 samples, 4 features
    'y': np.random.randint(0, 2, 10)  # 10 labels
}

batch_size = 2
num_iter = 5

ARGS = {
    'data': data,
    'batch_size': batch_size,
    'num_iter': num_iter
}
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 generator — a generator output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a generator 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
gen_batch_celeba Ran
ran; our contract draft was wrong, not the code
litian96/ditto/flearn/trainers_MTL/ditto.py
code served (permissive licence) · get_code("cfb67307b19711db")
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 generator. 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

# Set seed for reproducibility
np.random.seed(42)

# Create minimal valid data for the function
# The function expects:
# - data: dict with 'x' and 'y' keys
# - batch_size: int
# - num_iter: int

# Build sample words and labels
raw_x_batch = ['hello', 'world', 'test', 'code']
raw_y_batch = ['a', 'b', 'c', 'd']

# Create the data dictionary
data = {
    'x': raw_x_batch,
    'y': raw_y_batch
}

# Define parameters
batch_size = 2
num_iter = 3

ARGS = {
    'data': data,
    'batch_size': batch_size,
    'num_iter': num_iter
}
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 generator — a generator output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a generator 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
get_stdev Ran
ran, honoured the contract we drafted
litian96/ditto/flearn/trainers_MTL/ditto.py
code served (permissive licence) · get_code("5fc4fb53f71ddfec")
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 float64, ndim 0, dtype family float, shape () 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 sample parameters as a list of numpy arrays
# The function expects grads to be indexable and each element to be appendable
param1 = np.array([1.0, 2.0, 3.0, 4.0])
param2 = np.array([5.0, 6.0])
param3 = np.array([7.0, 8.0, 9.0])

parameters = [param1, param2, param3]

ARGS = {
    "parameters": parameters
}
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 float64, ndim 0, dtype family float, shape () — shape () 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
l2_clip Ran
ran; our contract draft was wrong, not the code
litian96/ditto/flearn/trainers_MTL/ditto.py
code served (permissive licence) · get_code("dd5f52ea37990475")
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

# l2_clip expects cgrads which is a list of lists of numpy arrays
# Each element in cgrads represents gradients from one client
# Each client's gradients is a list of numpy arrays (e.g., one per layer)

# Create sample client gradients
# Client 1: list of 2 gradient arrays with different shapes
client1_grads = [
    np.array([0.1, 0.2, 0.3, 0.4]),
    np.array([0.05, 0.15])
]

# Client 2: list of 2 gradient arrays with different shapes
client2_grads = [
    np.array([0.2, 0.1, 0.05, 0.3]),
    np.array([0.1, 0.2])
]

# Client 3: list of 2 gradient arrays with different shapes
client3_grads = [
    np.array([0.3, 0.25, 0.1, 0.05]),
    np.array([0.15, 0.25])
]

# cgrads is a list of client gradient lists
cgrads = [client1_grads, client2_grads, client3_grads]

ARGS = {
    "cgrads": cgrads
}
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
letter_to_vec Ran
ran, honoured the contract we drafted
litian96/ditto/flearn/trainers_MTL/ditto.py
code served (permissive licence) · get_code("9bc011aaf4c2fb8e")
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, ndim 1, dtype family int; no output shape is stated. The image it ran in was not recorded. If your copy returns the same type and ndim 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

ALL_LETTERS = '\n !"&\'(),-.0123456789:;>?ABCDEFGHIJKLMNOPQRSTUVWXYZ[]abcdefghijklmnopqrstuvwxyz}'

NUM_LETTERS = len(ALL_LETTERS)

def _one_hot(index, size):
    """returns one-hot vector with given size and value 1 at given index
    """
    vec = [0 for _ in range(size)]
    vec[int(index)] = 1
    return vec

def letter_to_vec(letter):
    """returns one-hot representation of given letter
    """
    index = ALL_LETTERS.find(letter)
    return _one_hot(index, NUM_LETTERS)

ARGS = {
    "letter": "A"
}
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 list, ndim 1, dtype family int — a list output has no array shape of its own; none is stated
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
process_grad Ran
ran, honoured the contract we drafted
litian96/ditto/flearn/trainers_MTL/ditto.py
code served (permissive licence) · get_code("47055aade47bacbb")
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 1, dtype family float, shape (9,) 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 sample gradient arrays of different shapes to test flattening
grad1 = np.array([1.0, 2.0, 3.0, 4.0])
grad2 = np.array([5.0, 6.0, 7.0])
grad3 = np.array([8.0, 9.0])

# Create list of gradients (list of numpy arrays)
grads = [grad1, grad2, grad3]

ARGS = {
    "grads": grads
}
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 1, dtype family float, shape (9,) — shape (9,) 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
process_x Ran
ran, honoured the contract we drafted
litian96/ditto/flearn/trainers_MTL/ditto.py
code served (permissive licence) · get_code("b9512fc3db0c9012")
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 2, dtype family int, shape (2, 5) 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

# Setup for process_x function
# The function takes raw_x_batch (a list of words/strings) and converts them to indices

raw_x_batch = ["hello", "world"]

ARGS = {
    "raw_x_batch": raw_x_batch
}
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 2, dtype family int, shape (2, 5) — shape (2, 5) 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
process_y Ran
ran, honoured the contract we drafted
litian96/ditto/flearn/trainers_MTL/ditto.py
code served (permissive licence) · get_code("9af2b978a7e47647")
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, ndim 2, dtype family int; no output shape is stated. The image it ran in was not recorded. If your copy returns the same type and ndim 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 numpy as np

ALL_LETTERS = '\n !"&\'(),-.0123456789:;>?ABCDEFGHIJKLMNOPQRSTUVWXYZ[]abcdefghijklmnopqrstuvwxyz}'

NUM_LETTERS = len(ALL_LETTERS)

def _one_hot(index, size):
    """returns one-hot vector with given size and value 1 at given index
    """
    vec = [0 for _ in range(size)]
    vec[int(index)] = 1
    return vec

def letter_to_vec(letter):
    """returns one-hot representation of given letter
    """
    index = ALL_LETTERS.find(letter)
    return _one_hot(index, NUM_LETTERS)

def process_y(raw_y_batch):
    y_batch = [letter_to_vec(c) for c in raw_y_batch]
    return y_batch

# Setup: raw_y_batch should be a string or sequence of letters
raw_y_batch_value = "abc"

ARGS = {
    "raw_y_batch": raw_y_batch_value
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type list, ndim 2, dtype family int — a list output has no array shape of its own; none is stated
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
word_to_indices Ran
ran, honoured the contract we drafted
litian96/ditto/flearn/trainers_MTL/ditto.py
code served (permissive licence) · get_code("e4cdde6a274b8fac")
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, ndim 1, dtype family int; no output shape is stated. The image it ran in was not recorded. If your copy returns the same type and ndim 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

ALL_LETTERS = '\n !"&\'(),-.0123456789:;>?ABCDEFGHIJKLMNOPQRSTUVWXYZ[]abcdefghijklmnopqrstuvwxyz}'

def word_to_indices(word):
    """returns a list of character indices

    Args:
        word: string
    
    Return:
        indices: int list with length len(word)
    """
    indices = []
    for c in word:
        indices.append(ALL_LETTERS.find(c))
    return indices


ARGS = {
    "word": "Hello"
}
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 list, ndim 1, dtype family int — a list output has no array shape of its own; none is stated
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
BaseFedarated Not yet run
unverified (harvested, no recorded run)
litian96/ditto/flearn/trainers_MTL/ditto.py
code served (permissive licence) · get_code("5ee7ccefc7e9913f")
How it ran

no invocation recorded.

Server Not yet run
unverified (harvested, no recorded run)
litian96/ditto/flearn/trainers_MTL/ditto.py
code served (permissive licence) · get_code("13cd97483b6a43de")
How it ran

no invocation recorded.

clientDitto Not yet run
unverified (harvested, no recorded run)
TsingZ0/PFL-Non-IID/system/flcore/clients/clientditto.py
code served (permissive licence) · get_code("80ce54309324d40d")
How it ran

no invocation recorded.

Also present in other papers' code

Of 18 samples lifted from this paper's linked repositories, 18 carry a function identity and 0 do not. Of the 18 distinct functions with an identity, 5 are also present in other papers whose code we hold (3 with at least one paper dated earlier, 0 the same month, 4 later) and 13 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.

FunctionAlso present inEarliest-datedOthers named
Client
brick of this paper's assembly: helper
9 other papers
2 dated earlier, 7 later · 2 only as an assembly brick
1602.05629 (2016-02)
Communication-Efficient Learning of Deep Networks from Decentralized Data
2001.01523 (2020-01)
Think Locally, Act Globally: Federated Learning with Local and Global Representations
2102.07623 (2021-02)
FedBN: Federated Learning on Non-IID Features via Local Batch Normalization
and 6 more not named here
word_to_indices
brick of this paper's assembly: helper
3 other papers
1 dated earlier, 2 later
1812.06127 (2018-12)
Federated Optimization in Heterogeneous Networks
2206.02078 (2022-06)
Straggler-Resilient Personalized Federated Learning
2407.18365 (2024-07)
FADAS: Towards Federated Adaptive Asynchronous Optimization
Metrics
brick of this paper's assembly: helper
1 other paper
1 later · 1 only as an assembly brick
2202.05963 (2022-02)
Private Adaptive Optimization with Side information
letter_to_vec
brick of this paper's assembly: helper
1 other paper
1 dated earlier
1812.06127 (2018-12)
Federated Optimization in Heterogeneous Networks
process_grad
brick of this paper's assembly: helper
1 other paper
1 later · 1 only as an assembly brick
2202.05963 (2022-02)
Private Adaptive Optimization with Side information

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-21.

Repositories linked to this paper

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

Abstract

Fairness and robustness are two important concerns for federated learning systems. In this work, we identify that robustness to data and model poisoning attacks and fairness, measured as the uniformity of performance across devices, are competing constraints in statistically heterogeneous networks. To address these constraints, we propose employing a simple, general framework for personalized federated learning, Ditto, that can inherently provide fairness and robustness benefits, and develop a scalable solver for it. Theoretically, we analyze the ability of Ditto to achieve fairness and robustness simultaneously on a class of linear problems. Empirically, across a suite of federated datasets, we show that Ditto not only achieves competitive performance relative to recent personalization methods, but also enables more accurate, robust, and fair models relative to state-of-the-art fair or robust baselines.

For agents

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

get_harvested_code_for_paper("2012.04221")
get_code_for_paper("2012.04221")
have("2012.04221")

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

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

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

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

Connect an agent — have() is free.