This release is a pre-release and may not be stable for production use.
tramdag — Interpretable Neural Causal Models (TRAM-DAGs) in PyTorch
TRAM-DAGs model each variable of a structural causal model with a monotone normalizing flow, the statistician's transformation model. The whole model is one triangular normalizing flow from iid standard-logistic latents to the observed variables, and its triangular structure is exactly your causal DAG. One fit on observational data answers all three rungs of Pearl's causal hierarchy: observational, interventional (the do-operator) and counterfactual (abduction). The model keeps interpretable effects: every linear-shift coefficient is a log-odds ratio, as in a classical proportional-odds model.
Beate Sick & Oliver Dürr, Interpretable Neural Causal Models with TRAM-DAGs, CLeaR 2025 (arXiv:2503.16206). This repository is the reference implementation, in PyTorch on zuko. It replicates the paper's experiments under continuous integration.
Start here
The demo notebook is the introduction. It fits the paper's bimodal benchmark, walks the three rungs, and checks every answer against analytic ground truth. It runs on CPU in a few minutes, in Colab or locally.
Install
The package is on PyPI as tramdag; uv add tramdag or pip install tramdag
installs it, and the plots extra (tramdag[plots]) adds matplotlib for the
figures. The PyPI release lags main; for the current state install from git
(tramdag @ git+https://github.com/tensorchiefs/tramdag.git@main, pinned to a
commit for reproducibility). A clone with uv sync gives the development
setup with tests and experiments.
Documentation
Guides, executed notebooks and the API reference are published at the documentation site. Each subject has one guide, and its worked example is one notebook.
| Subject | Guide | Example |
|---|---|---|
| The model, its notation, what it cannot do | docs/model.md, docs/notation.md |
demo |
| Reading a fitted model: coefficients, curves, interventional distributions | docs/interpretation.md |
classical fitting |
| Fitting: the likelihood, the Adam loop and its callbacks, the classical fit, a runtime comparison of the recipes | docs/fitting.md |
training strategies |
| Complex intercepts, joint versus additive | additive vs joint intercepts | |
| Treatment effects that vary with covariates | docs/varying-coefficients.md |
varying coefficients |
| Scores and the effect-modifier scan | docs/scores.md |
varying coefficients |
| Agreement with statsmodels and R, standard errors | classical fitting | |
| What the tests guarantee | tests/README.md |
|
| The API, every default and where it lives | docs/code-map.md |
|
| How the package is built inside | docs/architecture.md |
|
| zuko, and what tramdag would upstream | docs/zuko-upstream.md |
|
| The cited literature | docs/references.md |
CONTRIBUTING.md covers setup, tests, linting and
releases; notebooks/README.md how the notebooks are
written and run.
Experiments
experiments/ replicates the paper's experiments against its own R code and
checks them against committed ground truth in continuous integration.
experiments/README.md explains the layout, the
YAML variants and the frozen data;
docs/paper-replication.md gives the protocol,
the hyperparameters and the numbers, experiment by experiment.
Layout
src/tramdag/is the framework, and nothing else.tests/measures it against three inline data-generating processes; it never imports research code.experiments/holds the paper replications and their frozen data sets.notebooks/are jupytext.pyfiles, executed by the docs workflow.docs/are the guides; the API pages render from the docstrings.
Use of AI tools
This project was developed with the help of LLM coding assistants. The authors reviewed and take responsibility for all content.
Citation
If you use tramdag, please cite the method paper:
@inproceedings{sick2025tramdag,
title = {Interpretable Neural Causal Models with {TRAM-DAGs}},
author = {Sick, Beate and D{\"u}rr, Oliver},
booktitle = {Proceedings of the 4th Conference on Causal Learning and Reasoning (CLeaR)},
series = {Proceedings of Machine Learning Research},
volume = {275},
pages = {606-630},
year = {2025},
eprint = {2503.16206},
url = {https://arxiv.org/abs/2503.16206},
}
Metadata
Release files for tramdag 1.0.0rc1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| tramdag-1.0.0rc1.tar.gz | 59.4 kB | With provenance | Details for tramdag-1.0.0rc1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| tramdag-1.0.0rc1-py3-none-any.whl | Python 3 | none | any | Details for tramdag-1.0.0rc1-py3-none-any.whl |
Total release size: 124.2 kB
Release files / tramdag-1.0.0rc1.tar.gz
| Download URL | tramdag-1.0.0rc1.tar.gz |
|---|---|
| Size | 59.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
007248d4afce186fd855097bc4dc591cff7146126bb9de3fc0bca0cd66aa4dd4
|
|
BLAKE2b-256 checksum How to use checksums |
b71855abe3061337042bd2c14a5814af3d5fc7a562011dd3a00d77816bb460c7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 1, 2026.
Transparency logRelease files / tramdag-1.0.0rc1-py3-none-any.whl
| Download URL | tramdag-1.0.0rc1-py3-none-any.whl |
|---|---|
| Size | 64.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a76d39464931d358e62fd47f8189b5f2762e8ef2de680b935bfa9c593d69b941
|
|
BLAKE2b-256 checksum How to use checksums |
bf7bfdc1f412fea43604207ba5a924a5639c72731b7b18762f1c7839960bf5da
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 1, 2026.
Transparency logSecurity for tramdag 1.0.0rc1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for tramdag-1.0.0rc1.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 1, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.