ML-based Real-Time Control at the Edge: An Approach Using hls4ml

Rui Shi, Seda Ogrenci, Jeremy M. Arnold, J. R. Berlioz, Pierrick Hanlet, Kyle J. Hazelwood, Michelle A. Ibrahim, Han Liu, V. P. Nagaslaev, Aakaash Narayanan, D. J. Nicklaus, Jovan Mitrevski, Gauri Pradhan, A. L. Saewert, B. A. Schupbach, Kiyomi Seiya, Mattson Thieme, R. M. Thurman-Keup, N. V. Tran · DOI

Introduction

In high-energy physics, particle accelerators like those at Fermilab are incredibly complex systems where precision is paramount. A critical challenge in their operation is beam loss—the phenomenon where protons deviate from their intended path and strike the machine's walls. This creates radiation and risks damaging sensitive equipment. To mitigate this, researchers have developed a real-time, FPGA-based edge computing system designed to manage beam loss by "de-blending" signals from the Main Injector (MI) and the Recycler Ring (RR).

System overview of the Fermilab Recycler Ring and the real-time data processing pipeline.

The system must process data from hundreds of sensors and make control decisions every 3 milliseconds. Traditional computing architectures like CPUs and GPUs, while powerful, are optimized for high throughput through batch processing. However, for "batch size 1" real-time control, these platforms often fail to meet the strict latency requirements due to data transfer overheads.

Methodology

The proposed solution leverages a deep learning approach deployed on an Intel Arria 10 SoC FPGA. The technical implementation is built upon several key pillars:

Model Architecture

The team utilized a U-Net model (comprising 134,434 parameters) for its robust feature extraction capabilities. The encoder-decoder structure with skip connections allows the model to effectively map sensor readings to specific accelerator components. A simpler Multi-Layer Perceptron (MLP) was also evaluated as a baseline.

hls4ml and Optimization

To bridge the gap between high-level machine learning frameworks and hardware description languages, the researchers used hls4ml. This open-source tool converts models from Keras or TensorFlow into high-level synthesis (HLS) code.

A significant innovation in this work is the use of layer-based quantization. Rather than applying a uniform 16-bit precision, the team calculated the maximum output for each individual layer and assigned custom bit-widths. This approach reduced logic utilization on the FPGA from over 100% to just 31%, while simultaneously maintaining an accuracy of over 99%. Additionally, "reuse factors" were tuned to balance the physical circuit size against inference speed.

Performance and Results

The system was evaluated using real-world data from 260 Beam Loss Monitors (BLMs). The input consists of a 260-element array of sensor readings, and the output provides 520 values—probabilities attributing loss to either the MI or RR for each sensor.

Latency comparison between CPU, GPU, and SoC FPGA for MLP and U-Net models.

The results demonstrate the clear advantage of FPGAs for this application:

  • Latency: The total system latency for the U-Net model is 1.74 ms, well within the 3 ms requirement. The FPGA core itself completes inference in just 1.57 ms.
  • Throughput: The system achieves 575 frames per second (fps), significantly exceeding the target of 320 fps.
  • Accuracy: The optimized U-Net reached 99.1% accuracy for MI predictions and 99.9% for RR predictions.
  • Hardware Efficiency: The design utilized 89% of the logic and 85% of the RAM blocks on the Arria 10, demonstrating highly efficient resource allocation.

Discussion and Future Work

While GPUs are standard for many ML tasks, this research highlights that for real-time control where data arrives continuously in small increments, GPUs perform similarly to CPUs. FPGAs emerge as the superior choice for microsecond-to-millisecond latency requirements.

Despite the success, some limitations remain. The U-Net model nearly exhausts the logic resources of the Arria 10, suggesting that more complex models would require larger hardware or further architectural breakthroughs. Additionally, occasional latency spikes (up to 2.27 ms) were noted, likely due to OS-level task scheduling jitter. Future efforts will focus on creating a more generalized template for edge-ML applications in experimental physics, allowing for easier integration of various IP cores.

Summary updated

BibTeX
@inproceedings{shi2024ml,
  author = {Rui Shi and Seda Ogrenci and Jeremy M. Arnold and J. R. Berlioz and Pierrick Hanlet and Kyle J. Hazelwood and Michelle A. Ibrahim and Han Liu and V. P. Nagaslaev and Aakaash Narayanan and D. J. Nicklaus and Jovan Mitrevski and Gauri Pradhan and A. L. Saewert and B. A. Schupbach and Kiyomi Seiya and Mattson Thieme and R. M. Thurman-Keup and N. V. Tran},
  title = {{ML-based Real-Time Control at the Edge: An Approach Using hls4ml}},
  booktitle = {Workshops @ IPDPS},
  year = {2024},
  doi = {10.1109/ipdpsw63119.2024.00051},
}
Figure