Why Andrey is fast#

Cover: lanes rising into the sky, one amber streak far ahead, drawn in navy lines

Most of the time in causal discovery goes to two jobs: testing whether variables are independent (PC and FCI) and scoring candidate graphs (GES and BOSS). We speed up both with four ideas, easiest first. Each animation runs the same work in two lanes: Andrey’s, and one labeled Others that does it one step at a time. They are illustrations of the ideas, not measurements; the benchmarks have the measurements.

1. Do many things at once#

Batch and parallelize. Within one round of PC, each independence test stands alone, and within one pass of GES, so does each candidate move. Andrey runs them as one batched array operation, thousands at a time, with the same results as one at a time.

Andrey: 1 call, one call for the batch. Others: 8 calls, one call per test.

2. Never compute twice#

Cache and update incrementally. Andrey computes the correlation matrix once, up front, and caches it. Each test reads the few entries it needs instead of recomputing them, and GES memoizes its local scores the same way.

Andrey: 1 computation, computed once, then read. Others: 6 computations, recomputed for each test.

3. Skip what can’t matter#

Prune the search early. Tests given zero or one other variable have a closed form, so a quick pass settles most edges before any matrix is inverted. GES rules out invalid candidates with bit masks before scoring them.

Andrey: 3 inversions, a quick check first. Others: 10 inversions, every test inverts a matrix.

4. Use the hardware you have#

Hardware-aware acceleration. With the optional extras, Numba JIT-compiles GES’s path checks, and a CUDA GPU computes large entropy tables many cells at a time, once they are large enough to repay the transfer. Correlation matrices move to the GPU too when you set ANDREY_BACKEND=cuda.

Andrey: 3 steps, a GPU, many cells per step. Others: 48 steps, one core, one cell per step.

AI statement. Parts of this post were drafted with Claude Code and Codex. The author checked every statement, number, and reference and is responsible for the content.