When Monte-Carlo Dropout Meets Multi-Exit: Optimizing Bayesian Neural Networks on FPGA

Fan Hongxiang, Hongxiang Fan, Mark Chen, Liam Castelli, Zhiqiang Que, He Li, Kenneth Long, Wayne Luk

Abstract

Bayesian Neural Networks (BayesNNs) have demonstrated their capability of providing calibrated prediction for safety-critical applications such as medical imaging and autonomous driving. However, the high algorithmic complexity and the poor hardware performance of BayesNNs hinder their deployment in real-life applications. To bridge this gap, this paper proposes a novel multi-exit Monte-Carlo Dropout (MCD)-based BayesNN that achieves well-calibrated predictions with low algorithmic complexity. To further reduce the barrier to adopting BayesNNs, we propose a transformation framework that can generate FPGA-based accelerators for multi-exit MCD-based BayesNNs. Several novel optimization techniques are introduced to improve hardware performance. Our experiments demonstrate that our auto-generated accelerator achieves higher energy efficiency than CPU, GPU, and other state-of-the-art hardware implementations.

Introduction

Deep Neural Networks (DNNs) are often "overconfident" black boxes; they provide an answer but cannot quantify their uncertainty. In safety-critical fields like autonomous driving or medical imaging, knowing when a model is unsure is vital. Bayesian Neural Networks (BayesNNs) address this by providing uncertainty estimates. However, they face two significant challenges: algorithmic complexity and hardware bottlenecks. Standard BayesNN approximations like Monte-Carlo Dropout (MCD) often provide lower uncertainty quality than expensive ensembles, and they require multiple forward passes, making them too slow and power-hungry for edge devices.

This paper introduces a novel architecture that combines Multi-Exit Neural Networks with MCD to create BayesNNs that are both accurate and computationally efficient. To make these models practical for real-world deployment, the authors developed an automated framework to generate high-performance FPGA accelerators, achieving up to 65x better energy efficiency than traditional CPUs.

Multi-Exit MCD-based BayesNN

The proposed solution uses a "backbone" network with multiple "exits" attached at different depths. Instead of applying dropout to every layer, MCD layers are inserted only near these exits.

Comparison of single-exit BayesNN, multi-exit non-BayesNN, and the proposed multi-exit BayesNN architecture.

This approach treats the network as an ensemble that shares a common feature extractor. Because the backbone is shared, heavy computations are performed only once and cached. The lightweight exit branches are then run multiple times to generate Bayesian samples. This drastically reduces the number of Floating Point Operations (FLOPs) required compared to traditional BayesNNs while yielding better uncertainty calibration (lower Expected Calibration Error) than standard MCD.

FPGA Transformation Framework

The authors built a four-phase pipeline to automatically transform these models into FPGA bitstreams, extending the popular hls4ml tool.

The four-phase transformation framework for generating FPGA-based BayesNN accelerators.
  • Phase 1 (Optimization): A grid search to find the best number of exits and dropout rates.
  • Phase 2 (Mapping): Introduction of Spatial Mapping (parallel hardware engines for samples) and Temporal Mapping (shared engines to save space) to balance speed vs. hardware resources.
  • Phase 3 (Co-Exploration): Optimization of bitwidth (quantization) and channel numbers.
  • Phase 4 (Generation): Using High-Level Synthesis (HLS) to automatically generate the hardware design.

Experimental Evaluation

The framework was evaluated using standard image classification benchmarks: MNIST (LeNet5), CIFAR-10 (ResNet-18), SVHN (VGG-11), and a curated subset of CIFAR-100.

Key results include:

  • Accuracy & Calibration: On ResNet18, the proposed "MCD+ME" approach improved accuracy by 2.4% and significantly improved calibration compared to standard models.
  • Energy Efficiency: The FPGA implementation achieved 65x higher energy efficiency than an Intel Core i9 CPU and 33x higher than an NVIDIA RTX 2080 GPU.
  • Hardware Performance: Compared to state-of-the-art FPGA BayesNN accelerators like VIBNN or Bynqnet, this framework produced designs with lower latency and better resource utilization.

Conclusion and Future Work

This work demonstrates that combining multi-exit architectures with MCD can bridge the gap between high-quality uncertainty estimation and efficient hardware deployment. Future work will explore "zero skipping" to leverage sparsity, support for Attention-based architectures (Transformers), and dynamic scaling for run-time reconfiguration based on power constraints.

Summary updated

BibTeX
@inproceedings{hongxiang2023when,
  author = {Fan Hongxiang and Hongxiang Fan and Mark Chen and Liam Castelli and Zhiqiang Que and He Li and Kenneth Long and Wayne Luk},
  title = {{When Monte-Carlo Dropout Meets Multi-Exit: Optimizing Bayesian Neural Networks on FPGA}},
  booktitle = {DAC},
  year = {2023},
}
Figure