Cleft Labs Research Initiative · C++20 / C ABI / Python · v0.1.0
Whole-brain spiking simulation in 7.0 milliseconds.
CleftEngine is a simulation engine for connectome-scale spiking neural networks: fixed wiring diagrams with 105–106 neurons and 107–108 synapses, in which most neurons are silent most of the time, simulated across many trials. On the Drosophila whole-brain model of Shiu et al. (2024) — 138,639 neurons and 15.1 million connections — one second of activity takes 7.0 ms on one CPU core (143× real time), and 30 trials finish in 60 ms on 4 cores (499× real time), matching Brian2 spike for spike.
Because the subthreshold LIF dynamics are linear, an analytical upper bound decides whether a neuron can cross v_thresh before its next input. In the fly-brain benchmark, only 0.024% of neuron-steps are computed — an exact optimization, not an approximation.
Fly Brain · 1 Core
7.0 ms / s
143× real time on 138,639 neurons and 15.1 M synapses (537× faster than Brian2 Cython).
30-Trial Batch · 4 Cores
60 ms
499× real time total (2.0 ms/trial) on one shared immutable connectome; thread-count invariant.
Brian2 Equivalence
13,411 / 13,411
Every spike across 381 active neurons matches in step and neuron ID, in float64 and float32.
Dense AVX2 & Footprint
176 ms / s
5.7× real time dense (32-wide AVX2 + sparse ref bitmap); 16 B/neuron, 8 B/synapse, THP-aligned.
01 / Live 3D Brain Dashboard & Showcase
Real FlyWire whole-brain spiking telemetry, rendered and interactive.
CLEFTENGINE LIVE TELEMETRY · FLYWIRE FAFB v783 SUGAR-GRN ACTIVATION (1,000 ms)138,639 NEURONS · 15.1M SYNAPSES · 100% BRIAN2 MATCH
Explore the live connectome directly in your browser.
Driven by authentic CleftEngine simulation output on the FlyWire FAFB v783 connectome (20 sugar-sensing GRNs at 150 Hz, 358 active neurons, 12,237 spikes, 1.86 M synaptic events). Orbit the 3D brain, toggle excitatory and inhibitory pathways, scrub the timeline, and inspect live v(t)/g(t) probes with exact cold-vs.-hot peak-bound detection — zero external CDNs.
Whole-Brain Cascade Geometry. Real connectivity-embedded 3D layout of the 138,639-neuron Drosophila brain showing excitatory (violet/cyan) and inhibitory (rust/amber) pathways propagating from the subesophageal zone (SEZ) into protocerebral and descending circuits.
PLATE B · SYNCHRONIZED TELEMETRY VIEWINTERACTIVE CANVAS
Multi-Instrument Inspection. Synchronized v(t) & g(t) recordings across 6 probed neurons (hops 0–3), full 12,237-spike raster, instantaneous synaptic flux, and live cold-vs.-hot neuron fraction (~0.024% grid-stepped). Open live dashboard →
02 / Architecture & Exact Integration
Three consequences of linear subthreshold dynamics.
01 · DIAGONALIZED PROPAGATOR
Exact closed-form eigen-stepping
The engine integrates the leaky integrate-and-fire neuron with an exponential current synapse in diagonalized (z, g) eigen-coordinates, eliminating cross-terms and shrinking each propagator entry to 8 bytes. A k-step jump reduces to two scalar multiplies, matching Brian2 spike for spike.
Float32 default · Float64 build (-DCE_DOUBLE)
Hot propagator table (k < 64) fits in 512 B of L1d
02 · PEAK BOUND
Cold neurons are skipped, not approximated
The closed-form free trajectory yields a strict analytical upper bound on the future membrane peak. Neurons whose bound lies below v_thresh remain cold and are brought up to date only when an event arrives; pure-inhibitory segments bypass wake checks altogether.
Fly-brain constants: kick > 44 mV to turn hot
0.024 % of neuron-steps computed in sugar-GRN run
03 · SIMD EVENT PATH
Cost scales with events, not network size
Synapses are stored in a delay-segmented CSR grouped by (pre, delay) so each spike queues one entry per distinct delay and streams targets through a 2-wide SIMD delivery loop. Across trials, worker threads share one immutable connectome while reusing thread-local workspaces.
End-to-end data flow from static connectome construction to zero-allocation parallel trial execution. One read-only Connectome (118 MiB for FlyWire) is shared across concurrent worker threads, each owning a reusable Workspace.
03 / Empirical Benchmarks
Whole-brain throughput and lazy-vs.-dense scaling.
Drosophila Whole-Brain Model · Shiu et al. (2024)
138,639 neurons, 15.1 million connections
Reproducing the sugar-GRN activation experiment on the FlyWire FAFB v783 connectome (1 second of simulated biological time, dt = 0.1 ms, 20 sugar GRNs @ 150 Hz). Every row is a single CPU thread unless noted otherwise.
Configuration (1 s activity)
Wall time
vs. Real time
Brian2 2.10 (Cython, run phase)
4.10 s
0.24×
CleftEngine, dense AVX2 (f64 / f32)
349 / 176 ms
2.9× / 5.7×
CleftEngine, lazy f32 (1 thread)
7.0 ms
143×
CleftEngine, 30 trials · 4 threads
60 ms
499×
Hardware: 4 cores of AMD Ryzen 9 5950X (VM), GCC 13.3, -O3 -march=native. Load Parquet/CSV + Connectome build: 0.55 s. Fixed-input Brian2 parity run: 7.63 ms f32 (537× Brian2), 8.24 ms f64 (497× Brian2). Reproducible via bench/flywire.py and bench/compare_brian2.py.
FIG. 03 · WALL TIME PER SIMULATED SECONDLog scale (ms)
Single-core lazy execution reduces wall time from 4.1 s to 7.0 ms (537× vs. Brian2 on the fixed-input reference). Trial batches reach 499× real time on 4 cores without duplicating the connectome.
Choosing a Backend · Random Balanced Network
Crossover at ~0.19 synaptic events per neuron-step
backend="lazy" scales with synaptic events; backend="dense" scales with neurons × steps via an adaptive AVX2 kernel. On a 100,000-neuron, 10 M-synapse network simulated for 500 ms (bench/synthetic.py), both backends produce identical spikes and cross over near 0.19 events/neuron/step:
Connectome models driven via sparse sensory pathways sit orders of magnitude to the left of the ~0.19 crossover. Inspect stats["n_syn_events"] / (n_neurons * stats["n_steps"]) on your workload.
FIG. 05 · OPTIMIZATION COMPARISONBaseline vs. Current
Checked against Brian2, sanitizers, and its own dense kernel.
VALIDATION · 46 TESTS · ASAN / UBSAN CLEAN
What is verified
Brian2, spike for spike: Random networks with heterogeneous delays, mixed E/I synapses, and multiple neuron classes match Brian2 identically in the float64 build.
Whole fly brain vs. Brian2: With fixed input spikes, all 13,411 spikes across 381 active neurons coincide in step and neuron ID for both backends, in float64 and float32.
Lazy vs. dense equivalence: Tested over random τsyn ≷ τm, thresholds, reset levels, tonic classes, and inhibition-dominated regimes. Weakening the peak bound by 10% causes tests to fail.
Exact step semantics: Matches three easy-to-miss Brian2 rules — refractory input is discarded, integration resumes at n + t_ref/dt, and same-step input at a spike is wiped by reset.
Thread-count determinism: Random streams are keyed to (seed, stimulus, neuron), so parallel trial batches are invariant to thread count.
CURRENT SCOPE & ROADMAP
Known limits
Single neuron family: LIF with exponential current synapse (g in mV), configurable per class. No conductance synapses, adaptation currents, gap junctions, or neuromodulation yet.
Static weights: No short-term or long-term synaptic plasticity; connectome weights are immutable during a run.
Trial-level parallelism: One simulation runs on one thread; parallelism is across trials and parameter sweeps. Fits connectome perturbations, not single ultra-dense networks.
CPU-only (x86-64 Linux): Built and tested with GCC 13 on x86-64 Linux. Dense networks past a few million fast-firing neurons belong on a GPU simulator.
Planned next: Additional linear models with peak bounds (alpha synapses, adaptation), SIMD hot-neuron pool, intra-run partitioning, and automatic backend switching.
05 / Build & Interfaces
Python / NumPy front end over a zero-dependency C ABI.
import numpy as np
import cleftengine as ce
# Connectome from edge lists (units: ms and mV; scalar or per-synapse delay)
net = ce.Network(n_neurons, pre, post, weight_mv, delay=1.8, dt=0.1)
result = net.run(
1000.0, # ms
neurons=ce.LIF(), # or list of classes + class_of=
stimuli=[ce.Poisson(ids, rate_hz=150, weight=68.75, target="v")],
silenced=[...], # spike, but do not transmit
probes=[12, 99], # record v and g traces
seed=1,
)
result.spike_times, result.spike_ids # ms, neuron index
result.rates # Hz per neuron
result.probe_v # [samples, probes], mV# Parallel trial batch sharing one immutable connectome across all cores
trials = net.run_trials(1000.0, 30, stimuli=..., threads=0)
rates = ce.mean_rates(trials)
from cleftengine import flywire
# Reproduce Shiu et al. (2024) on FlyWire FAFB v783
fly = flywire.load(
"data/flywire/Connectivity_783.parquet",
"data/flywire/Completeness_783.csv",
)
sugar = fly.index(flywire.SUGAR_GRNS, missing="skip")
trials = fly.run(sugar, trials=30, r_poi=150.0, silence=[...])
# Nothing in CleftEngine is specific to Drosophila:# load structural synaptic weights from Weightome (weightome.com)# and pass (pre, post, weight_mv) directly into ce.Network(...).
# Requirements: C++20 compiler + make; Python >= 3.10 with NumPy
make # builds float32 & float64 shared libs
pip install -e . # optional; or add python/ to PYTHONPATH# Portable x86-64-v3 build (default ARCH=native tunes for the build host)
make ARCH=x86-64-v3
# Run the 46-test validation suite (Brian2 tests auto-skip if Brian2 absent)
make test PYTHON=python3
# Optional: fetch Shiu et al. FlyWire connectivity tables (~100 MB)
scripts/fetch_flywire.sh && pip install pyarrow
Zero External Dependencies
Core engine compiles cleanly with GCC/Clang in C++20 mode. The Python wrapper uses ctypes and NumPy — no PyTorch, CUDA, or build-time codegen required.
Precision Selection
precision="float32" is the default for speed; precision="float64" selects the double-precision build for bit-tight comparisons against reference simulators.
Built for Weightome
Designed alongside Weightome so structural synaptic weights measured from 8 nm 3D electron microscopy can be simulated directly at whole-brain scale.
06 / Licensing, Provenance & References
CleftEngine is part of Cleft Labs, an independent, privately funded research initiative dedicated to reproducible computational neuroscience and whole-brain emulation.
The CleftEngine source code is dual-licensed under AGPL-3.0-only OR PolyForm-Small-Business-1.0.0. You may use, modify, and distribute the software under either license at your option:
Open Research & Copyleft
AGPL-3.0-only
Free software with network copyleft. Academic, open-source, and derived works (including network services) are shared under the same license.
Small Business & Startups
PolyForm Small Business 1.0.0
Use without copyleft obligations for organizations with fewer than 100 people and under $1,000,000 USD (2019, CPI-adjusted) prior-year revenue.
For commercial enterprise use outside those terms, contact kontakt@cleftlabs.com. Consistent with Cleft Labs' charter, 100% of net proceeds from commercial licenses are reinvested into open connectomics compute, storage, and public research. The software license applies strictly to CleftEngine code and not to external connectome datasets (such as FlyWire FAFB v783).
2024Shiu, P. K., Sterne, G. R., Spiller, N. et al. A Drosophila computational brain model reveals sensorimotor processing. Nature, 634, 210–219.
2024Dorkenwald, S., Matsliah, A., Yu, S. C. et al. Neuronal wiring diagram of an adult brain (FlyWire FAFB v783). Nature, 634, 124–138.
2019Stimberg, M., Brette, R., Goodman, D. F. M. Brian 2, an intuitive and efficient neural simulator. eLife, 8, e47314.
1999Rotter, S., Diesmann, M. Exact digital simulation of time-invariant linear systems with applications to neuronal modeling. Biol. Cybern., 81, 381–402.
2007Brette, R., Rudolph, M., Carnevale, T. et al. Simulation of networks of spiking neurons: a review of tools and strategies. J. Comput. Neurosci., 23, 349–398.