Skip to main content

brainspike logo

Supported Python Version LICENSE Documentation PyPI version Continuous Integration

brainspike is the point-neuron spiking-network layer of the BrainX ecosystem: building, simulating, and training spiking neural networks of point neurons. A new kernel language unifies how models are built, how they are simulated, and how they are trained. It is built on JAX and brainstate.

brainspike provides:

  • NEST-compatible models — JAX re-implementations of NEST simulator neurons, synapses, plasticity (STDP, STP), and devices that preserve NEST's parameter names and unit conventions, numerically validated against a live NEST install within documented tolerance bands, driven through a NEST-style Simulator (create / connect / simulate).
  • A unified kernel (in development, still private) — one Network graph (populations, projections, devices, observers) over models with written contracts (declared ports, states, parameters, and spike rules), so the graph a simulation runs is the graph a learner trains (architecture spec, roadmap).

All parameters carry physical units via brainunit, catching unit errors at construction time.

Key features

  • NEST parameter parity — port models from NEST with minimal friction; every model carries live-NEST parity evidence within documented tolerance bands.
  • Physical units everywhere — parameters use brainunit quantities (mV, ms, nS, …), preventing unit errors at construction time.
  • One graph for simulation and learning — the new kernel compiles the same Network for simulation and for gradient-based or online learning.
  • Hardware-accelerated — JAX backend with JIT compilation for CPU, GPU, and TPU.

Scope

brainspike is for computational neuroscientists who want NEST models on GPU/TPU or want to train them, and for brain-inspired-computing researchers who need biologically constrained spiking networks.

  • Model scope: point neurons only (no multi-compartment or population/mean-field models) and no single-unit rate neurons.
  • Out of scope: detailed multi-compartment morphology, MPI cluster-scale simulation (single-host multi-device is in scope), MUSIC/SONATA co-simulation (SONATA import is in scope), and e-prop (see braintrace).

Kernel redesign in progress. The first kernel milestones have passed their go/no-go gates; the new kernel is still private. Meanwhile the current NEST-style Simulator API shown below is frozen (it keeps working; no new features or fixes) and will become a thin layer over the kernel's Network. CPU performance of the new kernel has been measured on one benchmark; GPU performance has not been measured yet.

See Positioning and scope.

Installation

brainspike requires Python ≥ 3.11 and runs on Linux, macOS, and Windows.

pip install brainspikes -U

The PyPI distribution is named brainspikes; the package is imported as import brainspike.

For hardware-specific JAX backends:

pip install brainspikes[cpu] -U     # CPU only
pip install brainspikes[cuda12] -U  # CUDA 12.x
pip install brainspikes[cuda13] -U  # CUDA 13.x
pip install brainspikes[tpu] -U     # TPU

Or install the full BrainX ecosystem:

pip install BrainX -U

Quickstart

A single iaf_psc_alpha driven by a constant current I_e and observed by a voltmeter (connected in the reversed direction, as in NEST):

import jax
import brainstate
import brainunit as u
import brainspike

jax.config.update("jax_enable_x64", True)   # NEST-parity runs use float64
brainstate.environ.set(precision=64)

sim = brainspike.Simulator(dt=0.1 * u.ms)
neuron = sim.create(brainspike.iaf_psc_alpha, 1, I_e=376.0 * u.pA)
vm = sim.create(brainspike.voltmeter)
sim.connect(vm, neuron)              # reversed: the voltmeter observes the neuron

res = sim.simulate(1000.0 * u.ms)
v_m = res.trace(vm, "V_m")           # membrane potential trace (with units)

See examples/nest_like/one_neuron.py for the full version with plotting, and the NEST-compatible hub for the tutorials, model directory, and validation evidence.

Documentation

Full documentation: https://brainx.chaobrain.com/brainspike/

Examples

Runnable NEST-compatible ports live in examples/nest_like/ and are catalogued in the NEST gallery. Highlights: Brunel random balanced networks, gap-junction networks, astrocyte networks, and STDP / STP plasticity demos.

Contributing

Contributions are welcome. Please read CONTRIBUTING.md for the development setup, coding conventions, testing guidance, and documentation workflow (including how to document new APIs and how to record live-NEST validation/parity evidence for NEST-compatible models).

Ecosystem

brainspike is one part of the BrainX ecosystem:

Package Description
brainstate State management for JAX-based brain modeling
brainunit Physical units for neuroscience
brainevent Event-driven sparse operators
braintools Surrogate gradients, analysis, and utilities
braintrace Linear-memory online learning for spiking networks

Citing

If you use brainspike, please consider citing the following:

@article {10.7554/eLife.86365,
    article_type = {journal},
    title = {BrainPy, a flexible, integrative, efficient, and extensible framework for general-purpose brain dynamics programming},
    author = {Wang, Chaoming and Zhang, Tianqiu and Chen, Xiaoyu and He, Sichao and Li, Shangyang and Wu, Si},
    editor = {Stimberg, Marcel},
    volume = 12,
    year = 2023,
    month = {dec},
    pub_date = {2023-12-22},
    pages = {e86365},
    citation = {eLife 2023;12:e86365},
    doi = {10.7554/eLife.86365},
    url = {https://doi.org/10.7554/eLife.86365},
    journal = {eLife},
    issn = {2050-084X},
    publisher = {eLife Sciences Publications, Ltd},
}

@inproceedings{wang2024a,
    title={A differentiable brain simulator bridging brain simulation and brain-inspired computing},
    author={Chaoming Wang and Tianqiu Zhang and Sichao He and Hongyaoxing Gu and Shangyang Li and Si Wu},
    booktitle={The Twelfth International Conference on Learning Representations},
    year={2024},
    url={https://openreview.net/forum?id=AU2gS9ut61}
}

License

brainspike is released under the Apache License 2.0. See LICENSE for the full text.

Metadata

Release files for brainspikes 0.2.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 brainspikes 0.2.0
File Size Uploaded Provenance Actions
brainspikes-0.2.0.tar.gz 2.0 MB Without provenance Details for brainspikes-0.2.0.tar.gz

Built distribution (wheel)

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

Total release size: 4.5 MB

Release files / brainspikes-0.2.0.tar.gz

Download URL brainspikes-0.2.0.tar.gz
Size 2.0 MB
Tags Source
SHA-256 checksum
How to use checksums
3918daa9d855852feec785c6e47a47aa1eb22e6169681e33e215fb6232913111
BLAKE2b-256 checksum
How to use checksums
7ca83546d67f57b0844850d002f694c34c21eb5cfc7220e8d5ddd8a944411130
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.11

Release files / brainspikes-0.2.0-py3-none-any.whl

Download URL brainspikes-0.2.0-py3-none-any.whl
Size 2.5 MB
Tags Python 3
SHA-256 checksum
How to use checksums
eee3c6c463179e544a5b6873447b8563fb850f49927beb979a02783e8d151fce
BLAKE2b-256 checksum
How to use checksums
dd137aa36d367fc43f47ffc8ceff6ca804ebb8fe923670cdf4af904a0a048eea
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.11

Security for brainspikes 0.2.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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

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.

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files No provenance

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