SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2307.13917 · NeurIPS · 2023

BayesDAG: Gradient-Based Posterior Inference for Causal Discovery

Cheng Zhang, Nick Pawlowski, Yashas Annadani, Stefan Bauer, Wenbo Gong, Joel Jennings

arXiv · PDF · Open in the Atlas

Code that ran

4 of 7 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; 1 honoured the contract we drafted, 0 violated it and 1 has no contract verdict; 2 failures of our instrument; 3 no recorded run), measured 2026-11-23; 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/2307.13917.json · badge: /api/ran/2307.13917.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
microsoft/Project-BayesDAG canonical (classifier label)
classifier basis: census
3 ran · 1 no recorded run
kurowasan/GraN-DAG community
Papers with Code archive
1 ran · 1 no recorded run
copy not recorded community
not in the paper's declared repositories
0 ran · 1 no recorded run
FunctionStatusWhere it lives
BaseModel Ran
ran on a synthesized input · constructed an object; no result was computed
kurowasan/GraN-DAG/gran_dag/models/learnables.py
code served (permissive licence) · get_code("e8d9b4d10fe3230b")
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, BaseModel: 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

torch.manual_seed(0)

ARGS = {
    'num_vars': 4,
    'num_layers': 2,
    'hid_dim': 3,
    'num_params': 2,
    'nonlin': 'leaky-relu',
    'norm_prod': 'path',
    'square_prod': False,
}
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 BaseModel — 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 BaseModel 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
download_dataset Ran
ran, honoured the contract we drafted
microsoft/Project-BayesDAG/src/causica/download_dataset.py
code served (permissive licence) · get_code("20a53997e54a0737")
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 (178, 14) 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
from sklearn import datasets

# The function takes a dataset_name parameter
# It supports 'boston' and 'wine' datasets from sklearn
# We'll use 'wine' as a valid dataset name

ARGS = {
    'dataset_name': 'wine'
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, sklearn — 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 (178, 14) — shape (178, 14) 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
split_configs Ran
ran; our contract draft was wrong, not the code
microsoft/Project-BayesDAG/src/causica/run_experiment.py
code served (permissive licence) · get_code("f322162c5e45f661")
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 list, ndim 2, 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 torch
import torch.nn as nn
from typing import Any, Dict, List, Optional, Tuple

torch.manual_seed(0)

# Create a small model config with some list values to trigger splitting
model_config = {
    "learning_rate": [0.001, 0.01, 0.1],
    "batch_size": 32,
    "hidden_dim": [64, 128],
    "num_layers": 2,
    "dropout": [0.1, 0.2, 0.3],
    "optimizer": "adam",
}

# Create a simple dataset config
dataset_config = {
    "dataset_name": "cifar10",
    "num_classes": 10,
    "input_size": 784,
    "validation_split": 0.2,
}

ARGS = {
    "model_config": model_config,
    "dataset_config": dataset_config,
}
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 list, ndim 2, dtype family float — a list 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
untranspose_stack Ran
ran; our contract draft was wrong, not the code
microsoft/Project-BayesDAG/src/causica/models/bayesdag/generation_functions.py
code served (permissive licence) · get_code("7e67818eba876c55")
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

torch.manual_seed(0)

# Build tuple_of_tensors: a tuple of tensors
# Each tensor will have shape (batch_size, ...) where we can index by 'index'
# The function indexes into dimension 0 of each tensor
tensor1 = torch.randn(2, 4)  # batch size 2, feature dim 4
tensor2 = torch.randn(2, 3)  # batch size 2, feature dim 3 (distinct)
tensor3 = torch.randn(2, 5)  # batch size 2, feature dim 5 (distinct)

tuple_of_tensors = (tensor1, tensor2, tensor3)

# index: which element to select from dimension 0
index = 0

# clone: boolean flag
clone = False

ARGS = {
    "tuple_of_tensors": tuple_of_tensors,
    "index": index,
    "clone": clone,
}
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 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
LearnableModel Not yet run
unverified (harvested, no recorded run)
kurowasan/GraN-DAG/gran_dag/models/learnables.py
code served (permissive licence) · get_code("a9daf9295e1bea2b")
How it ran

no invocation recorded.

compute_A_phi Not yet run
unverified (harvested, no recorded run)
this paper's copy was not recorded; identical code first harvested from kurowasan/GraN-DAG
pointer only · get_code("6ed7da204f2567a9")
How it ran

The body of this sample is withheld: this paper's copy of the code was not recorded (its link names no repository or source path), so no licence was read for it. 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. No invocation recorded.

create_diagonal_spline_flow Not yet run
unverified (harvested, no recorded run)
microsoft/Project-BayesDAG/src/causica/models/bayesdag/diagonal_flows.py
code served (permissive licence) · get_code("c4e4a51a4b478e9e")
How it ran

no invocation recorded.

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, 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 6 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
compute_A_phi
brick of this paper's assembly: helper
1 other paper
1 dated earlier
1906.02226 (2019-06)
Gradient-Based Neural DAG Learning

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-23.

Repositories linked to this paper

Some links come from the archived Papers with Code dataset (CC BY-SA 4.0): attribution and licence.

Abstract

Bayesian causal discovery aims to infer the posterior distribution over causal models from observed data, quantifying epistemic uncertainty and benefiting downstream tasks. However, computational challenges arise due to joint inference over combinatorial space of Directed Acyclic Graphs (DAGs) and nonlinear functions. Despite recent progress towards efficient posterior inference over DAGs, existing methods are either limited to variational inference on node permutation matrices for linear causal models, leading to compromised inference accuracy, or continuous relaxation of adjacency matrices constrained by a DAG regularizer, which cannot ensure resulting graphs are DAGs. In this work, we introduce a scalable Bayesian causal discovery framework based on a combination of stochastic gradient Markov Chain Monte Carlo (SG-MCMC) and Variational Inference (VI) that overcomes these limitations. Our approach directly samples DAGs from the posterior without requiring any DAG regularization, simultaneously draws function parameter samples and is applicable to both linear and nonlinear causal models. To enable our approach, we derive a novel equivalence to the permutation-based DAG learning, which opens up possibilities of using any relaxed gradient estimator defined over permutations. To our knowledge, this is the first framework applying gradient-based MCMC sampling for causal discovery. Empirical evaluation on synthetic and real-world datasets demonstrate our approach's effectiveness compared to state-of-the-art baselines.

For agents

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

get_harvested_code_for_paper("2307.13917")
get_code_for_paper("2307.13917")
have("2307.13917")

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

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

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

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

Connect an agent — have() is free.