SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2302.13485 · 2023

FedCLIP: Fast Generalization and Personalization for CLIP in Federated Learning

arXiv · PDF · Open in the Atlas

Code that ran

8 of 12 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; 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/2302.13485.json · badge: /api/ran/2302.13485.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
microsoft/personalizedfl canonical (classifier label)
classifier basis not recorded on the link
8 ran · 4 no recorded run
FunctionStatusWhere it lives
build_non_iid_by_dirichlet Ran
ran on a synthesized input
microsoft/personalizedfl/datautil/datasplit.py
code served (permissive licence) · get_code("f74d575af34e74e7")
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
import math

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

# Create indices2targets: array of shape (num_samples, 2) where each row is [index, target_class]
# Format: [[sample_index, class_label], ...]
num_samples = 20
num_classes = 3
indices2targets = np.array([[i, i % num_classes] for i in range(num_samples)])

# Parameters
non_iid_alpha = 0.5
num_indices = num_samples
n_workers = 4

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
communication Ran
ran on a synthesized input
microsoft/personalizedfl/alg/core/comm.py
code served (permissive licence) · get_code("10459ba23ee74a45")
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 torch
import torch.nn as nn
import copy

torch.manual_seed(0)

class SimpleModel(nn.Module):
    def __init__(self):
        super(SimpleModel, self).__init__()
        self.linear = nn.Linear(4, 3)
        self.bn = nn.BatchNorm1d(3)
    
    def forward(self, x):
        x = self.linear(x)
        x = self.bn(x)
        return x

class Args:
    def __init__(self, alg, device):
        self.alg = alg
        self.device = device

# Test case 1: FedBN algorithm
server_model = SimpleModel()
models = [SimpleModel() for _ in range(2)]
client_weights = torch.tensor([0.5, 0.5])
args_fedbn = Args('fedbn', 'cpu')

ARGS = {
    'args': args_fedbn,
    'server_model': server_model,
    'models': models,
    'client_weights': client_weights
}
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 — 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
communication Ran
ran on a synthesized input
microsoft/personalizedfl/fedclip/methods/fed_at_clip.py
code served (permissive licence) · get_code("edd2e01f90db21d4")
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 torch
import torch.nn as nn

torch.manual_seed(0)

class ImageAdapter(nn.Module):
    def __init__(self):
        super().__init__()
        self.linear1 = nn.Linear(4, 3)
        self.bn = nn.BatchNorm1d(3)
        self.linear2 = nn.Linear(3, 2)
    
    def forward(self, x):
        x = self.linear1(x)
        x = self.bn(x)
        x = self.linear2(x)
        return x

class ServerModel(nn.Module):
    def __init__(self):
        super().__init__()
        self.img_adap = ImageAdapter()
    
    def forward(self, x):
        return self.img_adap(x)

class ClientModel(nn.Module):
    def __init__(self):
        super().__init__()
        self.img_adap = ImageAdapter()
    
    def forward(self, x):
        return self.img_adap(x)

class Args:
    def __init__(self):
        self.test_envs = [2]

args = Args()

server_model = ServerModel()

models = [
    ClientModel(),
    ClientModel(),
    ClientModel(),
]

client_weights = [0.4, 0.3, 0.3]

ARGS = {
    "args": args,
    "server_model": server_model,
    "models": models,
    "client_weights": client_weights,
}
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 — 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
get_wasserstein Ran
ran on a synthesized input
microsoft/personalizedfl/alg/fedap.py
code served (permissive licence) · get_code("485a9696257a76b0")
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 float, 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
import math

# Create small numpy arrays for means and variances
# The function expects lists of arrays where it:
# 1. Computes squared differences between m1[i] and m2[i]
# 2. Computes squared differences between sqrt(v1[i]) and sqrt(v2[i])
# 3. Iterates over length of m1

# Create 2 batches of 4-dimensional data
batch_size = 2
dim = 4

m1 = [np.random.randn(dim) for _ in range(batch_size)]
v1 = [np.abs(np.random.randn(dim)) + 0.1 for _ in range(batch_size)]  # ensure positive for sqrt
m2 = [np.random.randn(dim) for _ in range(batch_size)]
v2 = [np.abs(np.random.randn(dim)) + 0.1 for _ in range(batch_size)]  # ensure positive for sqrt

mode = 'nosquare'

ARGS = {
    'm1': m1,
    'v1': v1,
    'm2': m2,
    'v2': v2,
    'mode': mode
}
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 float, 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
get_weight_matrix1 Ran
ran on a synthesized input
microsoft/personalizedfl/alg/fedap.py
code served (permissive licence) · get_code("5ad3d27e05d47a52")
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 float, shape (2, 2) 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
import math

class Args:
    def __init__(self):
        self.model_momentum = 0.7

# Create small batch normalization statistics for 2 clients
# Each client has batch norm mean and variance lists
bnmlist = [
    [np.random.randn(4), np.random.randn(3)],  # Client 0: 2 layers with dims 4 and 3
    [np.random.randn(4), np.random.randn(3)]   # Client 1: 2 layers with dims 4 and 3
]

bnvlist = [
    [np.abs(np.random.randn(4)) + 0.1, np.abs(np.random.randn(3)) + 0.1],  # Client 0 variances (positive)
    [np.abs(np.random.randn(4)) + 0.1, np.abs(np.random.randn(3)) + 0.1]   # Client 1 variances (positive)
]

client_weights = [0.5, 0.5]  # Equal weights for 2 clients

args = Args()

ARGS = {
    'args': args,
    'bnmlist': bnmlist,
    'bnvlist': bnvlist,
    'client_weights': client_weights
}
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 float, shape (2, 2) — shape (2, 2) 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
getfeadataloader Ran
ran on a synthesized input
microsoft/personalizedfl/datautil/prepare_data.py
code served (permissive licence) · get_code("a7b76be7899c4bfa")
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 2, 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
import numpy as np
from torchvision.datasets import ImageFolder
from torchvision.datasets.folder import default_loader
import tempfile
import os
from PIL import Image

# Create a temporary directory structure with fake images
temp_dir = tempfile.mkdtemp()
dataset_dir = os.path.join(temp_dir, 'test_dataset')
os.makedirs(dataset_dir, exist_ok=True)

# Create domain directories with class subdirectories
for domain in ['domain1', 'domain2']:
    domain_path = os.path.join(dataset_dir, domain)
    for class_id in ['class0', 'class1']:
        class_path = os.path.join(domain_path, class_id)
        os.makedirs(class_path, exist_ok=True)
        # Create 10 tiny fake images per class
        for i in range(10):
            img = Image.new('RGB', (32, 32), color=(73, 109, 137))
            img.save(os.path.join(class_path, f'img_{i}.jpg'))

# Create args object
class Args:
    def __init__(self):
        self.domains = ['domain1/', 'domain2/']
        self.dataset = 'test_dataset'
        self.root_dir = temp_dir + '/'
        self.datapercent = 0.4
        self.seed = 42
        self.batch = 2

ARGS = {
    'args': Args()
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
PIL, numpy, 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 2, 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
img_union Ran
ran on a synthesized input
microsoft/personalizedfl/datautil/prepare_data.py
code served (permissive licence) · get_code("4c58833df55e5fdc")
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 2, 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
import numpy as np
from torchvision.datasets import ImageFolder
from torchvision.datasets.folder import default_loader
import tempfile
import os
from PIL import Image

# Create a minimal temporary directory structure with fake images
temp_dir = tempfile.mkdtemp()
dataset_name = "test_dataset"
dataset_path = os.path.join(temp_dir, dataset_name)
os.makedirs(dataset_path, exist_ok=True)

# Create domain directories with image subdirectories
domains = ["domain1", "domain2"]
for domain in domains:
    domain_path = os.path.join(dataset_path, domain)
    for class_idx in range(2):
        class_path = os.path.join(domain_path, str(class_idx))
        os.makedirs(class_path, exist_ok=True)
        # Create 4 tiny fake images per class
        for img_idx in range(4):
            img = Image.new('RGB', (64, 64), color=(73, 109, 137))
            img.save(os.path.join(class_path, f"img_{img_idx}.jpg"))

# Create args object
class Args:
    def __init__(self):
        self.domains = domains
        self.dataset = dataset_name
        self.root_dir = temp_dir + "/"
        self.datapercent = 0.4
        self.seed = 42
        self.batch = 2

ARGS = {
    "args": Args()
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
PIL, numpy, 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 2, 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
record_class_distribution Ran
ran on a synthesized input
microsoft/personalizedfl/datautil/datasplit.py
code served (permissive licence) · get_code("f17fef1111fa1087")
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

# The function takes:
# 1. partitions: an iterable of index arrays/lists for different data partitions
# 2. targets: array-like of class labels

# Create sample targets (class labels)
targets = np.array([0, 1, 0, 1, 2, 0, 1, 2])

# Create partitions - list of index arrays that partition the targets
# Each partition contains indices into the targets array
partitions = [
    np.array([0, 1, 2, 3]),      # First partition: indices 0,1,2,3
    np.array([4, 5, 6, 7]),      # Second partition: indices 4,5,6,7
]

ARGS = {
    "partitions": partitions,
    "targets": targets,
}
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
define_val_dataset Not yet run
unverified (harvested, no recorded run)
microsoft/personalizedfl/datautil/datasplit.py
code served (permissive licence) · get_code("a839fc9a58cb6763")
How it ran

no invocation recorded.

get_algorithm_class Not yet run
unverified (harvested, no recorded run)
microsoft/personalizedfl/alg/algs.py
code served (permissive licence) · get_code("b0bc80b1655a6802")
How it ran

no invocation recorded.

get_data Not yet run
unverified (harvested, no recorded run)
microsoft/personalizedfl/datautil/prepare_data.py
code served (permissive licence) · get_code("407179ecda48fdf8")
How it ran

no invocation recorded.

get_form Not yet run
unverified (harvested, no recorded run)
microsoft/personalizedfl/alg/fedap.py
code served (permissive licence) · get_code("d16f8082ebd071a3")
How it ran

no invocation recorded.

Also present in other papers' code

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

FunctionAlso present inEarliest-datedOthers named
get_algorithm_class 39 other papers
19 dated earlier, 3 the same month, 17 later
1907.02893 (2019-07)
Invariant Risk Minimization
2007.01434 (2020-07)
In Search of Lost Domain Generalization
2007.02931 (2020-07)
Adaptive Risk Minimization: Learning to Adapt to Domain Shift
and 36 more not named here

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

Federated learning (FL) has emerged as a new paradigm for privacy-preserving computation in recent years. Unfortunately, FL faces two critical challenges that hinder its actual performance: data distribution heterogeneity and high resource costs brought by large foundation models. Specifically, the non-IID data in different clients make existing FL algorithms hard to converge while the high resource costs, including computational and communication costs that increase the deployment difficulty in real-world scenarios. In this paper, we propose an effective yet simple method, named FedCLIP, to achieve fast generalization and personalization for CLIP in federated learning. Concretely, we design an attention-based adapter for the large model, CLIP, and the rest operations merely depend on adapters. Lightweight adapters can make the most use of pretrained model information and ensure models be adaptive for clients in specific tasks. Simultaneously, small-scale operations can mitigate the computational burden and communication burden caused by large models. Extensive experiments are conducted on three datasets with distribution shifts. Qualitative and quantitative results demonstrate that FedCLIP significantly outperforms other baselines (9% overall improvements on PACS) and effectively reduces computational and communication costs (283x faster than FedAVG). Our code will be available at: https://github.com/microsoft/PersonalizedFL.

For agents

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

get_harvested_code_for_paper("2302.13485")
get_code_for_paper("2302.13485")
have("2302.13485")

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

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

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

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

Connect an agent — have() is free.