Spike-FINN
Spike-FINN is a framework for training and exporting spiking neural networks (SNNs) to FPGA hardware using the FINN compiler. It provides tools for collecting parameters during the forward pass of a PyTorch model, generating reports, and converting them into HLSLayerConfig objects for use in the export process. The framework includes implementations for Leaky Integrate-and-Fire (LIF) neuron layers, allowing users to design and optimize SNNs for efficient hardware deployment.
Prerequisites
Before you can use Spike-FINN, ensure you have the following dependencies installed:
- A local clone of FINN
- A Vivado installation (tested for 2022.2)
Installation
To install Spike-FINN, you can use the following command:
uv add spike-finn
Project Guide
0. General Idea
Spike-FINN makes use of the FINN framework for accelerating neural networks on FPGA hardware. It replaces the default computation unit with a statefull replacement, that shares all the same APIs. The replacement unit is configured using parameters collected directly from the SNNTorch implementation of the spiking neural network. The framework is intended to be easily extendable to support new hardware strategies and new spiking neuron types, by implementing new ParameterCollector and ParameterReport classes. The default implementation is for Leaky Integrate-and-Fire (LIF) neurons, but the framework can be extended to support other neuron types and hardware configurations.
1. Parameter Collection & Export
To map a spiking neuron layer on hardware, some parameters are required. For the provided LIF example, we need to know the threshold, number of neurons, leakage factor, reset mode and the size of the buffer required to store the membrane potential. These parameters are collected during the forward pass of the model using the LIFParameterCollector, which wraps the spiking activation function. The collected parameters are used to generate a LIFParameterReport, which can be converted into an HLSLayerConfig for use in the export process. The export process involves converting the collected parameters into a format that can be used by the FINN compiler to generate the necessary hardware description for the FPGA. This allows for efficient deployment of the spiking neural network on FPGA hardware, leveraging the performance benefits of custom hardware acceleration.
As a user you need to wrap your spiking activation functions with the parameter collector. E.g like this:
LIFParameterCollector.leaky(
neurons=16,
act=snn.Leaky(
beta=beta,
spike_grad=spike_grad,
init_hidden=False,
reset_mechanism="zero",
learn_threshold=True,
),
)
A provided function then evaluates the network and collects all parameters:
with collect_parameters(net) as reports:
evaluate()
If different strategies should be used, a custom ParameterCollector can be used.
2. Build and Synthesis
The build process involves using the collected parameters to configure the custom
HLS compute units in the FINN framework. Parts of the FINN compiler are overridden
to correctly include custom HLS in the build process. More details can be found
at src/spike_finn/finn/entrypoint.py. Spike-FINN creates a configuration file, that
removes semantic meaning and only contains pre-compiler directives and template parameters
that are passed to the HLS unit. If a custom HLS implementation follows the same
schema to configure the unit, the entrypoint.py file can stay as is.
After configuration the build process is handed over to the FINN compiler, which generates the necessary hardware description for the FPGA.
Metadata
Release files for spike-finn 0.1.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| spike_finn-0.1.3.tar.gz | 116.8 kB | Without provenance | Details for spike_finn-0.1.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| spike_finn-0.1.3-py3-none-any.whl | Python 3 | none | any | Details for spike_finn-0.1.3-py3-none-any.whl |
Total release size: 252.1 kB
Release files / spike_finn-0.1.3.tar.gz
| Download URL | spike_finn-0.1.3.tar.gz |
|---|---|
| Size | 116.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
8a29025ccd03adeca37452f7a7179d69a31c75c8e657509cf2d25aff882a9855
|
|
BLAKE2b-256 checksum How to use checksums |
ae9a81d6fecc73f069d4351a22a778dc840c5d642917e72bdda36350cb5addbd
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.11.15 {"installer":{"name":"uv","version":"0.11.15","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Release files / spike_finn-0.1.3-py3-none-any.whl
| Download URL | spike_finn-0.1.3-py3-none-any.whl |
|---|---|
| Size | 135.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
75bea4fabf9c482f34ddea8e8163187aa2c736ef7875c56ee609a1b8fdd3bdbb
|
|
BLAKE2b-256 checksum How to use checksums |
a2d7c6f9531be739e4bf6dd56b61bc26902a06379c7071fdf332187fcf9386f8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.11.15 {"installer":{"name":"uv","version":"0.11.15","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Security for spike-finn 0.1.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.