Skip to main content

Add your description here

Project description

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.

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

spike_finn-0.1.1.tar.gz (116.5 kB view details)

Uploaded Source

Built Distribution

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

spike_finn-0.1.1-py3-none-any.whl (135.1 kB view details)

Uploaded Python 3

File details

Details for the file spike_finn-0.1.1.tar.gz.

File metadata

  • Download URL: spike_finn-0.1.1.tar.gz
  • Upload date:
  • Size: 116.5 kB
  • Tags: Source
  • Uploaded using 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}

File hashes

Hashes for spike_finn-0.1.1.tar.gz
Algorithm Hash digest
SHA256 523da0f6fdb7ee9d79bbb6f9dfe7f22e238b6e4303eae540ac5fb17849c33a8e
MD5 898ba340a7b8dafa7f36d0a57e9f156d
BLAKE2b-256 95ce1afeab92126c25930a3e7225cd4a2d18b0255c02d11720038ac7c68e1831

See more details on using hashes here.

File details

Details for the file spike_finn-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: spike_finn-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 135.1 kB
  • Tags: Python 3
  • Uploaded using 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}

File hashes

Hashes for spike_finn-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 e686b748575cfe6a3adc91618e49c7ad5c25c409ed6558b481b10de4322e6572
MD5 0653b3ddd074f66ea08283c4c4cb46b3
BLAKE2b-256 28b50cfd3ae30f4f402fe8375dce1b341e9ba954103e01774c67b4a5de05aaae

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