SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2205.12934 · NeurIPS · 2022

Amortized Inference for Causal Structure Learning

Bernhard Schölkopf, Jonas Rothfuss, Andreas Krause, Lars Lorch, Scott Sussex

arXiv · PDF · Open in the Atlas

Code that ran

10 of 10 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; 3 honoured the contract we drafted, 0 violated it and 1 has no contract verdict; 6 failures of our instrument; 0 no recorded run), measured 2026-11-22; 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/2205.12934.json · badge: /api/ran/2205.12934.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
larslorch/avici canonical (classifier label)
classifier basis: classifier_2025
10 ran · 0 no recorded run
FunctionStatusWhere it lives
InferenceModel Ran
ran on a synthesized input · constructed an object; no result was computed
larslorch/avici/avici/model.py
code served (permissive licence) · get_code("0e130cba73756b6d")
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, InferenceModel: 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 jax
import jax.numpy as jnp
import jax.random as random
import haiku as hk


class SimpleModel(hk.Module):
    """Minimal model that outputs logits matching the expected shape."""
    
    def __init__(self, name=None):
        super().__init__(name=name)
    
    def __call__(self, rng, x, is_training, experimental_chunk_size=None):
        # x shape: [..., N, d, 2]
        # We need to output logits of shape [..., d, d]
        batch_shape = x.shape[:-3]
        n = x.shape[-3]
        d = x.shape[-2]
        
        # Flatten and process
        x_flat = jnp.reshape(x, (-1, n, d, 2))
        logits = hk.Linear(d * d)(x_flat[0, 0, :, :].flatten())
        logits = jnp.reshape(logits, (d, d))
        
        # Replicate for batch dimensions if needed
        for _ in batch_shape:
            logits = jnp.expand_dims(logits, 0)
        
        return logits


def simple_model_fn(rng, x, is_training, experimental_chunk_size=None):
    """Haiku-compatible function that applies SimpleModel."""
    model = SimpleModel()
    return model(rng, x, is_training, experimental_chunk_size=experimental_chunk_size)


# Create transformed network
net = hk.transform(simple_model_fn)

# Initialize with dummy data
key = random.PRNGKey(0)
batch_size = 2
n_obs = 3
d = 4
x_dummy = jnp.ones((batch_size, n_obs, d, 2))
params = net.init(key, key, x_dummy, False)

ARGS = {
    'model_class': SimpleModel,
    'model_kwargs': {},
    'train_p_obs_only': 0.0,
    'acyclicity': None,
    'acyclicity_pow_iters': 10,
    'mask_diag': True,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
haiku, jax — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type InferenceModel — 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 InferenceModel 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
_jax_cpm_shift_scale Ran
ran, honoured the contract we drafted
larslorch/avici/avici/model.py
code served (permissive licence) · get_code("776f8b0d66bb5b01")
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 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 jax.numpy as jnp
import numpy as np

# Create small test arrays for the function parameters
x = jnp.array([[1.0, 2.0, 3.0, 4.0],
               [5.0, 6.0, 7.0, 8.0]])

shift = jnp.array([[0.5, 1.0, 1.5, 2.0],
                   [2.5, 3.0, 3.5, 4.0]])

scale = jnp.array([[1.0, 2.0, 1.0, 2.0],
                   [1.0, 2.0, 1.0, 2.0]])

ARGS = {
    "x": x,
    "shift": shift,
    "scale": scale
}
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 ArrayImpl, 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
_jax_cpm_standardizer Ran
ran, honoured the contract we drafted
larslorch/avici/avici/model.py
code served (permissive licence) · get_code("a8e2ecc798861c78")
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 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 jax.numpy as jnp

# The function takes a single parameter x, which should be a JAX array
# The function computes log2(CPM) normalization on the input
# x should be a 2D array where the last dimension is summed for library size normalization

x = jnp.array([
    [0.0, 1.0, 2.0, 3.0],
    [4.0, 5.0, 0.0, 6.0]
], dtype=jnp.float32)

ARGS = {
    "x": x
}
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 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
_jax_standardize_count Ran
ran; our contract draft was wrong, not the code
larslorch/avici/avici/model.py
code served (permissive licence) · get_code("e37be173faa6071d")
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 4, 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 jax.numpy as jnp
import numpy as np

# Create small sample tensors for x_obs and x_int
# Shape: (batch=2, features=4, channels=1) where channel 0 will be processed
batch_size = 2
n_features = 4
n_channels = 1

# Create x_obs with small positive values (counts data)
x_obs_data = np.array([
    [[1.0], [2.0], [3.0], [4.0]],
    [[5.0], [6.0], [7.0], [8.0]]
], dtype=np.float32)
x_obs = jnp.array(x_obs_data)

# Create x_int with small positive values (counts data)
x_int_data = np.array([
    [[2.0], [3.0], [4.0], [5.0]],
    [[6.0], [7.0], [8.0], [9.0]]
], dtype=np.float32)
x_int = jnp.array(x_int_data)

ARGS = {
    "x_obs": x_obs,
    "x_int": x_int,
}
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, ndim 4, 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
_jax_standardize_default Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
larslorch/avici/avici/model.py
code served (permissive licence) · get_code("c5b2c0fcb84df84f")
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 tuple, ndim 4, 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 jax.numpy as jnp

# Create small test tensors for x_obs and x_int
# The function expects arrays with shape (..., last_dim) where last dimension has at least 1 element
# x_obs[..., 0] and x_int[..., 0] are accessed, so last dimension must be >= 1
# Let's create tensors with shape (2, 4, 1) - batch=2, features=4, channels=1

x_obs = jnp.ones((2, 4, 1))
x_int = jnp.ones((2, 4, 1)) * 2.0

ARGS = {
    "x_obs": x_obs,
    "x_int": x_int,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1
Imports
jax — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type tuple, ndim 4, 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
jax_get_train_x Ran
ran; our contract draft was wrong, not the code
larslorch/avici/avici/model.py
code served (permissive licence) · get_code("f014427d8a9afcdb")
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, 3, 4, 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 jax.numpy as jnp
import jax.random as random

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

# Create tiny batch data
batch_size = 2
n_obs_and_int = 3
n_int = 1
n_features = 4
feature_dim = 2

# x_obs shape: (batch_size, n_obs_and_int, n_features, feature_dim)
x_obs = jnp.ones((batch_size, n_obs_and_int, n_features, feature_dim))

# x_int shape: (batch_size, n_int, n_features, feature_dim)
x_int = jnp.ones((batch_size, n_int, n_features, feature_dim))

# is_count_data shape: (batch_size,)
is_count_data = jnp.array([True, False])

batch = {
    'x_obs': x_obs,
    'x_int': x_int,
    'is_count_data': is_count_data
}

p_obs_only = 0.5

ARGS = {
    'key': key,
    'batch': batch,
    'p_obs_only': p_obs_only
}
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, 3, 4, 2) — shape (2, 3, 4, 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
jax_get_x Ran
ran, honoured the contract we drafted
larslorch/avici/avici/model.py
code served (permissive licence) · get_code("d20f8e1765623650")
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, 3, 4, 1) 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 a minimal batch dict for jax_get_x
# The function expects:
# - batch['x_obs']: observations array
# - batch['x_int']: interventions array
# - batch['is_count_data']: boolean flag for count data

# Shape requirements from the code:
# - x_obs and x_int must have shape [..., N, M, 1] or [..., N, M, 2]
#   where the last dimension is 1 or 2
# - is_count_data should be broadcastable to the batch dimensions

# Create tiny tensors with distinct dimensions
batch_size = 2
n_features = 3
n_genes = 4
feature_dim = 1

# x_obs shape: (batch_size, n_features, n_genes, feature_dim)
x_obs = jnp.ones((batch_size, n_features, n_genes, feature_dim))

# x_int shape: (batch_size, 0, n_genes, feature_dim) - empty interventions
x_int = jnp.ones((batch_size, 0, n_genes, feature_dim))

# is_count_data shape: (batch_size,)
is_count_data = jnp.array([True, False])

batch = {
    'x_obs': x_obs,
    'x_int': x_int,
    'is_count_data': is_count_data
}

ARGS = {
    'batch': batch
}
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, 3, 4, 1) — shape (2, 3, 4, 1) 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
jax_standardize_data Ran
ran; our contract draft was wrong, not the code
larslorch/avici/avici/model.py
code served (permissive licence) · get_code("8b9cad48608a865a")
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 jax.numpy as jnp
import numpy as np

# Create small test data for the function
# The function expects:
# - x_obs: shape (..., n_features, 1 or 2) 
# - x_int: shape (..., n_features, 1 or 2)
# - is_count_data: shape (...,) boolean array

# Using batch_size=2, n_features=4, last_dim=1 for simplicity
batch_size = 2
n_features = 4
last_dim = 1

# Create x_obs: shape (2, 4, 1)
x_obs_data = jnp.array(np.random.rand(batch_size, n_features, last_dim) * 100 + 1, dtype=jnp.float32)

# Create x_int: shape (2, 4, 1)
x_int_data = jnp.array(np.random.rand(batch_size, n_features, last_dim) * 100 + 1, dtype=jnp.float32)

# Create is_count_data: shape (2,) boolean
is_count_data = jnp.array([True, False], dtype=jnp.bool_)

# Construct the data dict that the function expects
data = {
    'x_obs': x_obs_data,
    'x_int': x_int_data,
    'is_count_data': is_count_data,
}

ARGS = {
    'data': data,
}
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 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
jax_standardize_x Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
larslorch/avici/avici/model.py
code served (permissive licence) · get_code("fee04e78e53cb7c4")
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, 3, 4, 1) 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
import numpy as np

# Create small test tensors
# x shape: (batch, n_obs, n_features, channels) where channels is 1 or 2
# Following the function logic: x should be 4D with last dim being 1 or 2
batch_size = 2
n_obs = 3
n_features = 4
channels = 1

# Create x with shape (2, 3, 4, 1)
x = jnp.array(np.random.rand(batch_size, n_obs, n_features, channels) * 100 + 1, dtype=jnp.float32)

# Create is_count_data boolean array with shape (batch_size,)
is_count_data = jnp.array([True, False], dtype=jnp.bool_)

ARGS = {
    'x': x,
    'is_count_data': is_count_data,
}
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 ArrayImpl, ndim 4, dtype family float, shape (2, 3, 4, 1) — shape (2, 3, 4, 1) 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
set_diagonal Ran
ran; our contract draft was wrong, not the code
larslorch/avici/avici/model.py
code served (permissive licence) · get_code("b37ffef9bf2f19ff")
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 3, dtype family float, shape (2, 4, 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 jax.numpy as jnp

# set_diagonal takes an array and a value
# It sets the diagonal elements (indexed by [..., i, i]) to val
# arr needs to be at least 2D with last two dimensions being square-like for diagonal indexing
# val should be a scalar or compatible shape

arr = jnp.ones((2, 4, 4))  # batch of 2, 4x4 matrices
val = 5.0  # scalar value to set on diagonal

ARGS = {
    "arr": arr,
    "val": val,
}
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 3, dtype family float, shape (2, 4, 4) — shape (2, 4, 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

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, 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 10 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

Inferring causal structure poses a combinatorial search problem that typically involves evaluating structures with a score or independence test. The resulting search is costly, and designing suitable scores or tests that capture prior knowledge is difficult. In this work, we propose to amortize causal structure learning. Rather than searching over structures, we train a variational inference model to directly predict the causal structure from observational or interventional data. This allows our inference model to acquire domain-specific inductive biases for causal discovery solely from data generated by a simulator, bypassing both the hand-engineering of suitable score functions and the search over graphs. The architecture of our inference model emulates permutation invariances that are crucial for statistical efficiency in structure learning, which facilitates generalization to significantly larger problem instances than seen during training. On synthetic data and semisynthetic gene expression data, our models exhibit robust generalization capabilities when subject to substantial distribution shifts and significantly outperform existing algorithms, especially in the challenging genomics domain. Our code and models are publicly available at: https://github.com/larslorch/avici. 36th Conference on Neural Information Processing Systems (NeurIPS 2022).

For agents

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

get_harvested_code_for_paper("2205.12934")
get_code_for_paper("2205.12934")
have("2205.12934")

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

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

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

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

Connect an agent — have() is free.