Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

CRN-craft compared with GillesPy2

Measured on 12 November 2026 with the unified engine of release 0.7.0 (branch merge/M10c at cec91ed, before the release commit, so the build still reports the version string 0.6.0) and GillesPy2 1.8.3, Python 3.12.3 and g++ 13.3, on one shared two-CPU cloud host, every run under a CPU lock. The protocol and the agreement rule were declared before the first run (validation/merge/RESULTS.md, “M10c (GillesPy2 comparison on the unified engine): declaration”). Script: validation/compare_gillespy2.py; raw report: validation/merge/gillespy2-comparison-0.7.json. An earlier comparison measured the network engine of release 0.2.0; it is kept, separately, under History.

Summary

On these four networks GillesPy2’s compiled Direct-method solver (SSACSolver) takes longer than CRN-craft on every network, with every CRN-craft configuration except two selectors on the dense network:

  • with CRN-craft’s default request (Static Direct, the auto selector, Ziggurat waits), 2.9 times as long on a two-channel network, 10.6 times on a sparse 66-reaction network, 3.6 times on the 12-reaction repressilator and 9.3 times on a dense 66-reaction Michaelis–Menten network;
  • with the linear scan and inverse waits, the configuration closest to GillesPy2’s algorithm, 2.8, 5.6, 3.7 and 1.3 times as long.

GillesPy2’s pure Python solver (NumPySSASolver) takes 134 to 358 times as long as CRN-craft’s default. Its C++ solver compiles each model before the first run, which took 2.1 to 2.9 seconds. Both simulators sample the same process: all 28 agreement tests passed the declared rule.

Time per SSA event for CRN-craft’s default, the linear scan with inverse waits, composition-rejection and GillesPy2’s C++ solver on W1–W4

What was measured

IDNetworkReactionsRate laws
W1immigration–death2mass action
W233 independent immigration–death species66mass action
W3three-gene repressilator12Hill repression and mass action
W4eight species born and removed together66mass action and gated Michaelis–Menten

Each run simulates 64 paths over t from 0 to 100, with output at 0 and 100, on one thread, root seed 4242. These are the frozen workloads of the earlier performance campaigns. The network models are converted with crn_craft.convert and run as crn-craft.run/1.0 requests. Each row is the median of five interleaved runs (three for the NumPy solver).

How each row was timed:

  • CRN-craft CLI: the wall time of one crn-craft run MODEL REQUEST process for the default request, from start to exit, output included.
  • CRN-craft Python: the wall time of crn.ensemble(...) and .simulate(), preparation, the native run and the pandas result included. Rows: the default request (auto picks the linear scan on W1 and W3 and RSSA-CR on W2 and W4), the linear scan with inverse waits (the checked configuration of release 0.6.0), and each selector with Ziggurat waits.
  • GillesPy2: the wall time of model.run(solver=..., number_of_trajectories=64) with a solver object built beforehand. For the C++ solver this excludes the one-time compilation, reported separately.

Time per event divides by each CRN-craft row’s own event count, and for GillesPy2 by the event count of CRN-craft’s linear scan with inverse waits (1,274,177, 1,236,808, 3,648,339 and 1,228,794 events on W1 to W4). Both simulate the same process, so the expected number of events is the same.

Results

Median seconds for 64 paths:

W1W2W3W4
CRN-craft CLI run, default0.0490.0990.2690.107
CRN-craft default (auto, Ziggurat)0.0480.1020.2600.118
CRN-craft linear, inverse waits0.0510.1940.2570.843
CRN-craft linear, Ziggurat0.0490.2080.2620.789
CRN-craft composition_rejection, Ziggurat0.0870.1330.5111.240
CRN-craft sorting, Ziggurat0.0690.1560.3751.172
CRN-craft rssa_cr, Ziggurat0.0660.1030.4060.113
GillesPy2 SSACSolver (C++)0.1411.0800.9451.096
GillesPy2 NumPySSASolver6.5031.9537.4142.30
GillesPy2 C++ compile (once per model)2.852.142.072.29

Time per event, in nanoseconds:

W1W2W3W4
CRN-craft CLI run, default38807287
CRN-craft default38837096
CRN-craft linear, inverse waits4015770686
CRN-craft composition_rejection691081241,008
CRN-craft rssa_cr528310792
GillesPy2 C++111873259892
GillesPy2 NumPy5,09825,83410,25534,423

How many times longer GillesPy2’s C++ solver takes than CRN-craft:

W1W2W3W4
CRN-craft CLI run, default2.9010.863.5110.23
CRN-craft default2.9110.563.639.27
CRN-craft linear, inverse waits2.785.573.681.30
CRN-craft composition_rejection1.618.141.850.88
CRN-craft sorting2.046.922.520.93
CRN-craft rssa_cr2.1310.542.339.67

Run-to-run spread: most timed runs lie within 10% of their median. Single CRN-craft runs deviated by up to 34% (rssa_cr on W2) and GillesPy2’s C++ solver by up to 7%; the medians are robust to these outliers. On W1 and W3 the default and the linear scan with Ziggurat waits are the same computation, so their difference is noise.

Reading the results

  • The per-event strategies differ. In GillesPy2 1.8.3 (SSASolver.cpp), after each event the C++ solver:

    • recomputes only the propensities the fired reaction affects;
    • sums all propensities again;
    • picks the reaction by a linear scan;
    • loops over all species to apply the update.

    CRN-craft’s linear scan also recomputes only the affected rates, but it resumes its running total at the first changed channel and changes only the species the channel changes. On the sparse network (W2), where each reaction changes one species and one rate, that makes it 5.6 times faster.

  • The selector matters most on W2 and W4. The default auto picks RSSA-CR there. On W4 every event changes all 33 Michaelis–Menten death rates; RSSA-CR keeps bounds on them and evaluates a rate only when a bound cannot decide, so it needs far fewer rate evaluations than any Direct scan. With the linear scan W4 is 1.3 times faster than GillesPy2; with RSSA-CR 9.3 times. Composition–rejection and sorting are slower than GillesPy2 on W4 and are not what auto picks there.

  • Every configuration keeps CRN-craft’s checks. On every event it checks that no positive rate is lost to rounding or too small to be selected, draws from a ChaCha8 stream per path, polls for cancellation, and gives byte-identical results for every thread count. GillesPy2 makes none of these checks. Release 0.6.0 had an opt-in fast policy that dropped the per-event checks; the unified engine has no such switch, so these rows are the checked engine.

  • Compilation matters for short jobs. GillesPy2’s C++ solver compiles each model before its first run, in 2.1 to 2.9 seconds, about 20 times the W1 run itself. CRN-craft needs no per-model compilation.

  • The NumPy solver evaluates propensities in Python and takes 134 to 358 times as long as CRN-craft’s default.

The two tools simulate the same process

Before timing, both simulators ran 512 paths of each network with fixed, different seeds, twice: once with CRN-craft’s linear scan and inverse waits, once with its default. The declared rule: with a family-wise error rate of 0.01 over the 28 tests below (Bonferroni), a p-value below 3.6e-4 is a failure; on W4 every species must stay equal within each path.

  • Final counts agree. Two-sample Kolmogorov–Smirnov tests compared the final counts of up to three species per network: 20 tests, smallest p-value 0.209. Every mean z-score is at most 1.47 in absolute value.
  • The exact law agrees. W1 and W2 have Poisson laws at t = 100, with means 100 and 15. Pooled chi-square tests against them: 8 tests (both simulators, both CRN-craft configurations), smallest p-value 0.044 (GillesPy2 on W2).
  • W4: all eight species stay equal in every path of both simulators, as the network’s structure requires.

No test failed.

How the models were translated

  • Mass action: as GillesPy2 mass-action reactions. W1–W4 have only zeroth- and first-order reactants, so no combinatorial convention differs.
  • Hill repression: as the propensity expression basal + vmax / (1 + pow(x/K, n)).
  • Michaelis–Menten: as vmax * S / (Km + S).
  • Reactant gates. CRN-craft fires a whole-rule propensity only when its reactants are present. GillesPy2 expressions have no comparisons, so a gate is written as x / (x + 1e-300), which is exactly 0 for x = 0 and 1 otherwise.
  • W4 is timed without gates. Its eight species always stay equal, so the gates on its Michaelis–Menten deaths never change a propensity. The validation confirms this. With the gates, GillesPy2’s C++ solver took 9.32 seconds instead of 1.10, about 8.5 times longer. That cost belongs to the translation rather than to GillesPy2, so the comparison uses the faster form; the gated time is in the raw report.

Limitations

  • Host: one shared two-CPU cloud host. Absolute times differ on other machines, and the ratios may too.
  • Random streams are independent, so this compares cost for the same process, not identical paths.
  • Event counts: GillesPy2’s are not instrumented. Its time per event uses CRN-craft’s count, and the 64-path counts of the two tools differ by sampling noise.
  • What the timings include: GillesPy2’s include building its result objects and, for the C++ solver, launching its compiled program and parsing its output. CRN-craft’s Python rows include preparation and the conversion of the result into pandas objects.
  • Scope: only exact SSA on one thread. CRN-craft can also divide replicates among threads without changing results. GillesPy2 also offers tau-leaping, hybrid and ODE solvers, which are not compared here.
  • Workload size: the networks are small to medium (up to 66 reactions).
  • Build: measured on a tree that still contained the network engine’s code, before its deletion; the methods measured here do not call it.

Reproducing

python -m pip install -r validation/reference-requirements.txt
maturin build --release --locked --out dist && python -m pip install dist/*.whl
cargo build --release --workspace --locked
python validation/compare_gillespy2.py --binary target/release/crn-craft \
    --output gillespy2.json --figure gillespy2.png

GillesPy2 builds its C++ solver with SCons through python3 on the PATH, so SCons must be importable there; with the virtual environment’s bin first on the PATH that is the environment’s own Python. The script needs a C++ compiler and takes about ten minutes, mostly in the NumPy solver. --only W1 measures one workload; the report above merges four such runs.

History: the network engine of 0.2.0

These numbers were measured on 2 November 2026 with CRN-craft 0.2.0-dev.1, the network engine that release 0.7.0 replaced, and are not comparable with the tables above: another engine, another random stream, Python 3.13, and the fast policy, which dropped the per-event checks. Raw report: validation/fast/gillespy2-comparison-fast.json; the first comparison (1 November, checked policy only) is in validation/campaign/gillespy2-comparison.json.

Median seconds for 64 paths, 2 November 2026 (0.2.0-dev.1):

W1W2W3W4
CRN-craft fast cached Direct0.0390.0830.1790.498
CRN-craft fast DirectCR0.0570.0750.2730.647
CRN-craft fast SortingDirect0.0460.1020.1930.639
CRN-craft fast RSSACR0.0580.0830.3090.083
CRN-craft simulate-cached (checked)0.0620.1900.2840.678
CRN-craft simulate (checked)0.0650.5860.4150.821
GillesPy2 SSACSolver (C++)0.1130.6810.6460.761
GillesPy2 NumPySSASolver4.4224.427.531.5
GillesPy2 C++ compile (once per model)4.71.71.61.8

Time per SSA event on 2 November 2026: CRN-craft 0.2.0-dev.1 with the fast policy and checked, and GillesPy2’s C++ solver