SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2109.03867 · ICML · 2022

LSB: Local Self-Balancing MCMC in Discrete Spaces

Emanuele Sansone

arXiv · PDF · Open in the Atlas

Code that ran

10 of 11 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; 2 honoured the contract we drafted, 0 violated it and 3 have no contract verdict; 5 failures of our instrument; 1 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/2109.03867.json · badge: /api/ran/2109.03867.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
emsansone/LSB canonical (classifier label)
classifier basis: census
6 ran · 1 no recorded run
emsansone/lsb canonical (classifier label)
classifier basis: classifier_2025
4 ran · 0 no recorded run
FunctionStatusWhere it lives
LSB Ran
ran on a synthesized input · constructed an object; no result was computed
emsansone/lsb/RBM/self_sampler.py
code served (permissive licence) · get_code("4a7f2523bb87ec1d")
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, LSB: 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 torch.distributions as dists

torch.manual_seed(0)

# Create a simple stand-in model that the LSB class will use
class SimpleModel(nn.Module):
    def __init__(self):
        super().__init__()
        self.linear = nn.Linear(4, 1)
    
    def forward(self, x):
        # x shape: (batch, dim) or (batch, channels, width)
        if len(x.shape) == 3:
            b, c, w = x.shape
            x = x.view(b, -1)
        return self.linear(x)

# Create a simple difference function utility module
class utils:
    @staticmethod
    def difference_function(x, model):
        d = torch.zeros_like(x)
        orig_out = model(x).squeeze()
        for i in range(x.size(1)):
            x_pert = x.clone()
            x_pert[:, i] = 1.0 - x[:, i]
            delta = model(x_pert).squeeze() - orig_out
            d[:, i] = delta
        return d
    
    @staticmethod
    def approx_difference_function(x, model):
        x = x.requires_grad_()
        gx = torch.autograd.grad(model(x).sum(), x, create_graph=True)[0]
        wx = gx * -(2.0 * x - 1)
        return wx.detach()

# Create the model instance
model_instance = SimpleModel()

ARGS = {
    'dim': 4,
    'func': 'lsb1',
    'batch': 2,
    'n_steps': 2,
    'approx': False,
    'lr': 0.01,
    'model': model_instance,
    'hidden': 5,
    'burn_in': True,
    'device': None,
    'seed': 0,
}
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 LSB — 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 LSB 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
MLP Ran
ran on a synthesized input · constructed an object; no result was computed
emsansone/lsb/RBM/self_sampler.py
code served (permissive licence) · get_code("4d53f1f04cf6f2dd")
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, MLP: 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

torch.manual_seed(0)

ARGS = {
    "hidden": 8
}
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 MLP — 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 MLP 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
all_binary_choices Ran
ran, honoured the contract we drafted
emsansone/LSB/RBM/block_samplers.py
pointer only (licence: MIT); the stored copy get_code serves, from patrickpynadath1/automatic_cyclical_sampling, is pointer only (licence: NONE) · get_code("4b71b5539fbe3289")
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 patrickpynadath1/automatic_cyclical_sampling, 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.

approx_difference_function Ran
ran; our contract draft was wrong, not the code
emsansone/lsb/RBM/self_sampler.py
code served (permissive licence) · get_code("00335f85e82c7298")
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, 4) 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
import torch.nn as nn

torch.manual_seed(0)

# Build a minimal model that:
# - Takes a tensor x as input
# - Returns a tensor output that can be summed and differentiated
class SimpleModel(nn.Module):
    def __init__(self):
        super().__init__()
        self.linear = nn.Linear(4, 3)
    
    def forward(self, x):
        return self.linear(x)

# Create model instance
model = SimpleModel()

# Create input tensor: batch_size=2, feature_dim=4
x = torch.randn(2, 4, requires_grad=True)

ARGS = {
    "x": x,
    "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 Tensor, ndim 2, dtype family float, shape (2, 4) — shape (2, 4) 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
avg_hamming Ran
ran; our contract draft was wrong, not the code
emsansone/LSB/RBM/mmd.py
pointer only (licence: MIT); the stored copy get_code serves, from patrickpynadath1/automatic_cyclical_sampling, is pointer only (licence: NONE) · get_code("cf3a4e39e2d79a43")
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 patrickpynadath1/automatic_cyclical_sampling, 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.

difference_function Ran
ran; our contract draft was wrong, not the code
emsansone/lsb/RBM/self_sampler.py
code served (permissive licence) · get_code("b271a737c680bb32")
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, 4) 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
import torch.nn as nn

torch.manual_seed(0)

# Create a simple model that takes input and produces scalar output
class SimpleModel(nn.Module):
    def __init__(self, input_dim):
        super().__init__()
        self.linear = nn.Linear(input_dim, 1)
    
    def forward(self, x):
        return self.linear(x)

# Create a tiny input tensor: batch_size=2, feature_dim=4
x = torch.randn(2, 4)

# Create a simple model
model = SimpleModel(input_dim=4)

ARGS = {
    "x": x,
    "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 Tensor, ndim 2, dtype family float, shape (2, 4) — shape (2, 4) 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
effective_sample_size Ran
ran on a synthesized input
emsansone/LSB/2DIsing/ess.py
code served (permissive licence) · get_code("1df7cd9af94bdc93")
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 numpy as np

# The function takes a single parameter 'x' which should be a 2D numpy array
# with shape (n, d) where:
# - n is the number of samples
# - d is the number of dimensions/features
# The function accesses x[i, j] for all i in range(n) and j in range(1, d)
# and performs numerical operations on it

x = np.random.rand(2, 4).astype(np.float32)

ARGS = {
    "x": x
}
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 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
exp_avg_hamming Ran
ran; our contract draft was wrong, not the code
emsansone/LSB/RBM/mmd.py
pointer only (licence: MIT); the stored copy get_code serves, from patrickpynadath1/automatic_cyclical_sampling, is pointer only (licence: NONE) · get_code("dfc4c4bf9a645098")
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 patrickpynadath1/automatic_cyclical_sampling, 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.

hamming_ball Ran
ran, honoured the contract we drafted
emsansone/LSB/RBM/block_samplers.py
pointer only (licence: MIT); the stored copy get_code serves, from patrickpynadath1/automatic_cyclical_sampling, is pointer only (licence: NONE) · get_code("9d0191ea46d3b42e")
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 patrickpynadath1/automatic_cyclical_sampling, 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.

scaled_exp_avg_hamming Ran
ran; our contract draft was wrong, not the code
emsansone/LSB/RBM/mmd.py
pointer only (licence: MIT); the stored copy get_code serves, from patrickpynadath1/automatic_cyclical_sampling, is pointer only (licence: NONE) · get_code("d5d8e438b37db8df")
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 patrickpynadath1/automatic_cyclical_sampling, 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.

difference_function_multi_dim Not yet run
unverified (harvested, no recorded run)
emsansone/LSB/RBM/utils.py
code served (permissive licence) · get_code("671e4ba5363fbc01")
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, 7 are also present in other papers whose code we hold (0 with at least one paper dated earlier, 0 the same month, 7 later) and 4 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
all_binary_choices 1 other paper
1 later
2402.17699 (2024-02)
Gradient-based Discrete Sampling with Automatic Cyclical Scheduling
approx_difference_function
brick of this paper's assembly: helper
1 other paper
1 later · 1 only as an assembly brick
2206.09914 (2022-06)
A Langevin-like Sampler for Discrete Distributions
avg_hamming 1 other paper
1 later
2402.17699 (2024-02)
Gradient-based Discrete Sampling with Automatic Cyclical Scheduling
difference_function
brick of this paper's assembly: helper
1 other paper
1 later · 1 only as an assembly brick
2206.09914 (2022-06)
A Langevin-like Sampler for Discrete Distributions
exp_avg_hamming 1 other paper
1 later
2402.17699 (2024-02)
Gradient-based Discrete Sampling with Automatic Cyclical Scheduling
hamming_ball 1 other paper
1 later
2402.17699 (2024-02)
Gradient-based Discrete Sampling with Automatic Cyclical Scheduling
scaled_exp_avg_hamming 1 other paper
1 later
2402.17699 (2024-02)
Gradient-based Discrete Sampling with Automatic Cyclical Scheduling

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

We present the Local Self-Balancing sampler (LSB), a local Markov Chain Monte Carlo (MCMC) method for sampling in purely discrete domains, which is able to autonomously adapt to the target distribution and to reduce the number of target evaluations required to converge. LSB is based on (i) a parametrization of locally balanced proposals, (ii) a newly proposed objective function based on mutual information and (iii) a self-balancing learning procedure, which minimises the proposed objective to update the proposal parameters. Experiments on energy-based models and Markov networks show that LSB converges using a smaller number of queries to the oracle distribution compared to recent local MCMC samplers.

For agents

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

get_harvested_code_for_paper("2109.03867")
get_code_for_paper("2109.03867")
have("2109.03867")

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

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

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

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

Connect an agent — have() is free.