First Spiking Neural Network Library for MLX Released
A developer has released mlx-snn, the first Spiking Neural Network (SNN) library for Apple's MLX framework, designed for neuromorphic computing research. The library reportedly outperforms PyTorch alternatives by 2-10x on an M3 Max in both speed and memory usage, supporting models like LIF/IF neurons and BPTT training.
Apple's MLX, an open-source framework, is specifically engineered for its silicon, leveraging a unified memory architecture to eliminate data transfer delays between the CPU and GPU. This design allows arrays to exist in a shared memory space, accessible by any supported device, which is a key differentiator from other frameworks. mlx-snn is the first library to bring Spiking Neural Networks to this native Apple hardware environment, a space previously dominated by PyTorch-based libraries like snnTorch and SpikingJelly. Spiking Neural Networks represent a "third generation" of neural networks that more closely mimic biological brain function by processing information through discrete spike events rather than continuous activations. This event-driven computation is not only a closer model of how neurons work but also offers potential for significant energy savings, a critical factor for on-device AI. Their compatibility with neuromorphic hardware, which processes and stores information at the same location, opens doors for highly efficient, low-latency applications. The mlx-snn library provides researchers on Apple Silicon with a comprehensive toolkit, including six neuron models like Leaky Integrate-and-Fire (LIF) and Izhikevich, four surrogate gradient functions for training, and four methods for encoding data into spikes. This is a notable step as previous SNN frameworks required custom backends or were built on PyTorch, leaving a gap for native performance on Apple's architecture. The library is open-source under an MIT license and available on PyPI for developers. Training for SNNs in mlx-snn utilizes Backpropagation Through Time (BPTT), an algorithm adapted from Recurrent Neural Networks that accounts for the temporal, stateful nature of spiking neurons. Because the precise timing of spikes holds information, BPTT unfolds the network's operations over time to calculate gradients, a computationally intensive but precise method. The non-differentiable nature of a spike event is handled using surrogate gradients, a necessary approximation to enable training.