SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2402.14758 · ICML · 2024

Batch and match: black-box variational inference with a score-based divergence

Diana Cai, Chirag Modi, David Blei, Robert Gower, Loucas Pillaud-Vivien, Charles Margossian, Lawrence Saul

arXiv · PDF · Open in the Atlas

Code that ran

7 of 10 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; 1 honoured the contract we drafted, 0 violated it and 0 have no contract verdict; 6 failures of our instrument; 3 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/2402.14758.json · badge: /api/ran/2402.14758.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
modichirag/GSM-VI canonical (classifier label)
classifier basis: census
5 ran · 0 no recorded run
roualdes/bridgestan canonical (classifier label)
classifier basis: census
1 ran · 2 no recorded run
modichirag/gsm-vi canonical (classifier label)
classifier basis: classifier_2025
1 ran · 1 no recorded run
FunctionStatusWhere it lives
compute_Q_host Ran
ran, honoured the contract we drafted
modichirag/gsm-vi/gsmvi/bam.py
code served (permissive licence) · get_code("e4104749d59e0980")
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) and returned ndarray, ndim 2, dtype family float, shape (6, 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 scipy.sparse as spys

# Create a small sparse matrix U with distinct dimensions
# U should be a sparse matrix that can be passed to spys.linalg.svds
np.random.seed(0)
U_dense = np.random.randn(6, 4)  # 6x4 matrix
U = spys.csr_matrix(U_dense)

# B is the number of singular vectors to compute (k parameter for svds)
B = 2

ARGS = {
    "U_B": (U, B)
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1
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 2, dtype family float, shape (6, 2) — shape (6, 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
forward_kl Ran
ran; our contract draft was wrong, not the code
modichirag/GSM-VI/gsmvi/monitors.py
code served (permissive licence) · get_code("fd2c2158f3e92920")
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 float32, 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

# Create sample data
samples = np.random.randn(2, 4).astype(np.float32)

# Create log probability functions that take samples and return log probabilities
def lpq(x):
    # Mock log probability function for q (proposal)
    # Returns log probabilities for each sample
    return np.sum(x**2, axis=1)

def lpp(x):
    # Mock log probability function for p (target)
    # Returns log probabilities for each sample
    return np.sum(x, axis=1)

ARGS = {
    "samples": samples,
    "lpq": lpq,
    "lpp": lpp,
}
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 float32, 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
generate_so_name Ran
ran; our contract draft was wrong, not the code
roualdes/bridgestan/python/bridgestan/compile.py
code served (permissive licence) · get_code("de01b3676876a474")
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 PosixPath. 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.

from pathlib import Path

ARGS = {
    "model": Path("/tmp/test_model.pt")
}
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 PosixPath — a PosixPath output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a PosixPath 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
gsm_update Ran
ran; our contract draft was wrong, not the code
modichirag/GSM-VI/gsmvi/gsm.py
code served (permissive licence) · get_code("f44f72dc66d7deaa")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Sonnet 4.5, prompt python_fixture_v1) 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 random seed for reproducibility
np.random.seed(0)

# Define dimensions
B = 2  # batch size
D = 4  # dimension

# Create samples: BxD array
samples = jnp.array(np.random.randn(B, D).astype(np.float32))

# Create score functions vs: BxD array
vs = jnp.array(np.random.randn(B, D).astype(np.float32))

# Create current mean estimate mu0: D array
mu0 = jnp.array(np.random.randn(D).astype(np.float32))

# Create current covariance matrix estimate S0: DxD array
# Make it positive definite by using A^T A construction
A = np.random.randn(D, D).astype(np.float32)
S0 = jnp.array(np.dot(A.T, A) + 0.1 * np.eye(D))

ARGS = {
    'samples': samples,
    'vs': vs,
    'mu0': mu0,
    'S0': S0
}
Setup block drafted by
a language model, Claude Sonnet 4.5, prompt python_fixture_v1
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
gsm_update Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
modichirag/GSM-VI/gsmvi/gsm_numpy.py
code served (permissive licence) · get_code("6ddd611d572d26fd")
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

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

# Define dimensions
B = 2  # batch size
D = 4  # feature dimension

# Create sample arguments
samples = np.random.randn(B, D).astype(np.float64)
vs = np.random.randn(B, D).astype(np.float64)
mu0 = np.random.randn(D).astype(np.float64)
S0 = np.random.randn(D, D).astype(np.float64)
S0 = S0 @ S0.T  # Make it symmetric positive definite

ARGS = {
    "samples": samples,
    "vs": vs,
    "mu0": mu0,
    "S0": S0,
}
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
lbfgs_init Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
modichirag/GSM-VI/gsmvi/initializers.py
code served (permissive licence) · get_code("2f3a4b958db69b05")
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 scipy.optimize import minimize

torch.manual_seed(0)

# Create a simple log-probability function
def log_prob(x):
    """Simple quadratic log-probability: -0.5 * sum(x^2)"""
    return -0.5 * np.sum(x**2)

def log_prob_grad(x):
    """Gradient of the log-probability: -x"""
    return -x

# Initial point for optimization
x0 = np.array([1.0, 2.0, 0.5, -1.0])

ARGS = {
    'x0': x0,
    'lp': log_prob,
    'lp_g': log_prob_grad,
    'maxiter': 100,
    'maxfun': 100
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, scipy, 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
reverse_kl Ran
ran; our contract draft was wrong, not the code
modichirag/GSM-VI/gsmvi/monitors.py
code served (permissive licence) · get_code("7648c68a28ade9ce")
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 float32, 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

# samples is a numpy array that gets passed to lpq and lpp
# lpq and lpp are callable functions that take samples and return log probabilities
# The function sums the results, so they should return arrays of log probabilities

samples = np.random.randn(2, 4).astype(np.float32)

def lpq(samples):
    """Log probability of samples under proposal distribution q"""
    return np.sum(np.log(np.abs(samples) + 1e-6), axis=1)

def lpp(samples):
    """Log probability of samples under target distribution p"""
    return np.sum(np.log(np.abs(samples) + 1e-6), axis=1)

ARGS = {
    "samples": samples,
    "lpq": lpq,
    "lpp": lpp
}
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 float32, 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
compile_model Not yet run
unverified (harvested, no recorded run)
roualdes/bridgestan/python/bridgestan/compile.py
code served (permissive licence) · get_code("2886b3ba1cf892e9")
How it ran

no invocation recorded.

compute_Q Not yet run
unverified (harvested, no recorded run)
modichirag/gsm-vi/gsmvi/bam.py
code served (permissive licence) · get_code("9684d6283c9cb0f0")
How it ran

no invocation recorded.

get_bridgestan_path Not yet run
unverified (harvested, no recorded run)
roualdes/bridgestan/python/bridgestan/compile.py
code served (permissive licence) · get_code("9203180cea4cc0bf")
How it ran

no invocation recorded.

Also present in other papers' code

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

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

Most leading implementations of black-box variational inference (BBVI) are based on optimizing a stochastic evidence lower bound (ELBO). But such approaches to BBVI often converge slowly due to the high variance of their gradient estimates and their sensitivity to hyperparameters. In this work, we propose batch and match (BaM), an alternative approach to BBVI based on a score-based divergence. Notably, this score-based divergence can be optimized by a closed-form proximal update for Gaussian variational families with full covariance matrices. We analyze the convergence of BaM when the target distribution is Gaussian, and we prove that in the limit of infinite batch size the variational parameter updates converge exponentially quickly to the target mean and covariance. We also evaluate the performance of BaM on Gaussian and non-Gaussian target distributions that arise from posterior inference in hierarchical and deep generative models. In these experiments, we find that BaM typically converges in fewer (and sometimes significantly fewer) gradient evaluations than leading implementations of BBVI based on ELBO maximization. 1. Introduction. Probabilistic modeling plays a fundamental role in many problems of inference and decision-making, but it can be challenging to develop accurate probabilistic models that remain computationally tractable. In typical applications, the goal is to estimate a target distribution that cannot be evaluated or sampled from exactly, but where an unnormalized form is available. A canonical situation is applied Bayesian statistics, where the target is a posterior distribution of latent variables given observations, but where only the model's joint distribution is available in closed form. Variational inference (VI) has emerged as a leading method for fast approximate inference (Blei et al., 2017;Jordan et al., 1999;Wainwright et al., 2008). The idea behind VI is to posit a parameterized family of approximating distributions, and then to find the member of that family which is closest to the target distribution. Recently, VI methods have become increasingly "black box," in that they only require calculation of the log of the unnormalized target and (for some algorithms) its gradients (

For agents

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

get_harvested_code_for_paper("2402.14758")
get_code_for_paper("2402.14758")
have("2402.14758")

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

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

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

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

Connect an agent — have() is free.