SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2306.05651 · ICML · 2023

Differentially Private Sharpness-Aware Training

Hoki Kim, Jinseong Park, Yujin Choi, Jaewook Lee

arXiv · PDF · Open in the Atlas

Code that ran

9 of 11 samples (functions and classes) lifted from this paper's linked repositories executed on a synthesized input in Syntology's jail (1 of them constructed an object rather than computing a result; 1 honoured the contract we drafted, 0 violated it and 7 have no contract verdict; 1 failure of our instrument; 2 no recorded run); 1 of them was also run on the host, not in the jail, by the peer-agreement lane that set its level, measured 2026-11-24; 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/2306.05651.json · badge: /api/ran/2306.05651.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
TheSunWillRise/DPNAS canonical (classifier label)
classifier basis: census
8 ran · 2 no recorded run
jinseongp/dpsat canonical (classifier label)
classifier basis: classifier_2025
1 ran · 0 no recorded run
FunctionStatusWhere it lives
get_num_params Ran
ran, honoured the contract we drafted
TheSunWillRise/DPNAS/dp_evaluate/models.py
pointer only (licence: MIT); the stored copy get_code serves, from fortuinlab/spam-pruning, is pointer only (licence: NONE) · get_code("b81882decca625ee")
How it ran

The body of this sample is withheld: this paper's link allows the body inline (MIT), but get_code serves the stored copy, first harvested from fortuinlab/spam-pruning, and GitHub detected no licence in that repository 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.

DPSAT Ran
ran on a synthesized input · constructed an object; no result was computed
jinseongp/dpsat/src/optim/minimizer.py
code served (permissive licence) · get_code("f0eda3d04ebbaf0b")
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, DPSAT: 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 collections import defaultdict

torch.manual_seed(0)

# Create a simple model
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()

# Create a wrapper optimizer that has pre_step() method and original_optimizer attribute
class CustomOptimizer:
    def __init__(self, base_optimizer):
        self.original_optimizer = base_optimizer
        self.step_count = 0
    
    def pre_step(self):
        self.step_count += 1
        return True
    
    def zero_grad(self):
        self.original_optimizer.zero_grad()

# Create base optimizer and wrap it
base_optimizer = torch.optim.SGD(model.parameters(), lr=0.01)
optimizer = CustomOptimizer(base_optimizer)

# Initialize model parameters with gradients for testing
for param in model.parameters():
    param.grad = torch.randn_like(param)

ARGS = {
    'optimizer': optimizer,
    'model': model,
    'rho': 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 DPSAT — 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 DPSAT 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
GN Ran
ran on a synthesized input
TheSunWillRise/DPNAS/dp_evaluate/models.py
code served (permissive licence) · get_code("5133e2a3b3e11e2f")
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 GroupNorm. 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)

# The function GN takes a single parameter 'plane' which is used as:
# - First argument to nn.GroupNorm: num_groups (should be divisor of plane)
# - Second argument to nn.GroupNorm: num_channels (the plane value itself)
# Since num_groups=8, plane must be divisible by 8

plane = 16  # A value divisible by 8, allowing GroupNorm(8, 16) to work

ARGS = {
    "plane": plane
}
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 GroupNorm — a GroupNorm output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a GroupNorm 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
GN Ran
ran on a synthesized input
TheSunWillRise/DPNAS/dp_search/operations.py
code served (permissive licence) · get_code("2858772fbc33adfd")
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 GroupNorm. 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)

# The GN function takes a single parameter 'plane' which represents
# the number of channels/planes for GroupNorm
# GroupNorm(4, plane, affine=False) creates a group norm with 4 groups
# and 'plane' channels, so 'plane' must be divisible by 4

plane = 8

ARGS = {
    "plane": plane
}
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 GroupNorm — a GroupNorm output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a GroupNorm 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
accuracy Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
TheSunWillRise/DPNAS/dp_search/utils.py
code served (permissive licence) · get_code("e93d9ddbfeb73ced")
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 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)

# Create small tensors for the accuracy function
batch_size = 2
num_classes = 4

# output: logits/scores from model, shape (batch_size, num_classes)
output = torch.randn(batch_size, num_classes)

# target: ground truth labels, shape (batch_size,)
target = torch.tensor([0, 2])

# topk: tuple of k values to compute accuracy for
topk = (1, 2)

ARGS = {
    "output": output,
    "target": target,
    "topk": topk
}
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 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
get_data Ran
ran on a synthesized input
TheSunWillRise/DPNAS/dp_evaluate/data.py
code served (permissive licence) · get_code("e885a1ad06793510")
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 numpy as np
from torchvision import datasets, transforms
from unittest.mock import Mock, patch
import tempfile
import os

torch.manual_seed(0)

# Mock the dataset classes to avoid downloading
class MockCIFAR10:
    def __init__(self, root, train, transform, download=False):
        self.root = root
        self.train = train
        self.transform = transform
        self.data = np.random.randint(0, 256, (10, 32, 32, 3), dtype=np.uint8)
        self.targets = [i % 10 for i in range(10)]
    
    def __len__(self):
        return len(self.data)
    
    def __getitem__(self, idx):
        img = self.data[idx]
        if self.transform:
            from PIL import Image
            img = Image.fromarray(img)
            img = self.transform(img)
        return img, self.targets[idx]

class MockFashionMNIST:
    def __init__(self, root, train, transform, download=False):
        self.root = root
        self.train = train
        self.transform = transform
        self.data = torch.randint(0, 256, (10, 28, 28), dtype=torch.uint8)
        self.targets = [i % 10 for i in range(10)]
    
    def __len__(self):
        return len(self.data)
    
    def __getitem__(self, idx):
        img = self.data[idx]
        if self.transform:
            from PIL import Image
            img = Image.fromarray(img.numpy())
            img = self.transform(img)
        return img, self.targets[idx]

class MockMNIST:
    def __init__(self, root, train, transform, download=False):
        self.root = root
        self.train = train
        self.transform = transform
        self.data = torch.randint(0, 256, (10, 28, 28), dtype=torch.uint8)
        self.targets = [i % 10 for i in range(10)]
    
    def __len__(self):
        return len(self.data)
    
    def __getitem__(self, idx):
        img = self.data[idx]
        if self.transform:
            from PIL import Image
            img = Image.fromarray(img.numpy())
            img = self.transform(img)
        return img, self.targets[idx]

# Patch the datasets module
original_cifar10 = datasets.CIFAR10
original_fmnist = datasets.FashionMNIST
original_mnist = datasets.MNIST

datasets.CIFAR10 = MockCIFAR10
datasets.FashionMNIST = MockFashionMNIST
datasets.MNIST = MockMNIST

ARGS = {
    'name': 'cifar10',
    'augment': False
}
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 — 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
random_sample_loader Ran
ran on a synthesized input
TheSunWillRise/DPNAS/dp_evaluate/data.py
code served (permissive licence) · get_code("fc98656f39d43732")
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 DataLoader. 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 numpy as np

torch.manual_seed(0)
np.random.seed(0)

# Create a simple dataset
num_samples = 8
data_dim = 4
num_classes = 3

data_samples = torch.randn(num_samples, data_dim)
targets_samples = torch.randint(0, num_classes, (num_samples,))

dataset = torch.utils.data.TensorDataset(data_samples, targets_samples)
batch_size = 2

# Create a data loader with RandomSampler
loader = torch.utils.data.DataLoader(
    dataset,
    batch_size=batch_size,
    sampler=torch.utils.data.RandomSampler(dataset),
    num_workers=0
)

device = 'cpu'

ARGS = {
    'loader': loader,
    'device': device,
    'drop_last': False,
    'sample_batches': False
}
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 DataLoader — a DataLoader output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a DataLoader 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
subjectiwise_accuracy Ran
ran on a synthesized input
TheSunWillRise/DPNAS/dp_search/utils.py
code served (permissive licence) · get_code("4bfe7d10338dc3c4")
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
import itertools

def subjectiwise_accuracy(output, target, pid):
    res = {}
    r = zip(output, target, pid)
    for key, value in itertools.groupby(r, key=lambda x: x[-1]):
        tokens = key.split('_')
        organ = tokens[0]
        patentID = tokens[1]
        prob = [p[l] for p, l, id in value]
        max_p = max(prob)
        min_p = min(prob)
        mean_p = sum(prob) / len(prob)
        if organ in res:
            res[organ].append([float(max_p >= 0.5), float(min_p >= 0.5), float(mean_p >= 0.5)])
        else:
            res[organ] = [[float(max_p >= 0.5), float(min_p >= 0.5), float(mean_p >= 0.5)]]
    result = {}
    all = np.zeros((3,))
    n = 0
    for k, v in res.items():
        v = np.array(v)
        s = np.sum(v, axis=0)
        m = np.mean(v, axis=0)
        result[k] = list(m)
        all += s
        n += len(v)
    all_mean = all / n
    result['all'] = list(all_mean)
    return result


# Build test data
output = [np.array([0.2, 0.3, 0.7, 0.9]), 
          np.array([0.1, 0.6, 0.8, 0.4]),
          np.array([0.3, 0.4, 0.5, 0.6]),
          np.array([0.9, 0.8, 0.2, 0.1])]

target = [0, 1, 2, 0]

pid = ['heart_001', 'heart_001', 'liver_002', 'liver_002']

ARGS = {
    'output': output,
    'target': target,
    'pid': pid
}
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
test Ran
ran on a synthesized input
TheSunWillRise/DPNAS/dp_evaluate/train_utils.py
code served (permissive licence) · get_code("bd31d8cae37a3810")
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)

# Build a minimal model that satisfies the function's usage
class SimpleClassifier(nn.Module):
    def __init__(self, input_dim=4, num_classes=3):
        super().__init__()
        self.fc = nn.Linear(input_dim, num_classes)
    
    def forward(self, x):
        return self.fc(x)

# Create model on CPU
model = SimpleClassifier(input_dim=4, num_classes=3)
model = model.to('cpu')

# Create test_loader as a list of (data, target) tuples
# Batch size 2, input dim 4, 3 classes
test_loader = [
    (torch.randn(2, 4), torch.tensor([0, 1])),
    (torch.randn(2, 4), torch.tensor([2, 0])),
]

ARGS = {
    'model': model,
    'test_loader': test_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
imagewise_accuracy Not yet run
unverified (harvested, no recorded run)
TheSunWillRise/DPNAS/dp_search/utils.py
code served (permissive licence) · get_code("6d9077445a734b41")
How it ran

no invocation recorded.

train Not yet run
unverified (harvested, no recorded run)
TheSunWillRise/DPNAS/dp_evaluate/train_utils.py
code served (permissive licence) · get_code("d655d781dc686594")
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, 2 are also present in other papers whose code we hold (1 with at least one paper dated earlier, 0 the same month, 2 later) and 9 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
accuracy 7 other papers
3 dated earlier, 3 later, 1 same year, order not determinable
1806.09055 (2018-06)
DARTS: Differentiable Architecture Search
2103.15798 (2021-03)
Rethinking Neural Operations for Diverse Tasks
2109.03508 (2021-09)
RepNAS: Searching for Efficient Re-parameterizing Blocks
and 4 more not named here
get_num_params 2 other papers
2 later
2402.10211 (2024-02)
Hierarchical State Space Models for Continuous Sequence-to-Sequence Modeling
2402.15978 (2024-02)
Shaving Weights with Occam's Razor: Bayesian Sparsification for Neural Networks using the Marginal Likelihood

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

Repositories linked to this paper

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

Abstract

Training deep learning models with differential privacy (DP) results in a degradation of performance. The training dynamics of models with DP show a significant difference from standard training, whereas understanding the geometric properties of private learning remains largely unexplored. In this paper, we investigate sharpness, a key factor in achieving better generalization, in private learning. We show that flat minima can help reduce the negative effects of per-example gradient clipping and the addition of Gaussian noise. We then verify the effectiveness of Sharpness-Aware Minimization (SAM) for seeking flat minima in private learning. However, we also discover that SAM is detrimental to the privacy budget and computational time due to its two-step optimization. Thus, we propose a new sharpness-aware training method that mitigates the privacy-optimization trade-off. Our experimental results demonstrate that the proposed method improves the performance of deep learning models with DP from both scratch and finetuning. Code is available at https://github. com/jinseongP/DPSAT.

For agents

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

get_harvested_code_for_paper("2306.05651")
get_code_for_paper("2306.05651")
have("2306.05651")

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

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

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

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

Connect an agent — have() is free.