SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2205.00107 · IJCAI · 2022

Bridging Differential Privacy and Byzantine-Robustness via Model Aggregation

Qing Ling, Heng Zhu

arXiv · PDF · Open in the Atlas

Code that ran

8 of 8 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 8 have no contract verdict; 0 failures of our instrument; 0 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.00107.json · badge: /api/ran/2205.00107.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
oyhah/dp-rsa canonical (classifier label)
classifier basis not recorded on the link
8 ran · 0 no recorded run
FunctionStatusWhere it lives
caL_loss_acc Ran
ran on a synthesized input
oyhah/dp-rsa/code_cnn/MainModel.py
code served (permissive licence) · get_code("3f32f30012d4aaf4")
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, ndim 1, dtype family float; 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 torch.nn as nn
import torch.nn.functional as F

torch.manual_seed(0)

# Define a simple model
class SimpleModel(nn.Module):
    def __init__(self, input_dim=4, num_classes=3):
        super(SimpleModel, self).__init__()
        self.fc = nn.Linear(input_dim, num_classes)
    
    def forward(self, x):
        return self.fc(x)

# Create model instance
model = SimpleModel(input_dim=4, num_classes=3)

# Define device
device = 'cpu'

# Create a simple data loader (list of (data, target) tuples)
data_loader = [
    (torch.randn(2, 4), torch.tensor([0, 1])),
    (torch.randn(2, 4), torch.tensor([2, 1])),
]

# Add dataset attribute to data_loader for len(data_loader.dataset)
class SimpleDataLoader(list):
    def __init__(self, data):
        super().__init__(data)
        self.dataset = SimpleDataset(sum(len(batch[1]) for batch in data))

class SimpleDataset:
    def __init__(self, size):
        self.size = size
    
    def __len__(self):
        return self.size

data_loader = SimpleDataLoader([
    (torch.randn(2, 4), torch.tensor([0, 1])),
    (torch.randn(2, 4), torch.tensor([2, 1])),
])

ARGS = {
    'model': model,
    'device': device,
    'data_loader': data_loader,
}
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 tuple, ndim 1, dtype family float — a tuple 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
caL_loss_acc Ran
ran on a synthesized input
oyhah/dp-rsa/code_neural_network/MainModel.py
code served (permissive licence) · get_code("bfaec8000a21d1d6")
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, ndim 1, dtype family float; 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 torch.nn as nn
import torch.nn.functional as F

torch.manual_seed(0)

# Define a minimal model that satisfies the function's usage
class SimpleModel(nn.Module):
    def __init__(self, input_size=4, num_classes=3):
        super(SimpleModel, self).__init__()
        self.fc = nn.Linear(input_size, num_classes)
    
    def forward(self, x):
        x = self.fc(x)
        return F.log_softmax(x, dim=1)

# Create model
model = SimpleModel(input_size=4, num_classes=3)

# Create device
device = 'cpu'

# Create a minimal data loader (list of tuples with data and target)
# Each batch: input tensor of shape (2, 4), target tensor of shape (2,)
data_loader = [
    (torch.randn(2, 4), torch.randint(0, 3, (2,))),
    (torch.randn(2, 4), torch.randint(0, 3, (2,))),
]

# Add dataset length attribute to data_loader
class DataLoaderWrapper(list):
    def __init__(self, data):
        super().__init__(data)
        self.dataset = type('obj', (object,), {'__len__': lambda self: 4})()

data_loader = DataLoaderWrapper(data_loader)

ARGS = {
    'model': model,
    'device': device,
    'data_loader': data_loader,
}
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 tuple, ndim 1, dtype family float — a tuple 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
flatten_list Ran
ran on a synthesized input
oyhah/dp-rsa/code_cnn/MainModel.py
code served (permissive licence) · get_code("af42962fd71c9b38")
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 Tensor, ndim 2, dtype family float, shape (2, 16) 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 torch

torch.manual_seed(0)

# The function expects `message` to be an iterable of iterables of parameters
# Each inner iterable contains tensors that will be flattened and concatenated
# Let's create a list of lists of small tensors to represent gradients from workers

# Create 2 workers, each with 3 parameter tensors
worker1_params = [
    torch.randn(2, 3),
    torch.randn(4),
    torch.randn(3, 2)
]

worker2_params = [
    torch.randn(2, 3),
    torch.randn(4),
    torch.randn(3, 2)
]

message = [worker1_params, worker2_params]

ARGS = {
    "message": message
}
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 Tensor, ndim 2, dtype family float, shape (2, 16) — shape (2, 16) 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
gauss_attack Ran
ran on a synthesized input
oyhah/dp-rsa/code_neural_network/Attack.py
code served (permissive licence) · get_code("d308dc6844dc14d3")
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 3, dtype family float; 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

torch.manual_seed(0)

# Construct worker_grad as a list of tensors
# The function accesses worker_grad[0] and worker_grad[id] for ids in byzantine
worker_grad = [
    torch.randn(2, 4),
    torch.randn(2, 4),
    torch.randn(2, 4),
]

# regular: appears to be unused in the function body
regular = []

# byzantine: list of indices into worker_grad
byzantine = [1, 2]

ARGS = {
    "worker_grad": worker_grad,
    "regular": regular,
    "byzantine": byzantine,
}
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 3, dtype family float — 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
getData_mnist Ran
ran on a synthesized input
oyhah/dp-rsa/code_neural_network/LoadData.py
code served (permissive licence) · get_code("5f081ca1ab4a9001")
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. 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
import torch
import tempfile
from unittest.mock import patch, MagicMock
from torchvision import datasets, transforms
from torch.utils.data import DataLoader, Subset, Dataset

torch.manual_seed(0)

# Create a minimal mock config
config = {
    'test_batchSize': 2,
    'nodeSize': 4
}

# We need to mock the dataset loading since we can't download
# Create a simple in-memory dataset class
class MockMNISTDataset(Dataset):
    def __init__(self, num_samples=100):
        self.num_samples = num_samples
    
    def __len__(self):
        return self.num_samples
    
    def __getitem__(self, idx):
        # Return (image tensor, label)
        return torch.randn(1, 28, 28), torch.tensor(idx % 10, dtype=torch.long)

class MockImageFolderDataset(Dataset):
    def __init__(self, num_samples=60000):
        self.num_samples = num_samples
    
    def __len__(self):
        return self.num_samples
    
    def __getitem__(self, idx):
        # Return (image tensor, label) - ImageFolder returns (img, class_idx)
        return torch.randn(3, 28, 28), torch.tensor(idx % 10, dtype=torch.long)

# Mock the datasets module to return our mock datasets
def mock_mnist_init(*args, **kwargs):
    train = kwargs.get('train', True)
    if train:
        return MockMNISTDataset(num_samples=60000)
    else:
        return MockMNISTDataset(num_samples=10000)

def mock_imagefolder_init(*args, **kwargs):
    return MockImageFolderDataset(num_samples=60000)

# Patch the datasets
original_mnist = datasets.MNIST
original_imagefolder = datasets.ImageFolder

datasets.MNIST = mock_mnist_init
datasets.ImageFolder = mock_imagefolder_init

ARGS = {
    'setting': 'iid',
    'config': config
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
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
same_value Ran
ran on a synthesized input
oyhah/dp-rsa/code_neural_network/Attack.py
code served (permissive licence) · get_code("a3737f88f3b2da17")
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 3, dtype family float; 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

torch.manual_seed(0)

# The function expects:
# - worker_grad: a list of tensors (indexed by id, and [0] is accessed)
# - regular: a parameter that is passed but not used in the function body
# - byzantine: an iterable of ids to index into worker_grad

# Create a list of worker gradients (small tensors)
worker_grad = [torch.randn(4, 3) for _ in range(5)]

# regular parameter - not used in function body, can be any value
regular = None

# byzantine - list of indices to corrupt
byzantine = [1, 3]

ARGS = {
    "worker_grad": worker_grad,
    "regular": regular,
    "byzantine": byzantine,
}
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 3, dtype family float — 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
sign_flipping Ran
ran on a synthesized input
oyhah/dp-rsa/code_neural_network/Attack.py
code served (permissive licence) · get_code("d53870119fcfea99")
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 3, dtype family float; 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)

# Construct worker_grad as a list of tensors (one per worker)
# The function indexes by id and multiplies, so we need a list/dict structure
worker_grad = [
    torch.randn(2, 4),
    torch.randn(2, 4),
    torch.randn(2, 4),
]

# regular: list of honest worker IDs
regular = [0, 1]

# byzantine: list of byzantine worker IDs that will have their gradients sign-flipped
byzantine = [2]

ARGS = {
    "worker_grad": worker_grad,
    "regular": regular,
    "byzantine": byzantine,
}
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 3, dtype family float — 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
unflatten_vector Ran
ran on a synthesized input
oyhah/dp-rsa/code_cnn/MainModel.py
code served (permissive licence) · get_code("cfa3793c0bbeccfd")
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 torch
import torch.nn as nn

torch.manual_seed(0)

# Create a simple model with a few parameters of different shapes
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

model = SimpleModel()

# Calculate total number of parameters
total_params = sum(p.numel() for p in model.parameters())

# Create a flattened vector with the same total size
vector = torch.randn(total_params)

ARGS = {
    "vector": vector,
    "model": model
}
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 — 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

Also present in other papers' code

Of 8 samples lifted from this paper's linked repositories, 8 carry a function identity and 0 do not. Of the 8 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 8 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

This paper aims at jointly addressing two seemly conflicting issues in federated learning: differential privacy (DP) and Byzantine-robustness, which are particularly challenging when the distributed data are non-i.i.d. (independent and identically distributed). The standard DP mechanisms add noise to the transmitted messages, and entangle with robust stochastic gradient aggregation to defend against Byzantine attacks. In this paper, we decouple the two issues via robust stochastic model aggregation, in the sense that our proposed DP mechanisms and the defense against Byzantine attacks have separated influence on the learning performance. Leveraging robust stochastic model aggregation, at each iteration, each worker calculates the difference between the local model and the global one, followed by sending the element-wise signs to the master node, which enables robustness to Byzantine attacks. Further, we design two DP mechanisms to perturb the uploaded signs for the purpose of privacy preservation, and prove that they are (ϵ, 0)-DP by exploiting the properties of noise distributions. With the tools of Moreau envelop and proximal point projection, we establish the convergence of the proposed algorithm when the cost function is nonconvex. We analyze the trade-off between privacy preservation and learning performance, and show that the influence of our proposed DP mechanisms is decoupled with that of robust stochastic model aggregation. Numerical experiments demonstrate the effectiveness of the proposed algorithm.

For agents

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

get_harvested_code_for_paper("2205.00107")
get_code_for_paper("2205.00107")
have("2205.00107")

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

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

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

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

Connect an agent — have() is free.