Accelerating spiking neural network simulations with PymoNNto and PymoNNtorch

Marius N. Vieth, Ali Rahimi, Ashena Gorgan Mohammadi, Jochen Triesch, Mohammad GanjtabeshFrontiers Neuroinformatics 2024

Introduction

Simulating the brain's complex dynamics through Spiking Neural Networks (SNNs) is computationally intensive. These networks mimic biological communication via discrete pulses, requiring high-performance computing to scale. Historically, researchers have been forced to choose between flexible but slow Python-based tools and fast but rigid C++ or CUDA-based simulators. To bridge this gap, the authors introduced PymoNNtorch, a framework that utilizes PyTorch’s GPU acceleration within a modular "plug-and-play" architecture. By combining clever tensor optimization with a user-friendly interface, the tool can outperform established simulators like NEST and Brian 2 by up to 66x in large-scale scenarios.

Methods and Architecture

PymoNNtorch evolves from the earlier PymoNNto toolbox by replacing the NumPy backend with PyTorch. This transition allows for seamless execution on GPUs without requiring users to write low-level CUDA code.

Modular "Behavior" System

The core of the framework is its modularity. Instead of a hard-coded simulation loop, PymoNNtorch uses a "Behavior" system. Users define small, independent classes for specific biological processes—such as spike generation, voltage adjustment, or Spike-Timing-Dependent Plasticity (STDP)—and attach them to neuron groups.

UML class diagram of the PymoNNtorch architecture, highlighting the modular 'Behavior' system.

This design allows for high flexibility, enabling researchers to easily swap or modify components of their models without sacrificing performance.

Schematic of the behavior-based simulation loop and step-by-step execution.

Optimization Techniques

Beyond the backend switch, the authors implemented several critical optimization strategies:

  • Sparse Indexing: Utilizing functions like torch.where to update only the synaptic weights of active neurons, avoiding costly full-matrix operations.
  • Memory Alignment: By transposing weight matrices from a destination-source ($D \times S$) format to a source-destination ($S \times D$) format, the framework ensures contiguous memory access, which can result in up to a 38-fold speedup.
  • Precision Tuning: The framework supports 16-bit and 32-bit floating-point numbers, offering significant speed gains with minimal impact on biological accuracy compared to standard 64-bit precision.

Performance Benchmarking

The framework was evaluated using standard SNN models, including Leaky Integrate-and-Fire (LIF) neurons with one-step STDP and Izhikevich neurons with trace-based STDP. Benchmarks were conducted against established simulators such as NEST, Brian 2, and ANNarchy.

Key Results

  • Scalability: While PymoNNtorch incurs overhead for small networks (under 1,000 neurons) due to GPU kernel launches, it demonstrates exponential speedups as network size increases.
  • Large-Scale Dominance: In simulations with over 10,000 neurons, PymoNNtorch on a GPU outperformed NEST by 39x and showed a 61% speed increase over Brian 2’s GPU implementation in complex benchmarks.
  • CPU Efficiency: Even on CPUs, optimized indexing allowed PymoNNtorch to outperform the CPU version of ANNarchy by 5.5x in specific tasks.

Discussion and Future Work

PymoNNtorch successfully demonstrates that modular, object-oriented design does not have to compromise performance. However, the framework is in its early stages and currently lacks some high-level features of the original PymoNNto, such as a graphical user interface. Future development aims to unify PymoNNto and PymoNNtorch into a single codebase that automatically selects the optimal backend (NumPy or PyTorch) based on the available hardware and the specific requirements of the simulation.

Summary updated

BibTeX
@article{vieth2024accelerating,
  author = {Marius N. Vieth and Ali Rahimi and Ashena Gorgan Mohammadi and Jochen Triesch and Mohammad Ganjtabesh},
  title = {{Accelerating spiking neural network simulations with PymoNNto and PymoNNtorch}},
  journal = {Frontiers Neuroinformatics},
  year = {2024},
  doi = {10.3389/fninf.2024.1331220},
}
Figure