Hands-on With SnnTorch

snnTorch applies surrogate gradients to overcome the non-differentiability of spikes, enabling SNN training and quantization using standard PyTorch pipelines.

Integrating neuromorphic computing into mainstream machine learning workflows requires tools that leverage existing deep learning ecosystems. In this workshop, snnTorch is utilized to bridge the gap between traditional PyTorch environments and the unique temporal dynamics of Spiking Neural Networks (SNNs). By introducing surrogate gradient descent, the framework enables the application of standard backpropagation to non-differentiable spiking units, making it straightforward to train networks that process highly sparse, time-varying data.

Key Takeaways

  • snnTorch extends PyTorch to support spiking neural networks, utilizing surrogate gradients to bypass the non-differentiability of spikes.
  • LIF neurons can be configured natively alongside standard dense and convolutional PyTorch layers.
  • Advanced models, including spiking recurrent layers and LSTM variants, help capture complex temporal dependencies.
  • Weight and state quantization workflows are explored using Brevitas to prepare models for deployment on edge hardware.

Workshop Format & Takeaways

The session functions as a comprehensive, step-by-step coding tutorial executing entirely within a Google Colab environment. It begins at the foundational level, instantiating a single Leaky Integrate-and-Fire (LIF) neuron to observe its membrane potential dynamics, including exponential relaxation and threshold-based spike generation under continuous input currents.

Moving beyond single neurons, the workshop constructs a full spiking classifier to tackle the MNIST dataset. The standard PyTorch nn.Linear and nn.Conv2d blocks are seamlessly interlaced with snn.leaky nodes. As discussed in the session, addressing the non-differentiability of the active thresholding step is vital; snnTorch accomplishes this by relying on the derivative of the arctangent function by default to estimate gradients during the backward pass. Tonic is subsequently introduced to handle the Poker DVS dataset, demonstrating efficient caching and temporal binning of genuine event-camera data to avoid crippling computational overhead.

To improve performance on complex time-series data, the tutorial explores recurrent SNNs and spiking LSTMs, architectures designed to carry temporal state forward beyond the inherent membrane potential decay. Finally, the session tackles the reality of deploying models to edge silicon, integrating the Brevitas library to quantize both synaptic weights and membrane states down to 8-bit integers, effectively simulating hardware constraints without leaving the Python ecosystem.

What This Means for Neuromorphic Computing

Training SNNs historically required navigating a restrictive and esoteric hyperparameter space disconnected from modern deep learning infrastructure. Frameworks like snnTorch act as a vital translation layer, translating backpropagation concepts into spiking equivalents. By abstracting the complexities of surrogate gradients, multi-timestep unrolling, and thresholding mechanisms, researchers and practitioners can prototype energy-efficient algorithms with the same velocity and API familiarity as traditional Convolutional or Recurrent Neural Networks.

Resources

About the Speakers

Jason Eshraghian

Jason Eshraghian

Assistant Professor at UC Santa Cruz, leading UCSC Neuromorphic Computing Group. Focuses on brain-inspired circuits for AI & SNNs. Maintainer of snnTorch.
Fabrizio Ottati

Fabrizio Ottati

AI/ML Processor Engineer at NXP, PhD from Politecnico di Torino. Focuses on event cameras, digital hardware, and deep learning. Maintains Tonic & Expelliarmus.
Social share preview for Hands-On with snnTorch

Upcoming Workshops

No workshops are currently scheduled. Check back soon for new events!

Are you an expert in a neuromorphic topic? We invite you to share your knowledge with our community.

Inspired? Share your work.

Share your expertise with the community by speaking at a workshop, student talk, or hacking hour. It’s a great way to get feedback and help others learn.

Related Workshops

Project Phasor - Kickoff

Project Phasor - Kickoff

Project Phasor is a community initiative building shared compilers, behavioral virtual machines, and open datasets to scale neuromorphic computing workloads.

Advances in Neuromorphic Visual Place Recognition

Advances in Neuromorphic Visual Place Recognition

Sampling a tiny subset of high-variance event pixels allows robotic visual place recognition systems to successfully operate with low latency and minimal storage.

Hands-On with Nengo Applied Brain Research

Hands-On with Nengo Applied Brain Research

The Neural Engineering Framework and Nengo's core Python objects accurately translate high-level algorithmic intentions into functional spiking neural network models.