SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2302.00860 · 2023

Modeling Causal Mechanisms with Diffusion Models for Interventional and Counterfactual Queries

arXiv · PDF · Open in the Atlas

Code that ran

8 of 12 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 7 have no contract verdict; 0 failures of our instrument; 4 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/2302.00860.json · badge: /api/ran/2302.00860.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
patrickrchao/diffusionbasedcausalmodels canonical (classifier label)
classifier basis: classifier_2025
1 ran · 3 no recorded run
tatsu432/BDCM community (classifier label)
classifier basis not recorded on the link
7 ran · 1 no recorded run
FunctionStatusWhere it lives
build_diffusion_schedule Ran
ran on a synthesized input
tatsu432/BDCM/src/bdcm/config.py
code served (permissive licence) · get_code("a63a5a850576074d")
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 DiffusionSchedule. 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

ARGS = {
    'T': 100
}
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 DiffusionSchedule — a DiffusionSchedule output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a DiffusionSchedule 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
config_summary Ran
ran on a synthesized input
tatsu432/BDCM/src/bdcm/hydra_config.py
code served (permissive licence) · get_code("a013316d618bdcde")
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 str. 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 omegaconf import DictConfig, OmegaConf

# Create a simple DictConfig with various nested settings
cfg_dict = {
    "model": {
        "name": "transformer",
        "hidden_dim": 768,
        "num_layers": 12,
    },
    "training": {
        "batch_size": 32,
        "learning_rate": 1e-4,
        "epochs": 10,
    },
    "data": {
        "train_path": "/path/to/train",
        "val_path": "/path/to/val",
        "max_length": 512,
    },
    "seed": 42,
    "use_mixed_precision": True,
}

cfg = OmegaConf.create(cfg_dict)

ARGS = {
    "cfg": cfg,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
omegaconf — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type str — a str output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a str 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
create_input_1 Ran
ran on a synthesized input
tatsu432/BDCM/src/bdcm/infrastructure/diffusion.py
code served (permissive licence) · get_code("f52e9c858becf668")
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 (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 numpy as np

# Create small numpy arrays for the diffusion process
# alpha_t: schedule value at time t (scalar or small array)
alpha_t = np.array([0.9])

# x: input data (batch_size=2, features=4)
x = np.random.randn(2, 4)

# epsilon: noise (same shape as x, batch_size=2, features=4)
epsilon = np.random.randn(2, 4)

ARGS = {
    "alpha_t": alpha_t,
    "x": x,
    "epsilon": epsilon
}
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 (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
experiment_config_from_omegaconf Ran
ran on a synthesized input
tatsu432/BDCM/src/bdcm/config.py
code served (permissive licence) · get_code("e4882eb143ebe45c")
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 ExperimentConfig. 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
from pathlib import Path
from omegaconf import OmegaConf

# Create a minimal OmegaConf experiment node with all required fields
experiment_config_dict = {
    'num_seeds': 3,
    'n_obs': 500,
    'n_sample_dcm': 250,
    'num_interventions': 5,
    'lowest_intervention': -2.5,
    'highest_intervention': 2.5,
    'num_epochs': 100,
    'batch_size': 32,
    'learning_rate': 0.001,
    'mu': 0.0,
    'sigma': 1.0,
    'schedule': {
        'T': 50
    },
    'flags': {
        'plot_nn_train': True,
        'print_each_mmd': False,
        'show_plot': False
    }
}

experiment_node = OmegaConf.create(experiment_config_dict)

ARGS = {
    'experiment_node': experiment_node
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, omegaconf — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type ExperimentConfig — a ExperimentConfig output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a ExperimentConfig 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
get_train_data Ran
ran, honoured the contract we drafted
patrickrchao/diffusionbasedcausalmodels/all_exp.py
code served (permissive licence) · get_code("ffedaa6f5d9645d7")
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 Tensor, ndim 2, dtype family float, shape (2, 3) 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 numpy as np
import pandas as pd
import networkx as nx
from torch import nn

torch.manual_seed(0)

# Stand-in Dataset class
class StandInDataset:
    def __init__(self):
        self.var_to_idx = {'var_0': 0, 'var_1': 1, 'var_2': 2, 'var_3': 3}
        self.U = torch.randn(2, 4)  # batch_size=2, num_vars=4

# Stand-in DataLoader class
class StandInDataLoader:
    def __init__(self):
        self.dataset = StandInDataset()

# Stand-in DataModule class
class StandInDataModule:
    def __init__(self):
        self._data_loader = StandInDataLoader()
    
    def train_dataloader(self):
        return self._data_loader

# Stand-in TrueModel class
class StandInTrueModel(nn.Module):
    def __init__(self):
        super().__init__()
        self.linear = nn.Linear(4, 3)
    
    def data_from_noise(self, train_u):
        # train_u is a DataFrame, convert to tensor
        if isinstance(train_u, pd.DataFrame):
            data_tensor = torch.tensor(train_u.values, dtype=torch.float32)
        else:
            data_tensor = train_u
        return self.linear(data_tensor)

# Create instances
data_module = StandInDataModule()
graph = nx.DiGraph()
true_model = StandInTrueModel()

ARGS = {
    'data_module': data_module,
    'graph': graph,
    'true_model': true_model
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1
Imports
networkx, numpy, pandas, 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, 3) — shape (2, 3) 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
mmd Ran
ran on a synthesized input
tatsu432/BDCM/src/bdcm/infrastructure/mmd.py
code served (permissive licence) · get_code("e1188dd6fec1ecd6")
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 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 torch

torch.manual_seed(0)

# Create two small tensors for x and y
# x: shape (2, 4) - 2 samples, 4 dimensions
# y: shape (2, 4) - 2 samples, 4 dimensions
x = torch.randn(2, 4)
y = torch.randn(2, 4)

# Device set to CPU
device = torch.device('cpu')

# Kernel type - must be one of 'multiscale' or 'rbf'
kernel = 'rbf'

ARGS = {
    'x': x,
    'y': y,
    'kernel': kernel,
    'device': device,
}
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 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
normalize Ran
ran on a synthesized input
tatsu432/BDCM/src/bdcm/infrastructure/diffusion.py
code served (permissive licence) · get_code("ce0be3a33a19fd30")
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 (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 numpy as np

# Create a small test array with shape (2, 4) for normalization
x = np.array([[1.0, 2.0, 3.0, 4.0],
              [5.0, 6.0, 7.0, 8.0]], dtype=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 ndarray, 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
save_array Ran
ran on a synthesized input
tatsu432/BDCM/src/bdcm/infrastructure/evaluation.py
code served (permissive licence) · get_code("420cc879345f3b2e")
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 float, shape (2, 6, 5) 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
import numpy as np

torch.manual_seed(0)

# Define minimal nn.Module for array_net_x
class MinimalNet(nn.Module):
    def __init__(self, input_size=4, output_size=3):
        super().__init__()
        self.linear = nn.Linear(input_size, output_size)
    
    def forward(self, x):
        return self.linear(x)

# Create sample callables for DCM and BDCM sampling functions
def sample_outcome_do_cause_DCM(intervention_value, x, array_net_x):
    # Returns an array with shape (2, 5) to be stacked
    return np.random.randn(2, 5)

def sample_outcome_do_cause_BDCM(intervention_value, x, array_net_x):
    # Returns an array with shape (2, 5) to be stacked
    return np.random.randn(2, 5)

# Create the arguments
array_interventions = np.array([0.1, 0.5, 0.9])  # 3 interventions
x = np.random.randn(2, 4)  # Small sample array with batch=2, features=4
array_net_x = [MinimalNet(input_size=4, output_size=3) for _ in range(2)]  # Sequence of 2 minimal networks

ARGS = {
    "array_interventions": array_interventions,
    "sample_outcome_do_cause_DCM": sample_outcome_do_cause_DCM,
    "sample_outcome_do_cause_BDCM": sample_outcome_do_cause_BDCM,
    "x": x,
    "array_net_x": array_net_x
}
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 ndarray, ndim 3, dtype family float, shape (2, 6, 5) — shape (2, 6, 5) 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
compose_config Not yet run
unverified (harvested, no recorded run)
tatsu432/BDCM/src/bdcm/hydra_config.py
code served (permissive licence) · get_code("f510fd2b496d5b89")
How it ran

no invocation recorded.

convert_data_to_pandas Not yet run
unverified (harvested, no recorded run)
patrickrchao/diffusionbasedcausalmodels/all_exp.py
code served (permissive licence) · get_code("9e4e0b99a3c337ca")
How it ran

no invocation recorded.

convert_numpy_to_torch Not yet run
unverified (harvested, no recorded run)
patrickrchao/diffusionbasedcausalmodels/model/diffusion.py
code served (permissive licence) · get_code("66a5d053ccc3be6e")
How it ran

no invocation recorded.

get_data_loader Not yet run
unverified (harvested, no recorded run)
patrickrchao/diffusionbasedcausalmodels/all_exp.py
code served (permissive licence) · get_code("44bde545b1a472e4")
How it ran

no invocation recorded.

Also present in other papers' code

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

We consider the problem of answering observational, interventional, and counterfactual queries in a causally sufficient setting where only observational data and the causal graph are available. Utilizing the recent developments in diffusion models, we introduce diffusion-based causal models (DCM) to learn causal mechanisms, that generate unique latent encodings. These encodings enable us to directly sample under interventions and perform abduction for counterfactuals. Diffusion models are a natural fit here, since they can encode each node to a latent representation that acts as a proxy for exogenous noise. Our empirical evaluations demonstrate significant improvements over existing state-of-the-art methods for answering causal queries. Furthermore, we provide theoretical results that offer a methodology for analyzing counterfactual estimation in general encoder-decoder models, which could be useful in settings beyond our proposed approach.

For agents

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

get_harvested_code_for_paper("2302.00860")
get_code_for_paper("2302.00860")
have("2302.00860")

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

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

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

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

Connect an agent — have() is free.