SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2003.03564 · 2020

Ternary Compression for Communication-Efficient Federated Learning

arXiv · PDF · Open in the Atlas

Code that ran

7 of 11 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 7 have no contract verdict; 0 failures of our instrument; 4 no recorded run), measured 2026-11-22; 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/2003.03564.json · badge: /api/ran/2003.03564.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
VeritasXu/Ternary-Federated canonical (classifier label)
classifier basis: census
7 ran · 4 no recorded run
FunctionStatusWhere it lives
Quantized_CNN Ran
ran on a synthesized input
VeritasXu/Ternary-Federated/model/CNN.py
code served (permissive licence) · get_code("73adecfb184d05a3")
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.optim as optim

torch.manual_seed(0)

class SimpleModel(nn.Module):
    def __init__(self):
        super().__init__()
        # Create layers with 'fp' in name for weights/biases
        self.fp_layer1 = nn.Linear(4, 3)
        self.fp_layer2 = nn.Linear(3, 2)
        
        # Create ternary conv layers
        self.ternary_conv1 = nn.Conv2d(1, 2, kernel_size=3)
        
        # Create batch norm layers with 'norm' in name
        self.norm1 = nn.BatchNorm2d(2)
        self.norm2 = nn.BatchNorm1d(3)
    
    def forward(self, x):
        return x

class ArgsConfig:
    def __init__(self):
        self.lr = 0.001

pre_model = SimpleModel()
args = ArgsConfig()

ARGS = {
    'pre_model': pre_model,
    'args': args
}
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
Quantized_MLP Ran
ran on a synthesized input
VeritasXu/Ternary-Federated/model/MLP.py
code served (permissive licence) · get_code("d5fecfb63fd31a6d")
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.optim as optim

torch.manual_seed(0)

# Create a simple model with the expected layer structure
class SimpleMLPModel(nn.Module):
    def __init__(self):
        super().__init__()
        self.fp_layer1 = nn.Linear(4, 3)
        self.fp_layer2 = nn.Linear(3, 2)
        self.ternary_layer = nn.Linear(2, 2)
    
    def forward(self, x):
        x = self.fp_layer1(x)
        x = self.fp_layer2(x)
        x = self.ternary_layer(x)
        return x

# Create the pre-trained model
pre_model = SimpleMLPModel()

# Create a simple args object with lr attribute
class Args:
    def __init__(self):
        self.lr = 0.01

args = Args()

ARGS = {
    'pre_model': pre_model,
    'args': args
}
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
Quantized_resnet Ran
ran on a synthesized input
VeritasXu/Ternary-Federated/model/resnet.py
code served (permissive licence) · get_code("5ad6b119a1012940")
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

torch.manual_seed(0)

class ResidualBlock(nn.Module):
    def __init__(self):
        super().__init__()
        self.conv1 = nn.Conv2d(3, 3, 3, padding=1)
        self.norm1 = nn.BatchNorm2d(3)
        self.conv2 = nn.Conv2d(3, 3, 3, padding=1)
        self.norm2 = nn.BatchNorm2d(3)
    
    def forward(self, x):
        return x

class SimpleResNet(nn.Module):
    def __init__(self):
        super().__init__()
        self.features = nn.Module()
        self.features.conv0 = nn.Conv2d(3, 3, 3, padding=1)
        self.features.ResidualBlock1 = ResidualBlock()
        self.features.ResidualBlock2 = ResidualBlock()
        self.classifier = nn.Linear(3 * 4 * 4, 10)
    
    def forward(self, x):
        return self.classifier(x.view(x.size(0), -1))

pre_model = SimpleResNet()

class Args:
    def __init__(self):
        self.lr = 0.001

args = Args()

ARGS = {
    'pre_model': pre_model,
    'args': args
}
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
assign_class Ran
ran on a synthesized input
VeritasXu/Ternary-Federated/utils/load_mnist.py
code served (permissive licence) · get_code("4cd79ed37e858055")
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 random

# Set random seed for reproducibility
random.seed(0)

# The function assign_class takes two parameters:
# - n_client: number of clients (int)
# - nc: number of classes per client (int)
# 
# The function uses these to initialize class assignments in a non-iid setting
# where each client gets nc distinct classes from the 10 total classes,
# and ensures all 10 classes are covered across all clients.

ARGS = {
    "n_client": 5,
    "nc": 2,
}
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 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
get_default_data_transforms Ran
ran on a synthesized input
VeritasXu/Ternary-Federated/utils/data_utils.py
code served (permissive licence) · get_code("416dfb90fb5db29a")
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 torchvision.transforms as transforms

# The function get_default_data_transforms takes:
# - name: str (dataset name like 'mnist' or 'cifar10')
# - train: bool (whether to return training or evaluation transforms)
# - verbose: bool (whether to print transformation details)

# Reading the function body:
# - It accesses transforms_train[name] and transforms_eval[name]
# - It iterates over .transforms attribute of the composed transforms
# - It prints each transformation
# - It returns a tuple of two transform objects

# The function supports 'mnist' and 'cifar10' datasets based on the hardcoded dicts

ARGS = {
    'name': 'mnist',
    'train': True,
    'verbose': True
}
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, 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
init_class Ran
ran on a synthesized input
VeritasXu/Ternary-Federated/utils/load_mnist.py
code served (permissive licence) · get_code("4452e9be4aadec2f")
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 random

def init_class(n_client, nc):
    """
    Used for non-iid setting, initialize classes in each client
    :param n_client:
    :param nc:
    :return:
    """
    n_part = [[] for _ in range(n_client)]
    all_class = [_c for _c in range(10)]
    assigned_set = set([])
    for _i in range(0, n_client):
        while len(set(n_part[_i])) < nc:
            tmp_c = random.choice(all_class)
            if tmp_c not in n_part[_i]:
                n_part[_i].append(tmp_c)
        assigned_set = assigned_set | set(n_part[_i])
    return (n_part, assigned_set)


random.seed(42)

ARGS = {
    "n_client": 5,
    "nc": 2
}
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 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
split_image_data Ran
ran on a synthesized input
VeritasXu/Ternary-Federated/utils/data_utils.py
code served (permissive licence) · get_code("c33b295e9a6d638b")
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

# Create small synthetic image data with labels
np.random.seed(0)

# Create 100 data samples with shape (28, 28) - small "images"
data = np.random.randn(100, 28, 28).astype(np.float32)

# Create labels: 20 samples each from classes 0-4 (5 classes total)
labels = np.array([i // 20 for i in range(100)], dtype=np.int64)

ARGS = {
    "data": data,
    "labels": labels,
    "n_clients": 5,
    "classes_per_client": 2,
    "shuffle": True,
    "verbose": True,
    "balancedness": 1.0,
}
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
accuracy Not yet run
unverified (harvested, no recorded run)
VeritasXu/Ternary-Federated/utils/Evaluate.py
code served (permissive licence) · get_code("4e069beede38eca8")
How it ran

no invocation recorded.

default_loader Not yet run
unverified (harvested, no recorded run)
VeritasXu/Ternary-Federated/utils/load_mnist.py
code served (permissive licence) · get_code("250c0467006c5b33")
How it ran

no invocation recorded.

evaluate Not yet run
unverified (harvested, no recorded run)
VeritasXu/Ternary-Federated/utils/Evaluate.py
code served (permissive licence) · get_code("4c9d08b2b9135f96")
How it ran

no invocation recorded.

get_dataset Not yet run
unverified (harvested, no recorded run)
VeritasXu/Ternary-Federated/utils/data_utils.py
code served (permissive licence) · get_code("31499f814edb01ee")
How it ran

no invocation recorded.

Also present in other papers' code

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

Repositories linked to this paper

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

Abstract

Learning over massive data stored in different locations is essential in many real-world applications. However, sharing data is full of challenges due to the increasing demands of privacy and security with the growing use of smart mobile devices and IoT devices. Federated learning provides a potential solution to privacy-preserving and secure machine learning, by means of jointly training a global model without uploading data distributed on multiple devices to a central server. However, most existing work on federated learning adopts machine learning models with full-precision weights, and almost all these models contain a large number of redundant parameters that do not need to be transmitted to the server, consuming an excessive amount of communication costs. To address this issue, we propose a federated trained ternary quantization (FTTQ) algorithm, which optimizes the quantized networks on the clients through a self-learning quantization factor. Theoretical proofs of the convergence of quantization factors, unbiasedness of FTTQ, as well as a reduced weight divergence are given. On the basis of FTTQ, we propose a ternary federated averaging protocol (T-FedAvg) to reduce the upstream and downstream communication of federated learning systems. Empirical experiments are conducted to train widely used deep learning models on publicly available datasets, and our results demonstrate that the proposed T-FedAvg is effective in reducing communication costs and can even achieve slightly better performance on non-IID data in contrast to the canonical federated learning algorithms.

For agents

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

get_harvested_code_for_paper("2003.03564")
get_code_for_paper("2003.03564")
have("2003.03564")

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

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

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

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

Connect an agent — have() is free.