Open-source FPGA-ML codesign for the MLPerf Tiny Benchmark

Hendrik Borras, Giuseppe Di Guglielmo, Javier Duarte, Nicolò Ghielmetti, Ben Hawks, Scott Hauck, Shih-Chieh Hsu, Ryan Kastner, Jason Liang, Andres Meza, Jules Muhizi, Tai Nguyen, Rushil Roy, Nhan Tran, Yaman Umuroglu, Olivia Weng, Aidan Yokuda, Michaela Blott

TL;DR

This paper demonstrates how open-source toolchains like hls4ml and FINN can democratize the deployment of ultra-efficient machine learning on FPGAs. By leveraging hardware-software codesign and extreme quantization, the authors achieved record-breaking latencies as low as 17–20 µs and energy consumption as low as 30 µJ per inference for the MLPerf™ Tiny benchmark.

What Problem Does This Paper Address?

Deploying machine learning at the "edge"—near sensors in IoT devices or industrial robots—requires extreme efficiency. While microcontrollers are the traditional choice for TinyML, Field-Programmable Gate Arrays (FPGAs) offer unique advantages: they allow for massive parallelism and custom bit-precision tailored to a specific model.

However, the barrier to entry for FPGA development is notoriously high, often requiring specialized hardware description languages (HDL). This paper addresses the gap between high-level ML research and low-level hardware implementation by showcasing a fully open-source, automated workflow that optimizes neural networks specifically for FPGA architectures.

Methods

The authors utilized two primary open-source workflows:

  • hls4ml: A tool that converts neural networks into High-Level Synthesis (HLS) C++ code, which is then synthesized into FPGA logic.
  • FINN: A framework from AMD/Xilinx specifically designed for highly quantized neural networks (including Binarized Neural Networks).

A critical contribution of this work is the use of QONNX, a common interchange format that allows models trained in different libraries (like QKeras or Brevitas) to flow seamlessly into either hardware toolchain.

Figure 1. Common hls4ml-FINN FPGA codesign workflow based on QONNX.

Key optimization techniques included:

  • Neural Architecture Search (NAS): Using Bayesian Optimization (via KerasTuner) and ASHA (via Determined AI) to find the best trade-off between model accuracy and hardware "cost" (FLOPs or Bit-Operations).
  • Quantization-Aware Training (QAT): Training models with reduced precision (from 12-bit down to 1-bit) to minimize memory and logic usage.
  • Hardware-Specific Tuning: Automated FIFO buffer depth optimization and "layer fusion" (merging ReLU activations into preceding layers) to drastically reduce resource consumption on the chip.

Datasets

The models were evaluated on standard MLPerf Tiny tasks:

  • Image Classification (IC): CIFAR-10 dataset (32x32 RGB images).
  • Anomaly Detection (AD): DCASE 2020 Challenge Task 2 (ToyADMOS ToyCar audio).
  • Keyword Spotting (KWS): Google Speech Commands V2 (12-class variant).

Key Insights and Ideas

  • Spatial Dataflow is King: Unlike CPUs/GPUs that move data in and out of a central processor, FPGAs allow for "spatial dataflow" architectures. The hardware is configured to resemble the neural network itself, allowing data to stream through layers with minimal movement and latency.
  • Extreme Quantization Works: The FINN implementation for image classification used 1-bit weights and activations. Despite this radical compression, it achieved 84.5% accuracy, proving that for many edge tasks, high precision is unnecessary overhead.
  • The Pareto Frontier: The authors used automated scans to map the "Pareto-optimal" front, identifying models that offer the best accuracy for a given hardware budget. Figure 4 illustrates this for Keyword Spotting, showing how accuracy drops off sharply only when moving below 3-bit quantization.
Figure 4. Quantization exploration for keyword spotting. Each data point is annotated with its weight and activation bit width, in the following schema: WnAm, with n the weight bit width and m the activation bit width. Additionally, floating point data points are annotated with FP. The model accuracy on the validation dataset is shown on as a function of the network complexity quantified by BOPs.

Key Results

The team submitted results for both a System-on-Chip (Pynq-Z2) and a pure FPGA (Arty A7-100T).

Table 1. Summary of models submitted for the v0.7 benchmark.
  • Ultra-Low Latency: The Anomaly Detection and Keyword Spotting models achieved latencies of 17–19 µs on the Pynq-Z2.
  • Energy Efficiency: The Anomaly Detection model consumed only 30.1 µJ per inference.
  • Competitive Accuracy: Despite the heavy optimizations, accuracies remained high (e.g., 84.5% for IC and 82.5% for KWS), comparable to the benchmark's reference models.

Limitations and Future Work

The authors noted a significant bottleneck in their hls4ml image classification model. Because the input image was iterated over sequentially, the latency was 18.2 times higher than the FINN version. Future work will focus on more efficient pipelining to bring these latencies down.

Additionally, while the workflows are largely automated, they still require some manual integration. The authors aim to further formalize these into end-to-end "push-button" workflows, potentially integrating with tools like Sherlock for even more advanced design space exploration.

Summary updated

BibTeX
@misc{borras2022open,
  author = {Hendrik Borras and Giuseppe Di Guglielmo and Javier Duarte and Nicolò Ghielmetti and Ben Hawks and Scott Hauck and Shih-Chieh Hsu and Ryan Kastner and Jason Liang and Andres Meza and Jules Muhizi and Tai Nguyen and Rushil Roy and Nhan Tran and Yaman Umuroglu and Olivia Weng and Aidan Yokuda and Michaela Blott},
  title = {{Open-source FPGA-ML codesign for the MLPerf Tiny Benchmark}},
  year = {2022},
  eprint = {2206.11791},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2206.11791},
}
Figure