A differentiable brain simulator bridging brain simulation and brain-inspired computing

Chaoming Wang, Tianqiu Zhang, Sichao He, Hongyaoxing Gu, Shangyang Li, Si Wu

Historically, researchers studying the brain have been split into two distinct camps. The Brain Simulation community builds high-fidelity models using tools like NEURON or Brian2 to mimic biophysical details such as ion channels and synaptic delays. However, these traditional simulators are not "differentiable," meaning they cannot be easily trained using backpropagation.

Conversely, the Brain-Inspired Computing (BIC) community uses deep learning frameworks like PyTorch or JAX to build Spiking Neural Networks (SNNs). While these models are easy to train, they often lack biophysical realism and struggle to efficiently handle the memory-intensive, sparse, and event-driven nature of real brain dynamics.

To address this divide, researchers have introduced BrainPy, a new framework built on JAX that bridges the gap between high-fidelity brain simulation and brain-inspired computing. By introducing specialized event-driven operators and object-oriented just-in-time (JIT) compilation, BrainPy allows researchers to train biologically realistic, multi-scale neural models using the same gradient-based optimization tools that power modern AI.

The BrainPy Architecture

BrainPy is built on top of JAX and XLA, inheriting their high-performance hardware acceleration across CPUs, GPUs, and TPUs. However, it introduces several novel architectural choices specifically tailored for neuro-computational modeling:

BrainPy Architecture Overview
  • Dedicated Event-Driven Operators: Standard deep learning operators process dense tensors, which is highly inefficient for sparse biological networks where most neurons are silent at any given time. BrainPy introduces operators (like csrmv) that only perform computations when a neuron actually spikes, leading to massive speedups.
  • JIT Connectivity: Simulating the human brain's trillions of synapses typically requires terabytes of memory just to store the connectivity matrix. BrainPy uses "Just-In-Time" connectivity, regenerating synaptic parameters on the fly during the simulation to maintain a near-zero memory footprint.
  • Decoupled Dynamics and Communication: The framework separates the internal state equations of a neuron from its communication method. This modularity allows researchers to seamlessly swap out standard biological synapses for deep learning components like convolutions or linear transformations.
  • Object-Oriented JIT (OO-JIT): While JAX is natively functional, this paradigm can be unintuitive for neuroscientists accustomed to modeling discrete "objects" (like specific neuron groups or brain regions). BrainPy provides a Pythonic, object-oriented interface that automatically transforms into JAX-compatible functional code under the hood.

Key Insights and Innovations

BrainPy's design yields several critical advantages for both simulation and training:

  • Efficiency through Sparsity: By tailoring operators to the event-driven nature of spiking neurons, BrainPy achieves speedups of two to five orders of magnitude over standard dense operators.
  • Overcoming Memory Bottlenecks: For large-scale brain models, memory storage for synapses is the primary limiting factor. BrainPy's JIT connectivity approach allows a single GPU to simulate networks with over 4 million neurons—a scale previously reserved for massive supercomputer clusters.
  • The "Differentiable Biology" Advantage: By making biophysical models fully differentiable, the authors successfully trained a Generalized Leaky Integrate-and-Fire (GIF) model—fitted to real monkey prefrontal cortex data—to solve a Delayed Match-to-Sample (DMS) working memory task. This proves that AI optimization techniques can be used to find parameters for biologically plausible cognitive models.

Performance and Benchmarks

The authors evaluated BrainPy across a diverse set of benchmarks, including simulation tasks (COBA-LIF and COBA-HH networks), BIC tasks (action recognition on the KTH dataset, image classification on MNIST/Fashion-MNIST), and biological cognitive tasks.

GPU Speed Comparison
  • Speed: BrainPy consistently outperformed mainstream simulators like NEST, Brian2, and BindsNet, particularly as network complexity increased.
  • Scalability: The framework demonstrated linear scaling of memory and time. For a complex multi-area model comprising 30 distinct brain regions, BrainPy’s compilation was over 1,000x faster than Brian2 (taking seconds instead of over an hour).
  • Training Performance: On SNN training tasks (such as VGG-SNN on Fashion-MNIST), BrainPy was roughly twice as fast as specialized spiking libraries like SpikingJelly or snnTorch on GPU hardware.

Limitations and Future Work

While BrainPy supports distributed computing via JAX’s pjit, the authors note a significant ongoing challenge: communication overhead. In spiking networks, gathering and broadcasting sparse spikes across multiple devices can be inefficient because standard communication protocols are optimized for dense data tensors.

Future work will focus on developing "spike-specific" synchronization schemes—such as compressing spike data or exclusively communicating non-zero events—to unlock even greater scalability for distributed, brain-scale simulations.

Summary updated

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