Abstract
We introduce CIfly, a framework for efficient algorithmic primitives in graphical causal inference that isolates reachability as a reusable core operation. It builds on the insight that many causal reasoning tasks can be reduced to reachability in purpose-built state-space graphs that can be constructed on the fly during traversal. We formalize a rule table schema for specifying such algorithms and prove they run in linear time. We establish CIfly as a more efficient alternative to the common primitives moralization and latent projection, which we show are computationally equivalent to Boolean matrix multiplication. Our open-source Rust implementation parses rule table text files and runs the specified CIfly algorithms providing high-performance execution accessible from Python and R. We demonstrate CIfly's utility by re-implementing a range of established causal inference tasks within the framework and by developing new algorithms for instrumental variables. These contributions position CIfly as a flexible and scalable backbone for graphical causal inference, guiding algorithm development and enabling easy and efficient deployment.
Introduction
Graphical causal inference is a powerful tool for reasoning about cause and effect, yet the field currently faces challenges regarding fragmentation and computational inefficiency. Researchers must navigate a diverse array of graph types—including DAGs, CPDAGs, MAGs, and PAGs—and a wide variety of tasks such as finding adjustment sets, d-separation, and identifying instrumental variables. Implementations are often scattered across different languages and rarely optimized for large-scale graphs.
Furthermore, many standard techniques used as building blocks, specifically graph moralization and latent projection, are computationally expensive. This research definitively shows that these operations are equivalent to Boolean Matrix Multiplication, meaning they cannot currently be solved in linear time. This creates a significant bottleneck for researchers working with large-scale datasets or complex simulations.
The CIfly Framework
CIfly addresses these issues by transforming complex causal inference tasks into simple graph reachability problems. The framework is built on the insight that most path-based causal criteria can be reduced to reachability if the state-space is defined correctly.
In this approach, a single node in the original graph might be represented by multiple states in a "state-space graph" (for example, distinguishing between arriving at a node via a directed edge versus a bidirected edge). Users specify algorithms using a "rule table," a simple text-based schema that defines the logic for moving between these states.
Crucially, CIfly does not pre-calculate the entire state-space graph. Instead, it generates only the necessary parts on the fly during a standard Depth-First or Breadth-First search. This ensures linear-time performance ($O(p+m)$), providing a significant theoretical and practical upgrade over traditional methods.
Experimental Evaluation and Results
The researchers evaluated CIfly using synthetic random graphs (CPDAGs and ADMGs) generated via Erdős-Rényi models, testing graphs ranging from 10 to 500 nodes across various edge densities. The core engine is implemented in Rust for maximum speed, with wrappers available for Python (ciflypy) and R (ciflyr).
Key findings include:
- Massive Speedups: For checking adjustment set validity, CIfly was up to five orders of magnitude faster than the R package
pcalgand 15x faster thanDAGitty. - Linear Scaling: Unlike traditional methods that slow down exponentially as graphs grow, CIfly’s runtime grows linearly with the number of nodes and edges.
- Improved Soundness: The study found that the popular
DAGittypackage produced incorrect results for instrumental variable tasks in approximately 18% of tested cases. CIfly provides a mathematically sound, verified alternative. - New Capabilities: The framework enabled the development of the first linear-time algorithms for identifying and verifying conditional instrumental sets.
Conclusion and Future Work
CIfly establishes reachability as the "assembly language" of causal inference, separating algorithmic logic from high-performance implementation. By allowing researchers to design new algorithms via simple text files, it lowers the barrier to creating efficient, scalable causal tools. Future work will focus on extending the framework to handle Maximal Ancestral Graphs (MAGs) and Partial Ancestral Graphs (PAGs).
Summary updated