Skip to main content

jaxsnn is an event-based approach to machine-learning-inspired training and simulation of SNNs, including support for neuromorphic backends (BrainScaleS-2).

Project description

/ˈdʒæksən/

jaxsnn

jaxsnn (pronounced like Jackson /ˈdʒæksən/) is an event-based approach to machine-learning-inspired training and simulation of SNNs, including support for neuromorphic backends (BrainScaleS-2). We build upon jax, a Python library providing autograd and XLA functionality for high-performance machine learning research.

Installation

We provide a pypi build of the software that lacks support for the BrainScaleS-2 neuromorphic hardware system. The usual pip install jaxsnn stuff should work, but YMMV.

Building the Software

The software builds upon existing libraries, such as jax, optax, and tree-math. When using the neuromorphic BrainScaleS-2 backend, the software stack of the platform is required.

We provide a container image (based on the Apptainer format) including all build-time and runtime dependencies. Feel free to download the most recent version from here.

For all following steps, we assume that the most recent Apptainer container is located at /containers/stable/latest.

Github-based Build

To build this project from public resources, adhere to the following guide:

# 1) Most of the following steps will be executed within a apptainer container
#    To keep the steps clutter-free, we start by defining an alias
shopt -s expand_aliases
alias c="apptainer exec --app dls /containers/stable/latest"

# 2) Prepare a fresh workspace and change directory into it
mkdir workspace && cd workspace

# 3) Fetch a current copy of the symwaf2ic build tool
git clone https://github.com/electronicvisions/waf -b symwaf2ic symwaf2ic

# 4) Build symwaf2ic
c make -C symwaf2ic
ln -s symwaf2ic/waf

# 5) Setup your workspace and clone all dependencies (--clone-depth=1 to skip history)
c ./waf setup --repo-db-url=https://github.com/electronicvisions/projects --project=jaxsnn

# 6) Load PPU cross-compiler toolchain (or build https://github.com/electronicvisions/oppulance)
module load ppu-toolchain

# 7) Build the project
#    Adjust -j1 to your own needs, beware that high parallelism will increase memory consumption!
c ./waf configure
c ./waf build -j1

# 8) Install the project to ./bin and ./lib
c ./waf install

# 9) If you run programs outside waf, you'll need to add ./lib and ./bin to your path specifications
export APPTAINERENV_PREPEND_PATH=`pwd`/bin:$APPTAINERENV_PREPEND_PATH
export APPTAINERENV_LD_LIBRARY_PATH=`pwd`/lib:$APPTAINERENV_LD_LIBRARY_PATH
export PYTHONPATH=`pwd`/lib:$PYTHONPATH
export PYTHONPATH=`pwd`/lib/python3.10/site-packages:$PYTHONPATH

# 10) To validate that your build was successful, execute the following example
python -m jaxsnn.examples.event.yinyang_analytical

Structure

jaxsnn is split into two parts. Training of SNNs is done in the init/apply style.

Time Discrete

jaxsnn.discrete simulates SNNs by treating time in a discrete way. It uses euler steps of a fixed size to advance the network forward in time which draws inspiration from norse.

Time Continuous

jaxsnn.event treats time continously and allows jumping from one event to the next one. Its core functionality consists of the step function, which does three things:

  1. Find the next threshold crossing
  2. Integrate the neuron to this point in time
  3. Apply the discontinuity after the threshold crossing

jaxsnn.event.modules.lif provides the implementation of a CubaLIF neuron which can be used to build larger networks.

BSS-2 Connection

jaxsnn.event.modules.hx provides functionality to connect to the BSS-2 system and to conduct learning experiments on dedicated neuromorphic hardware.

First Steps

We provide multiple examples for usage of jaxsnn.

Time discrete learning using surrogate gradients on the Yin-Yang dataset:

python -m jaxsnn.examples.discrete.yinyang

Event-based two layer feed-forward network with analytical gradients:

python -m jaxsnn.examples.event.yinyang_analytical

Event-based two-layer feed-forward network with gradients computed using the EventProp algorithm:

python -m jaxsnn.examples.event.yinyang_layered_event_prop

Event-based recurrent network with gradients computed using the EventProp algorithm:

python -m jaxsnn.examples.event.yinyang_recurrent_event_prop

BSS-2

If you want to work with the BSS-2 system, a working example is provided:

python -m jaxsnn.examples.event.yinyang_bss2

Acknowledgements

The software in this repository has been developed by staff and students of Heidelberg University as part of the research carried out by the Electronic Visions group at the Kirchhoff-Institute for Physics.

This work has received funding from the EC Horizon 2020 Framework Programme under grant agreements 785907 (HBP SGA2) and 945539 (HBP SGA3), the Deutsche Forschungsgemeinschaft (DFG, German Research Foundation) under Germany's Excellence Strategy EXC 2181/1-390900948 (the Heidelberg STRUCTURES Excellence Cluster), the German Federal Ministry of Education and Research under grant number 16ES1127 as part of the Pilotinnovationswettbewerb Energieeffizientes KI-System, the Helmholtz Association Initiative and Networking Fund [Advanced Computing Architectures (ACA)] under Project SO-092, as well as from the Manfred Stärk Foundation, and the Lautenschläger-Forschungspreis 2018 for Karlheinz Meier.

Licensing

SPDX-License-Identifier: LGPL-2.1-or-later

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

jaxsnn-0.3.0rc1.tar.gz (207.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

jaxsnn-0.3.0rc1-py3-none-any.whl (106.6 kB view details)

Uploaded Python 3

File details

Details for the file jaxsnn-0.3.0rc1.tar.gz.

File metadata

  • Download URL: jaxsnn-0.3.0rc1.tar.gz
  • Upload date:
  • Size: 207.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for jaxsnn-0.3.0rc1.tar.gz
Algorithm Hash digest
SHA256 e42d86f31fdcfcba24197e46df0f488303dafbfac763a6ccf0f8e0947e1bacdb
MD5 227cd6b92e8e3e1c0996c0d8716f90d1
BLAKE2b-256 4977ee618462b93737bab521b00e20a668fd267660be7ed74ba272d02e286e53

See more details on using hashes here.

File details

Details for the file jaxsnn-0.3.0rc1-py3-none-any.whl.

File metadata

  • Download URL: jaxsnn-0.3.0rc1-py3-none-any.whl
  • Upload date:
  • Size: 106.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for jaxsnn-0.3.0rc1-py3-none-any.whl
Algorithm Hash digest
SHA256 b3b55f962532e995c10a9192c5a640eaae280461607abc373fd57ee75fb5f563
MD5 c44d538447354cedd1dffde425911e01
BLAKE2b-256 f6c69c92bb86f26598c97b9e2c598d7dcfbefcd96b82010c4cb69883f1f8e546

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page