Skip to main content

flycns

ci license: MIT

Compile a fly connectome release into a graph a simulator can run, model the two compound eyes over the release's own optic-lobe columns, and simulate the whole central nervous system with the published neuron models, in Python and in the browser, with the two implementations held to each other by parity tests.

  • Release: MaleCNS v1.0, the complete male Drosophila CNS (166,700 neurons, brain and ventral nerve cord; Berg et al., Cell 189:5504-5526, 2026, doi:10.1016/j.cell.2026.08.015; data CC BY 4.0). Both optic lobes are mapped column by column in the release (879 columns left, 892 right), which is what lets two eyes feed it.
  • Neuron models: the published leaky integrate-and-fire model of the fly brain (Shiu et al., Nature 634:210-219, 2024, doi:10.1038/s41586-024-07763-9), and a graded optic lobe in the form of the connectome-constrained visual model (Lappalainen et al., Nature 2024, doi:10.1038/s41586-024-07939-3).
  • Two implementations, one set of equations: a Python reference (NumPy, and PyTorch on a GPU) and a browser engine (@fasl-work/flycns, WebGPU with a worker fallback).

What it is not

A general neural simulator, a learned model of the fly, or a claim about behaviour. Synapse counts and signs are data and never change; the package integrates published equations over them and says where those equations are known to fall short.

Status

Version 0.07.000: the MaleCNS v1.0 compiler and compiled format; the two compound eyes over the release's own columns, their vertical set by the dorsal rim; the published spiking model, identical to a literal Brian2 transcription, on a NumPy reference and a GPU engine; the graded visual neurons as flyvis computes them, held to flyvis itself, with its 50 trained networks shipped as data; and flyvis's numbers transferred onto the neuron-level wiring of both MaleCNS optic lobes, where T4 cells, measured through the modelled eyes, prefer their known directions; and the whole CNS coupled, in four engines (the published model everywhere, which does not see; the graded optic lobes with the spiking CNS, which carries a flash to the motor neurons; flyvis's own networks mapped onto MaleCNS; and the stabilised version, which leaves the published model one state); and the browser engine (@fasl-work/flycns): a CPU engine that reproduces the Python reference spike for spike, the whole CNS included, and WebGPU kernels held to it by the design's tolerances. Next: Destello's scenes, cases and web product. This README lists capabilities only as they land.

Compile MaleCNS v1.0

Download the four tables listed in docs/releases/01_malecns-v1.md into one folder, then:

from pathlib import Path
from flycns.release import compile_malecns_v1
from flycns.compiled import read_compiled

compile_malecns_v1(Path("malecns-tables"), Path("compiled/malecns-v1.0"), progress=print)
graph = read_compiled(Path("compiled/malecns-v1.0"))      # every array verified against its SHA-256
print(graph.n_neurons, graph.n_edges, graph.counts["columns"])

A table whose SHA-256 differs from the locked value is refused. Compilation streams the 13 GB synapse table in record batches and takes a few minutes on a desktop.

Simulate

from pathlib import Path

from flycns.compiled import read_compiled
from flycns.dynamics import Drive, LIFReference, synaptic_weights

graph = read_compiled(Path("compiled/malecns-v1.0"))
weights = synaptic_weights(graph["csr_indptr"], graph["csr_indices"], graph["csr_count"], graph["neuron_sign"], 0.275)
engine = LIFReference(graph["csr_indptr"], graph["csr_indices"], weights)      # or LIFTorch on a GPU
run = engine.run(10_000, Drive(activate={1234: 150.0}), seed=0)                   # one second of model time
print(run.spike_counts().sum(), "spikes")

The graded visual neurons run through flycns.dynamics.GradedReference (or GradedTorch), with the trained flyvis parameters from flycns.flyvis.load_ensemble(); see docs/models/03_graded.md.

Install

pip install flycns              # Python 3.11+; flycns[gpu] adds PyTorch, flycns[release] reads release files
npm install @fasl-work/flycns   # the browser engine: loaders, the CPU engines, WebGPU, the worker

Both are published from this repository's releases: flycns on PyPI through trusted publishing, and @fasl-work/flycns on npm. The browser engine and its measurements are in docs/models/06_browser.md.

Install (development)

python -m venv .venv
.venv/Scripts/python -m pip install -e ".[dev,release,parity]"     # add ,gpu for PyTorch; .venv/bin/python elsewhere
.venv/Scripts/python -m pytest -rs
npm ci && npm test

Documentation

The wiki starts at docs/README.md.

License

Code: MIT. Connectome data are not redistributed here; they are fetched from the release with their hashes checked, and remain under their own licence (MaleCNS: CC BY 4.0). The trained parameters of flyvis's pretrained networks ship inside the package under flyvis's MIT licence, whose notice travels with them (src/flycns/data/flyvis-1.2.0-ensemble/LICENSE-flyvis.txt).

Metadata

Release files for flycns 0.7.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for flycns 0.7.0
File Size Uploaded Provenance Actions
flycns-0.7.0.tar.gz 241.3 kB With provenance Details for flycns-0.7.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for flycns 0.7.0
File Interpreter ABI Platform Actions
flycns-0.7.0-py3-none-any.whl Python 3 none any Details for flycns-0.7.0-py3-none-any.whl

Total release size: 456.9 kB

Release files / flycns-0.7.0.tar.gz

Download URL flycns-0.7.0.tar.gz
Size 241.3 kB
Tags Source
SHA-256 checksum
How to use checksums
147f61cef767cd2dbcc12c59f60e2a99c9649d717801bf8a78d067c65363ce2f
BLAKE2b-256 checksum
How to use checksums
f94c23b9397aa423ba9ee8a463962116559719e53b52eaff384c59b7655fab09
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 Sep 26, 2026.

Transparency log

Release files / flycns-0.7.0-py3-none-any.whl

Download URL flycns-0.7.0-py3-none-any.whl
Size 215.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2a6057aab9653d6ff8ed1736825bbb1008235c6c297ddf56181a80290cc8745d
BLAKE2b-256 checksum
How to use checksums
d4a620654de5de34ba4d89bad25381bf88e54de112027c9687c37379525fe9d7
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 Sep 26, 2026.

Transparency log

Security for flycns 0.7.0

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.

Select from 2 files

Attestation for flycns-0.7.0.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 Sep 26, 2026.

Transparency log

A 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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page