Resource utilization and Latency Estimation for ML on FPGA
Project description
rule4ml: Resource Utilization and Latency Estimation for ML
rule4ml
is a tool designed for pre-synthesis estimation of FPGA resource utilization and inference latency for machine learning models.
Installation
rule4ml
can be installed using the provided setup.py
. A package will soon be available on the Python Package Index for easier installation via pip
directly.
git clone git@github.com:IMPETUS-UdeS/rule4ml.git
cd rule4ml
pip install ./
This will only install the base package and its dependencies. The dependencies for the data_gen scripts, used for generating synthetic data, need to be installed separately. These dependencies are listed in requirements.txt.
Getting Started
Tutorial
To get started with rule4ml
, refer to the detailed Jupyter Notebook tutorial. This tutorial covers:
- Using pre-trained estimators for resources and latency predictions.
- Generating synthetic datasets.
- Training your own predictors.
Usage
Here's a quick example of how to use rule4ml
to estimate resources and latency for a given model:
import keras
from keras.layers import Input, Dense, Activation
from rule4ml.models.estimators import MultiModelEstimator
# Example of a simple keras Model
input_size = 16
inputs = Input(shape=(input_size,))
x = Dense(32, activation="relu")(inputs)
x = Dense(32, activation="relu")(x)
x = Dense(32, activation="relu")(x)
outputs = Dense(5, activation="softmax")(x)
model_to_predict = keras.Model(inputs=inputs, outputs=outputs, name="Jet Classifier")
model_to_predict.build((None, input_size))
# Loading default predictors
estimator = MultiModelEstimator()
estimator.load_default_models()
# Predictions are formatted as a pandas DataFrame
prediction_df = estimator.predict(model_to_predict)
# Outside of Jupyter notebooks, we recommend saving the DataFrame as HTML for better readability
prediction_df.to_html("keras_example.html")
Datasets
Training accurate predictors requires large datasets of synthesized neural networks. We used hls4ml to synthesize neural networks generated with parameters randomly sampled from predefined ranges. The data our models were trained on can be found at https://borealisdata.ca/dataverse/rule4ml.
Limitations
In their current iteration, the predictors can process Keras or PyTorch models to generate FPGA resources (BRAM, DSP, FF, LUT) and latency (Clock Cycles) estimations for various synthesis configurations. However, the training models are limited to specific layers: Dense/Linear, ReLU, Tanh, Sigmoid, Softmax, BatchNorm, Add, Concatenate, and Dropout. They are also constrained by synthesis parameters, notably clock_period (10 ns) and io_type (io_parallel). Inputs outside these configurations may result in inaccurate predictions.
License
This project is licensed under the GPL-3.0 License. See the LICENSE file for details.
Project details
Release history Release notifications | RSS feed
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
File details
Details for the file rule4ml_test-0.1.6.tar.gz
.
File metadata
- Download URL: rule4ml_test-0.1.6.tar.gz
- Upload date:
- Size: 2.3 MB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.0 CPython/3.12.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b810b89ea057d8e334ddff80b7b2936d187e007a709152d254441008adfce3fd |
|
MD5 | 2ed834383d781f1101c061c69ee4199d |
|
BLAKE2b-256 | b3c955af2cccb04a7b31103e5c65fe0826b4c49ae7cf06dbcba93dd2349a184c |
File details
Details for the file rule4ml_test-0.1.6-py3-none-any.whl
.
File metadata
- Download URL: rule4ml_test-0.1.6-py3-none-any.whl
- Upload date:
- Size: 2.3 MB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.0 CPython/3.12.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ce7cd605218ff2c34c5b850dfb17b368daa702269f05b4151c7ce7f30e787f82 |
|
MD5 | 0bbca7e781a2d6d25b99407800d7550e |
|
BLAKE2b-256 | af009eaef95899577e30b5f2834349634670215a3abde2effee59d4cfed6d5bb |