SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2111.02458 · 2021

Perturb-and-max-product: Sampling and learning in discrete energy-based models

arXiv · PDF · Open in the Atlas

Code that ran

7 of 7 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; 0 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/2111.02458.json · badge: /api/ran/2111.02458.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
vicariousinc/perturb_and_max_product canonical (classifier label)
classifier basis not recorded on the link
7 ran · 0 no recorded run
FunctionStatusWhere it lives
c2d_latt_mask Ran
ran on a synthesized input
vicariousinc/perturb_and_max_product/experiments/generate_erdos_and_lattice.py
code served (permissive licence) · get_code("2936452754433fcd")
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 (16, 16) 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

def c2d_latt_mask(side):
    grid = np.arange(side ** 2).reshape(side, side)
    mask = np.zeros((side ** 2, side ** 2))
    mask[grid[:-1], grid[1:]] = 1
    mask[grid[-1], grid[0]] = 1
    mask[grid[:, :-1], grid[:, 1:]] = 1
    mask[grid[:, -1], grid[:, 0]] = 1
    mask = mask + mask.T
    return mask

ARGS = {
    "side": 4
}
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 (16, 16) — shape (16, 16) 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
contour_mnist Ran
ran on a synthesized input
vicariousinc/perturb_and_max_product/experiments/generate_mnist_and_contour_mnist.py
code served (permissive licence) · get_code("3d522d6b60f4a4d7")
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 3, dtype family int, shape (2, 30, 30) 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

# The function takes X as input, which should be a numpy array
# Looking at the function:
# - X is compared with 0.5 (thresholding)
# - X is converted to int
# - binary_dilation is applied (works on 3D arrays based on the structure element)
# - The structure element s is 3D (3x3x3)
# - X is indexed and manipulated
# - contour_X is created with shape (X.shape[0], 30, 30)
# This suggests X should be a 3D array with shape (batch, height, width)

# Create a small test input: batch_size=2, height=28, width=28 (typical MNIST size)
X = np.random.rand(2, 28, 28)

ARGS = {
    "X": X
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, scipy — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type ndarray, ndim 3, dtype family int, shape (2, 30, 30) — shape (2, 30, 30) 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
grad Ran
ran on a synthesized input
vicariousinc/perturb_and_max_product/pmap/rbm_modeling.py
code served (permissive licence) · get_code("ba817fe401de23e8")
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 jax
import jax.numpy as jnp
from jax import random

# Set seed for reproducibility
key = random.PRNGKey(42)

# Define small dimensions for the RBM
n_hidden = 3
n_visible = 4
n_samples = 2

# Create small weight matrix W: (n_hidden, n_visible)
W = jnp.ones((n_hidden, n_visible)) * 0.1

# Create bias for visible units: (1, n_visible)
bv = jnp.ones((1, n_visible)) * 0.05

# Create bias for hidden units: (1, n_hidden)
bh = jnp.ones((1, n_hidden)) * 0.02

# Create small data matrix X: (n_samples, n_visible)
X = jnp.array([[0.5, 0.2, 0.8, 0.3],
               [0.1, 0.9, 0.4, 0.6]], dtype=jnp.float32)

# Number of Gibbs/min_energy sampling steps
n_steps = 2

# Sampling algorithm choice
sampling_alg = 'gibbs'

# RNG key
rng = random.PRNGKey(123)

# Optional initial sample S (None means it will be initialized)
S = None

ARGS = {
    'W': W,
    'bv': bv,
    'bh': bh,
    'X': X,
    'n_steps': n_steps,
    'sampling_alg': sampling_alg,
    'rng': rng,
    'S': S,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
jax — 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
grad_from_samples Ran
ran on a synthesized input
vicariousinc/perturb_and_max_product/pmap/rbm_modeling.py
code served (permissive licence) · get_code("c613e60795684456")
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 jax.numpy as jnp
import numpy as np

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

# Define tiny tensors matching the function's operations
# X: (n_samples, feature_dim) - shape (2, 4)
X = jnp.array(np.random.randn(2, 4).astype(np.float32))

# W: (hidden_dim, feature_dim) - shape (3, 4)
# Used in: X @ W.T, so W.T is (4, 3), resulting in (2, 3)
W = jnp.array(np.random.randn(3, 4).astype(np.float32))

# bh: (hidden_dim,) - shape (3,)
# Used in: X @ W.T + bh, broadcasts to (2, 3)
bh = jnp.array(np.random.randn(3).astype(np.float32))

ARGS = {
    "W": W,
    "bh": bh,
    "X": X,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
jax, numpy — 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
mean_corr Ran
ran on a synthesized input
vicariousinc/perturb_and_max_product/pmap/ising_modeling.py
code served (permissive licence) · get_code("f03099160b305294")
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 jax.numpy as jnp

# Create a small sample matrix S with shape (batch=2, dim=4)
S = jnp.array([
    [1.0, 2.0, 3.0, 4.0],
    [5.0, 6.0, 7.0, 8.0]
], dtype=jnp.float32)

ARGS = {
    "S": S
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
jax — 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
np_mean_corr Ran
ran on a synthesized input
vicariousinc/perturb_and_max_product/pmap/ising_modeling_lp.py
code served (permissive licence) · get_code("2084d897d09fc639")
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 numpy as np

# Construct a valid argument for np_mean_corr
# The function expects S to be a 2D numpy array where:
# - S.shape[0] is the batch/sample dimension
# - S.shape[1] is the feature dimension
# The function computes mean and correlation matrix

S = np.random.randn(2, 4)  # batch_size=2, n_features=4

ARGS = {
    'S': S
}
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 — 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
or_layer Ran
ran on a synthesized input
vicariousinc/perturb_and_max_product/pmap/conv_or_modeling.py
code served (permissive licence) · get_code("364aaefad0d757b2")
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 ArrayImpl, ndim 4, dtype family float, shape (2, 2, 6, 7) 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 jax.numpy as jnp

# Construct valid arguments for or_layer function
# Signature: or_layer(S, W)
# S: (n_samples, n_feat, s_height, s_width)
# W: (n_chan, n_feat, feat_height, feat_width)

n_samples = 2
n_feat = 3
s_height = 4
s_width = 5
n_chan = 2
feat_height = 3
feat_width = 3

# S: input tensor with shape (n_samples, n_feat, s_height, s_width)
S = jnp.ones((n_samples, n_feat, s_height, s_width), dtype=jnp.float32)

# W: weight tensor with shape (n_chan, n_feat, feat_height, feat_width)
W = jnp.ones((n_chan, n_feat, feat_height, feat_width), dtype=jnp.float32) * 0.5

ARGS = {
    "S": S,
    "W": W,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
jax — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type ArrayImpl, ndim 4, dtype family float, shape (2, 2, 6, 7) — shape (2, 2, 6, 7) 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

Also present in other papers' code

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

Perturb-and-MAP offers an elegant approach to approximately sample from a energy-based model (EBM) by computing the maximum-a-posteriori (MAP) configuration of a perturbed version of the model. Sampling in turn enables learning. However, this line of research has been hindered by the general intractability of the MAP computation. Very few works venture outside tractable models, and when they do, they use linear programming approaches, which as we will show, have several limitations. In this work we present perturb-and-max-product (PMP), a parallel and scalable mechanism for sampling and learning in discrete EBMs. Models can be arbitrary as long as they are built using tractable factors. We show that (a) for Ising models, PMP is orders of magnitude faster than Gibbs and Gibbs-with-Gradients (GWG) at learning and generating samples of similar or better quality; (b) PMP is able to learn and sample from RBMs; (c) in a large, entangled graphical model in which Gibbs and GWG fail to mix, PMP succeeds.

For agents

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

get_harvested_code_for_paper("2111.02458")
get_code_for_paper("2111.02458")
have("2111.02458")

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

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

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

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

Connect an agent — have() is free.