SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2406.03682 · ICML · 2024

A Universal Class of Sharpness-Aware Minimization Algorithms

Dara Bahri, Patrick Jaillet, Stefanie Jegelka, Behrooz Tahmasebi, Ashkan Soleymani

arXiv · PDF · Open in the Atlas

Code that ran

5 of 6 samples (functions and classes) lifted from this paper's linked repositories executed on a synthesized input in Syntology's jail (2 of them constructed an object rather than computing a result; 0 honoured the contract we drafted, 1 violated it and 2 have no contract verdict; 2 failures of our instrument; 1 no recorded run), measured 2026-11-23; 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/2406.03682.json · badge: /api/ran/2406.03682.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
dbahri/universal_sam canonical (classifier label)
classifier basis: classifier_2025
5 ran · 1 no recorded run
FunctionStatusWhere it lives
FROSAM Ran
ran on a synthesized input · constructed an object; no result was computed
dbahri/universal_sam/solver/sam.py
code served (permissive licence) · get_code("9f74929ef23622be")
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, FROSAM: 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 argparse

torch.manual_seed(0)

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

model = SimpleModel()

# Create a base optimizer (SGD)
base_optimizer = torch.optim.SGD(model.parameters(), lr=0.01)

# Define ARGS dictionary with all required parameters
ARGS = {
    'params': model.parameters(),
    'base_optimizer': base_optimizer,
    'rho': 0.05,
    'n_samples': 5,
    'lam': 0.1
}
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 FROSAM — 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 FROSAM 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
Registry Ran
ran on a synthesized input · constructed an object; no result was computed
dbahri/universal_sam/solver/sam.py
code served (permissive licence) · get_code("b5c45c26158cac1e")
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, Registry: 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

torch.manual_seed(0)

# Create a Registry instance with a name
ARGS = {
    "name": "test_registry"
}
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 Registry — 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 Registry 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
_called_with_args Ran
ran, violated the contract we drafted
dbahri/universal_sam/solver/sam.py
code served (permissive licence) · get_code("be3e23f766be2625")
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 bool, 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 argparse
import torch
import numpy as np

torch.manual_seed(0)

# Create a minimal argparse.Namespace object
namespace = argparse.Namespace(param1="value1", param2=42)

# The function _called_with_args accepts *args and **kwargs
# We need to construct valid arguments for it

ARGS = {
    'args': (namespace,),  # positional argument as a tuple
    'kwargs': {}  # keyword arguments as a dict
}
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 bool, 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_args_from_config Ran
ran; our contract draft was wrong, not the code
dbahri/universal_sam/solver/sam.py
code served (permissive licence) · get_code("71fb39740e62a991")
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 inspect

def sample_from_config(args, extra_param=None, **kwargs):
    """A sample from_config function that takes 'args' as first parameter"""
    return {
        'param1': 'value1',
        'param2': 42
    }

def sample_from_config_with_varargs(args, *more_args, **kwargs):
    """A sample from_config function with VAR_POSITIONAL support"""
    return {
        'result': 'computed',
        'extra': len(more_args)
    }

# Test case 1: Basic function with 'args' and keyword arguments
ARGS = {
    'from_config_func': sample_from_config,
    'args': ('config_value',),
    'kwargs': {'extra_param': 'test', 'other_key': 'other_value'}
}
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 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
_sample_gaussian Ran
ran; our contract draft was wrong, not the code
dbahri/universal_sam/solver/sam.py
code served (permissive licence) · get_code("21d027bd501c4c4f")
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

torch.manual_seed(0)

# The function takes:
# 1. shapes: an iterable of tensor shapes (tuples)
# 2. device: a torch device object

ARGS = {
    "shapes": [(2, 4), (3, 5), (2,)],
    "device": torch.device("cpu"),
}
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
configurable Not yet run
unverified (harvested, no recorded run)
dbahri/universal_sam/solver/sam.py
code served (permissive licence) · get_code("c8391702d5318ce9")
How it ran

no invocation recorded.

Also present in other papers' code

Of 6 samples lifted from this paper's linked repositories, 6 carry a function identity and 0 do not. Of the 6 distinct functions with an identity, 4 are also present in other papers whose code we hold (4 with at least one paper dated earlier, 0 the same month, 0 later) and 2 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
configurable
brick of this paper's assembly: helper
2 other papers
2 dated earlier
2210.05177 (2022-10)
Make Sharpness-Aware Minimization Stronger: A Sparsified Perturbation Approach
2309.15639 (2023-09)
Enhancing Sharpness-Aware Optimization Through Variance Suppression
Registry
brick of this paper's assembly: helper
1 other paper
1 dated earlier · 1 only as an assembly brick
2210.05177 (2022-10)
Make Sharpness-Aware Minimization Stronger: A Sparsified Perturbation Approach
_called_with_args
brick of this paper's assembly: helper
1 other paper
1 dated earlier · 1 only as an assembly brick
2210.05177 (2022-10)
Make Sharpness-Aware Minimization Stronger: A Sparsified Perturbation Approach
_get_args_from_config
brick of this paper's assembly: helper
1 other paper
1 dated earlier · 1 only as an assembly brick
2210.05177 (2022-10)
Make Sharpness-Aware Minimization Stronger: A Sparsified Perturbation Approach

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

Recently, there has been a surge in interest in developing optimization algorithms for overparameterized models as achieving generalization is believed to require algorithms with suitable biases. This interest centers on minimizing sharpness of the original loss function; the Sharpness-Aware Minimization (SAM) algorithm has proven effective. However, most literature only considers a few sharpness measures, such as the maximum eigenvalue or trace of the training loss Hessian, which may not yield meaningful insights for non-convex optimization scenarios like neural networks. Additionally, many sharpness measures are sensitive to parameter invariances in neural networks, magnifying significantly under rescaling parameters. Motivated by these challenges, we introduce a new class of sharpness measures in this paper, leading to new sharpness-aware objective functions. We prove that these measures are universally expressive, allowing any function of the training loss Hessian matrix to be represented by appropriate hyperparameters. Furthermore, we show that the proposed objective functions explicitly bias towards minimizing their corresponding sharpness measures, and how they allow meaningful applications to models with parameter invariances (such as scale-invariances). Finally, as instances of our proposed general framework, we present Frob-SAM and Det-SAM, which are specifically designed to minimize the Frobenius norm and the determinant of the Hessian of the training loss, respectively. We also demonstrate the advantages of our general framework through extensive experiments.

For agents

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

get_harvested_code_for_paper("2406.03682")
get_code_for_paper("2406.03682")
have("2406.03682")

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

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

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

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

Connect an agent — have() is free.