Abstract
Bayesian Recurrent Neural Networks (RNNs) provide critical uncertainty estimation for safety-critical applications but suffer from high computational costs due to Monte Carlo sampling. This paper introduces the first FPGA-based hardware accelerator for Bayesian RNNs, utilizing a custom pipelined architecture and an algorithmic-hardware co-design framework. Our implementation achieves a 10x speedup and a $10^6$ improvement in energy efficiency over high-end GPUs, enabling real-time monitoring of ECG signals with reliable uncertainty quantification.
Introduction
Standard Recurrent Neural Networks (RNNs), particularly Long Short-Term Memory (LSTM) networks, are highly effective at modeling time-series data. However, they are often "overconfident," providing predictions without quantifying uncertainty. In safety-critical fields like medicine, knowing when a model is unsure is as vital as the prediction itself. Bayesian RNNs address this by treating weights as distributions, allowing for uncertainty estimation through Monte Carlo (MC) sampling.
The primary challenge for Bayesian RNNs is their computational expense. Obtaining a single prediction requires dozens or hundreds of MC samples, which can take several seconds on a standard CPU—far too slow for real-time ECG monitoring. This work bridges the gap by providing a specialized hardware architecture for efficient, real-time Bayesian RNN deployment.
Methods
Hardware Architecture
The proposed architecture focuses on Monte Carlo Dropout (MCD) to avoid the memory overhead of storing multiple weight sets. Instead, the design maintains one set of weights and applies random binary masks to inputs and hidden states on the fly.
Key architectural features include:
- On-chip Bernoulli Sampler: A custom module using Linear Feedback Shift Registers (LFSRs) generates randomness without stalling the pipeline.
- Advanced Pipelining: The design overlaps mask generation with LSTM computations and employs "time-step pipelining" to process multiple sequence steps in parallel across layers.
- Weight Reuse: By keeping weights on-chip and using demultiplexers for data flow control, the design eliminates the massive memory traffic typically associated with Bayesian inference.
Co-Design Framework
The authors developed a framework to explore the design space between hardware performance and algorithmic accuracy. This includes optimizing algorithmic parameters (hidden size, number of layers), hardware resource allocation (DSPs), and quantization (moving from 32-bit floating-point to 16-bit fixed-point math).
Experimental Results
The system was evaluated using the ECG5000 dataset for anomaly detection and arrhythmia classification.
- Speed and Latency: The FPGA implementation achieved a 10x speedup over an NVIDIA TITAN X Pascal GPU. For anomaly detection, the FPGA latency was approximately 41ms for a batch of 50, compared to 380ms on the GPU.
- Energy Efficiency: The design proved to be nearly one million ($10^6$) times more energy-efficient per sample than the GPU implementation.
- Partial Bayesianism: A key insight was that making every layer Bayesian is unnecessary. "Partially Bayesian" models often provide the best balance of accuracy, uncertainty quality, and hardware speed.
- Sampling Returns: The benefits of MC sampling were found to plateau after $S=30$ samples, allowing for significant optimization by capping the number of required passes.
Conclusion
This work demonstrates that FPGA-based acceleration can make complex Bayesian RNNs viable for real-time, safety-critical applications. Future work will focus on supporting variable dropout rates, extending the architecture to Gated Recurrent Units (GRUs), and automating the re-training process within the co-design framework.
Summary updated