Efficient convolution for sparse data on FPGAs
Project description
SparsePixels: Efficient convolution for sparse data on FPGAs
Note: We are actively working on hls4ml integration to auto-convert sparse models to HLS, along with a major upgrade with partial parallelization and streaming for sparse layers in HLS. Stay tuned!
Installation
With Python >= 3.10:
pip install sparsepixels
Getting Started
Import sparse layers and quantization library (HGQ2):
import keras
from keras.layers import Flatten, Activation
from hgq.layers import QConv2D, QDense
from hgq.config import QuantizerConfigScope, LayerConfigScope
from sparsepixels.layers import InputReduce, QConv2DSparse, AveragePooling2DSparse
Build an example sparse CNN within HGQ2 quantization scopes. For sparse models, input
quantization and eBOPs are disabled for now (enable_iq=False, enable_ebops=False) because the input
quantizer's internal regularizer degrades precision too fast for sparse data's weak gradient
signal to counteract (we will fix that in future release soon).
with (
QuantizerConfigScope(place='all', default_q_type='kbi', overflow_mode='SAT_SYM'),
QuantizerConfigScope(place='datalane', default_q_type='kif', overflow_mode='WRAP'),
LayerConfigScope(enable_ebops=False, enable_iq=False), # for now and can be enabled after fix soon
):
x_in = keras.Input(shape=(28, 28, 1), name='x_in')
# Sparse input reduction: retain up to n_max_pixels active pixels
x, keep_mask = InputReduce(n_max_pixels=20, threshold=0.1, name='input_reduce')(x_in)
# Sparse convolution
x = QConv2DSparse(filters=3, kernel_size=3, name='conv1', padding='same', strides=1,
activation='relu')([x, keep_mask])
# Sparse pooling
x, keep_mask = AveragePooling2DSparse(2, name='pool1')([x, keep_mask])
x = Flatten(name='flatten')(x)
x = QDense(10, name='dense1', activation='relu')(x)
x = Activation('softmax', name='softmax')(x)
model = keras.Model(x_in, x)
We are working on hls4ml integration that auto parses the sparse layers into HLS.
Documentation
Citation
If you find this useful in your research, please consider citing:
@article{Tsoi:2025nvg,
author = "Tsoi, Ho Fung and Rankin, Dylan and Loncar, Vladimir and Harris, Philip",
title = "{SparsePixels: Efficient Convolution for Sparse Data on FPGAs}",
eprint = "2512.06208",
archivePrefix = "arXiv",
primaryClass = "cs.AR",
month = "12",
year = "2025"
}
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file sparsepixels-0.2.2.tar.gz.
File metadata
- Download URL: sparsepixels-0.2.2.tar.gz
- Upload date:
- Size: 84.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9f591d7af2b3fc2369c6f6066d76b7dd7d37e748f7f5208ed5f996fc2296d728
|
|
| MD5 |
032e90df1823f88f77d06e1f19cb4a3d
|
|
| BLAKE2b-256 |
8a9ca7ef0b9657b38274131124c8c7e86d0b1ea9fc3e792f9d2406ef7a27132b
|
Provenance
The following attestation bundles were made for sparsepixels-0.2.2.tar.gz:
Publisher:
publish.yml on hftsoi/sparse-pixels
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
sparsepixels-0.2.2.tar.gz -
Subject digest:
9f591d7af2b3fc2369c6f6066d76b7dd7d37e748f7f5208ed5f996fc2296d728 - Sigstore transparency entry: 1136311102
- Sigstore integration time:
-
Permalink:
hftsoi/sparse-pixels@13d04e164c212028030a502cf5c8bae1dbf10edd -
Branch / Tag:
refs/tags/v0.2.2 - Owner: https://github.com/hftsoi
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@13d04e164c212028030a502cf5c8bae1dbf10edd -
Trigger Event:
release
-
Statement type:
File details
Details for the file sparsepixels-0.2.2-py3-none-any.whl.
File metadata
- Download URL: sparsepixels-0.2.2-py3-none-any.whl
- Upload date:
- Size: 81.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9c9c73ae63dc7bca514d22c2ee1a55a7923b514b6644522824c64dbb26f88a58
|
|
| MD5 |
3dde72160396557c6d98f36d792d31d4
|
|
| BLAKE2b-256 |
5088a35e8f1eef7c53277cc5bd2e6b4cc416f72fc721aae92a07e347665db475
|
Provenance
The following attestation bundles were made for sparsepixels-0.2.2-py3-none-any.whl:
Publisher:
publish.yml on hftsoi/sparse-pixels
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
sparsepixels-0.2.2-py3-none-any.whl -
Subject digest:
9c9c73ae63dc7bca514d22c2ee1a55a7923b514b6644522824c64dbb26f88a58 - Sigstore transparency entry: 1136311205
- Sigstore integration time:
-
Permalink:
hftsoi/sparse-pixels@13d04e164c212028030a502cf5c8bae1dbf10edd -
Branch / Tag:
refs/tags/v0.2.2 - Owner: https://github.com/hftsoi
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@13d04e164c212028030a502cf5c8bae1dbf10edd -
Trigger Event:
release
-
Statement type: