alphaFeedback

WorksComputer Science

LEAF: LUT-aware Efficient Attention on FPGAs

AI contributions
Not recorded for this paper
View details
Ancillary data
1 code link
View

Abstract

We introduce Lookup-table (LUT)-aware Efficient Attention on FPGAs (LEAF). LEAF is the first nanosecond-scale LUT-aware transformer for FPGAs. Deploying transformers that are large enough to perform well, small enough to fit on an FPGA, and fast enough to meet the sub-microsecond timescales required by real-time systems such as those at CERN remains difficult, since the same attention mechanism that gives these models their high expressivity also makes them costly to implement in hardware. LEAF converts the query, key, and value projections and the final output feed-forward layer into FPGA-native layers with LUT-aware training, creating the first LUT-aware transformer and linformer layers built for ultra-low-latency inference. Attention resists LUT-aware training because it multiplies two activations where the method needs a constant weight to tabulate; LEAF tabulates the attention block's constant matrix-vector multiplications and leaves the rest in arithmetic form. On a standard jet tagging benchmark this improves accuracy by 1.8 percentage points while using 2.9 times fewer LUTs than the previous state-of-the-art sub-microsecond transformer at the same input size. Our most efficient LEAF-based linformer with 64 input particles reaches 80.4% classification accuracy at 28k LUTs and 35ns.

Introduction

The CMS [1] and ATLAS [2] experiments at the Large Hadron Collider [3] at CERN generate hundreds of terabytes of data per second from 40 MHz collisions. Since this data cannot all feasibly be stored, the experiments select a small subset of potentially interesting events using a two-level trigger system, consisting of an FPGA-based hardware trigger followed by a software trigger. The experiments can only store the full detector readout for a few microseconds [4, 5], due to limited buffer capacity, and thus the hardware trigger must decide whether to keep each event within this time frame. Any events not selected are permanently discarded, making trigger efficiency crucial for the experiments’ physics reach. To improve filtering performance on the hardware trigger, physicists aim to deploy advanced ML algorithms, which demand highly compressed models capable of running on FPGAs within the resource and latency budgets.

Jet tagging, the task of identifying which particle initiated a collimated spray of particles, is a key step in these trigger systems: accurately tagged jets provide an essential handle for distinguishing rare signals of interest from overwhelming Standard Model backgrounds. Jet tagging has also become a standard benchmark within the fast machine learning community, widely used to demonstrate quantization and compression techniques for FPGA-based neural networks, and we therefore use it to compare our LEAF workflow against previous methods.

LUT-aware training replaces arithmetic with truth tables learned during training, absorbing each constant weight into a table indexed by a single input. Attention resists this: the operation that defines it multiplies two activations and offers no constant to absorb, so existing LUT-aware methods [6] provide dense and convolutional layers only. Within the attention block, however, the query, key and value projections and the output feed-forward layer are constant matrix-vector multiplications (CMVMs). We convert all of them to table-based representations, while the activation-activation products remain in arithmetic form. All parts are trained under a single resource budget, so the trade-off between accuracy and hardware cost is optimized across the whole network. We call the resulting LUT-aware transformer and linformer layers LEAF. Combined with HGQ-LUT [6] for training and Alkaid [7] for bit-exact RTL generation, they form an end-to-end workflow that, on the hls4ml jet tagging benchmark, improves accuracy by 1.8 percentage points while using 2.9× fewer LUTs than the previous state-of-the-art sub-microsecond transformer [8] with 32 input particles. We have integrated our transformer and linformer layers into the open-source HGQ [9] repository, enabling the fast machine learning community to develop efficient LUT-aware transformers for their own applications.

LUT-Aware Transformer Workflow

LUT-Aware Training using HGQ-LUT

High Granularity Quantization (HGQ) [9] is a quantization-aware training method that assigns each weight, bias and activation its own trainable bitwidth, rather than applying a single precision uniformly across a layer or network. It optimizes these bitwidths jointly with the network weights by adding a differentiable resource surrogate, Effective Bit Operations (EBOPs), to the loss function. This allows standard gradient descent to trade off accuracy against estimated hardware cost automatically, including automatic pruning when bitwidths reach zero. This fine-grained approach yields highly compact, hardware-efficient models suited to ultra-low-latency FPGA inference, without requiring manual bitwidth tuning.

HGQ-LUT [6] extends the HGQ method to LUT-based neural networks, a class of architectures that map neural network operations directly onto logic LUTs (L-LUTs) rather than mapping to standard multiply-accumulate (MAC) operations. HGQ-LUT neural network layers are built from single-input logical LUTs, each implemented during training as a small multi-layer perceptron (MLP) and compiled into L-LUT truth tables for FPGA deployment. HGQ-LUT applies HGQ’s heterogeneous differentiable quantization to the inputs and outputs of each L-LUT, extending the EBOPs resource surrogate to this LUT-based setting so that the trade-off between model accuracy and LUT usage is explored during gradient descent, including automatic L-LUT pruning.

Our LEAF attention replaces all CMVM operations, specifically in the query, key, and value projections and the output feed-forward layer, with table-based operations and LUT-aware layers. The key-query multiplication and subsequent multiplication by the value matrix, in contrast, involve variable-variable multiplication and therefore remain in conventional arithmetic form. However, their resource usages contribute to the same differentiable EBOPs resource surrogate as the LUT-aware layers, so that the trade-off between accuracy, arithmetic structure and resource usage is optimized consistently across the entire network. Our LEAF transformer and linformer layers are available in the open-source HGQ tool.

RTL Generation using Alkaid

For streamlined deployment of our LEAF models, we used Alkaid [7], a compiler framework that can translate pretrained Python neural networks directly into RTL, while also applying further optimizations to compress the design. Through Alkaid’s built-in HGQ plugin, our training-to-RTL workflow remains simple and bit-exact verifiable, combining the HGQ tool for model training with Alkaid’s efficient hardware generation.

Application to Jet Tagging

Jet Tagging Task

We demonstrate the performance of our LEAF transformer workflow on a jet tagging task using the HLS4ML LHC Jet dataset [10]. The dataset contains jets of up to 150 particles, each initiated by a gluon, light quark, W boson, Z boson, or top quark, giving 5 classes in total. This dataset has been used extensively to benchmark FPGA-based jet taggers in prior works [8, 11, 12, 13], and we compare our results directly against these in § 3.3.

Model Details

The model architecture used in this work is an encoder-only transformer with residual connections using a standard attention layer [14] with a single head. The model input is a sequence of particles, each represented by three features. The three particle features are transverse momentum pTp_T, pseudorapidity η\eta, and azimuthal angle ϕ\phi. Particles are ordered by decreasing pTp_T, and separate models are trained using only nn of the highest-pTp_T particles, with nn being 8, 16, 32 or 64. The model outputs a probability distribution over the five jet classes. Model accuracy is defined as the percentage of jets for which the highest-probability class is correct.

We also investigated linformer architectures [15] since the projection of the key and value matrices to lower dimensions means that the computational complexity of the attention layer scales linearly with input sequence length rather than quadratically for transformers. The linformer attention layers are by design less resource intensive, so they can more easily be compressed to the required size to fit on the target FPGA.

Our LEAF models are trained using the HGQ tool and are optimized and converted to RTL using Alkaid, as set out in § 2. Note that in our work, we apply saturation (SAT) mode rather than wrap-around (WRAP) mode to the input and output quantizers of each L-LUT. This RTL is then synthesized using Vivado for a Xilinx XCU 250 FPGA to produce the hardware results laid out in § 3.3. Our code1 is available both for reproducibility of the results in this paper and to act as a useful example for others seeking to develop LEAF transformers and linformers for their own applications.

Results

We compare our LEAF models against prior works across five key metrics: accuracy, latency, LUT usage, DSP usage, and initiation interval, evaluating each for 8, 16, 32 or 64 input particles. We evaluate our model performance against the prior state-of-the-art sub-microsecond transformer and linformer models [8, 7], as well as several alternatives, including JEDI-linear [16, 6], MLP Mixer [11], and Deep Sets [12]. The full jet tagging comparison is presented in Table 1, with accuracy shown against LUT usage and latency for all 32-input particle models in Figure 1.

Accuracy against LUT usage and latency for models with 32 input particles

Figure 1. Accuracy against LUT usage and latency for models with 32 input particles.

Architecture TypeDatapathBackendParticlesAcc. (%)Lat. (ns)LUT (k)II (clk)DSP
Transformer (ours)L-LUTalkaid866.37147151
Transformer (ours)L-LUTalkaid1672.6666610
Transformer (ours)L-LUTalkaid3278.8626210
Transformer (ours)L-LUTalkaid6480.97416210
Transformer [7]MACalkaid1672.39822910
Transformer [7]MACalkaid3277.08014110
Transformer [8]MACda4ml866.310424610
Transformer [8]MACda4ml1672.39827910
Transformer [8]MACda4ml3277.08318010
Transformer [8]MACda4ml6477.9444710
Linformer (ours)L-LUTalkaid866.2615010
Linformer (ours)L-LUTalkaid1673.1687315
Linformer (ours)L-LUTalkaid3279.37322510
Linformer (ours)L-LUTalkaid3278.97311110
Linformer (ours)L-LUTalkaid6480.8577610
Linformer (ours)L-LUTalkaid6480.4352810
Linformer [7]MACalkaid1672.810218510
Linformer [7]MACalkaid3278.48719810
Linformer [8]MACda4ml866.311023010
Linformer [8]MACda4ml1672.810524610
Linformer [8]MACda4ml3278.414026710
Linformer [8]MACda4ml6479.87820210
JEDI-linear [6]L-LUTda4ml3278.3304210
JEDI-linear [16]MACda4ml866.57913610
JEDI-linear [16]MACda4ml1673.67513610
JEDI-linear [16]MACda4ml3279.08013610
JEDI-linear [16]MACda4ml6481.87816410
MLP Mixer [11]MACda4ml1671.7687510
MLP Mixer [11]MACda4ml3278.0626310
MLP Mixer [11]MACda4ml6479.77215910
Deep Sets [12]1MAChls4ml8≤64.0\le64.02953863626
Deep Sets [12]1MAChls4ml16≤69.4\le69.421157473555
Deep Sets [12]1MAChls4ml32≤75.9\le75.921309032434

Table 1. Performance comparison of models on the hls4ml LHC Jet dataset [10]. All results presented are from out-of-context results post place & route on Vivado 2025.1 if not otherwise specified.

These results show that LEAF’s LUT-aware attention with HGQ-LUT is a major improvement on the HGQ method alone for transformer architectures [8]. To isolate the contribution of LUT-aware attention, we separate LEAF’s gains over prior work into the part due to the Alkaid backend and the part due to LEAF itself. In Table 1, we compare the resource usage and latency between HGQ transformer models converted with da4ml [8] against the same HGQ models converted with Alkaid [7]. For example, for the 32-particle transformer model, LUTs go from 180k with da4ml to 141k with Alkaid. However, when using LEAF with Alkaid we obtain both a 1.8 percentage point increase in accuracy and a reduction to 62k LUT. In this case roughly a third of the saving comes from the backend and two-thirds from the LUT-aware training. This comparison shows that the majority of the improvement achieved by our LEAF transformers and linformers is attributable to LUT-aware training and table-based mapping, although the switch from da4ml to Alkaid also contributes, through additional optimizations such as affine interval tracking and improved distributed arithmetic optimization [7].

These results demonstrate that LEAF moves transformers competitively onto the accuracy-resource Pareto front for jet tagging on FPGAs, alongside the leading architecture JEDI-linear [16].

Conclusions

We have presented LEAF, the first nanosecond-scale LUT-aware transformer for FPGA applications, achieving greater model accuracy with fewer LUTs than previous transformer implementations. By contributing support for our transformer and linformer layers in the open-source HGQ repository, we aim to make efficient, LUT-aware attention mechanisms broadly accessible to the fast machine learning community. We envision that these LUT-aware transformers could prove useful and effective across a wide range of high-energy physics tasks beyond jet tagging, including anomaly detection and foundation models. We believe our workflow makes larger, more expressive transformers more easily deployable for real-time systems, from CERN trigger systems to other ultra-low-latency applications.

Acknowledgments

Work done by Imperial College is funded by the Science and Technology Facilities Council (STFC) grant ST/W000636/1 and Intel and Lenovo (ICICLE HPC & AI partnership). Work done at Caltech is partially funded by the U.S. Department of Energy grant numbers DE-SC0011925, DE-FOA-0002705 and National Science Foundation grant numbers PHY240298, PHY2117997.

References

  1. [1]The CMS Collaboration. The CMS Experiment at the CERN LHC. Journal of Instrumentation, 3:S08004, 2008. doi:10.1088/1748-0221/3/08/S08004.
  2. [2]The ATLAS Collaboration. The ATLAS Experiment at the CERN Large Hadron Collider. Journal of Instrumentation, 3(08):S08003, 2008. URL: https://dx.doi.org/10.1088/1748-0221/3/08/S08003, doi:10.1088/1748-0221/3/08/S08003.
  3. [3]The LHC Study Group. The Large Hadron Collider, Conceptual Design. Technical report, CERN/AC/95-05 (LHC) Geneva, 1995.
  4. [4]The CMS Collaboration. The Phase-2 Upgrade of the CMS Level-1 Trigger. Technical report, CERN, Geneva, 2020. URL: https://cds.cern.ch/record/2714892.
  5. [5]The ATLAS Collaboration. Technical Design Report for the Phase-II Upgrade of the ATLAS TDAQ System. Technical report, CERN, Geneva, 2017. URL: https://cds.cern.ch/record/2285584, doi:10.17181/CERN.2LBB.4TAL.DOI
  6. [6]Chang Sun, Zhiqiang Que, Bakhtiar Zadeh, Qibin Liu, Kevin H Alvarez, Wayne Luk, and Maria Spiropulu. HGQ-LUT: Fast LUT-Aware Training and Efficient Architectures for DNN Inference. In 2026 IEEE 34th Annual International Symposium on Field-Programmable Custom Computing Machines (FCCM), pages 19–28. IEEE, 2026.
  7. [7]Chang Sun, Zhiqiang Que, Dimitrios Danopoulos, Maurizio Pierini, Wayne Luk, and Maria Spiropulu. Alkaid: A Compiler Framework for Ultra-Low-Latency Kernels on Hardware. In 2026 IEEE 44th Annual International Conference on Computer Design (ICCD). IEEE, 2026.arxiv.org/abs/2610.04808
  8. [8]Lauri Laatu, Chang Sun, Arianna Cox, Abhijith Gandrakota, Benedikt Maier, Jennifer Ngadiuba, Zhiqiang Que, Wayne Luk, Maria Spiropulu, and Alexander Tappert. Sub-microsecond Transformers for Jet Tagging on FPGAs, 2025. URL: https://arxiv.org/abs/2510.24784, arXiv:2510.24784.
  9. [9]Chang Sun, Zhiqiang Que, Thea Aarrestad, Vladimir Loncar, Jennifer Ngadiuba, Wayne Luk, and Maria Spiropulu. Hgq: High granularity quantization for real-time neural networks on fpgas. In Proceedings of the 2026 ACM/SIGDA International Symposium on Field Programmable Gate Arrays, pages 79–91, 2026.DOI
  10. [10]Maurizio Pierini, Javier Mauricio Duarte, Nhan Tran, and Marat Freytsis. HLS4ML LHC Jet dataset (150 particles), 2020. doi:10.5281/zenodo.3602260.
  11. [11]Chang Sun, Jennifer Ngadiuba, Maurizio Pierini, and Maria Spiropulu. Fast Jet Tagging with MLP-Mixers on FPGAs. Machine Learning: Science and Technology, 2025. URL: http://iopscience.iop.org/article/10.1088/2632-2153/adf596.DOI
  12. [12]Patrick Odagiu, Zhiqiang Que, Javier Duarte, Johannes Haller, Gregor Kasieczka, Artur Lobanov, Vladimir Loncar, Wayne Luk, Jennifer Ngadiuba, Maurizio Pierini, Philipp Rincke, Arpita Sekaria, Sioni Summers, Andre Sznajder, Alexander Tapper, and Thea K Ärrestad. Ultrafast jet classification at the HL-LHC. Machine Learning: Science and Technology, 5(3):035017, July 2024. URL: http://dx.doi.org/10.1088/2632-2153/ad5f10, doi:10.1088/2632-2153/ad5f10.
  13. [13]Jason Weitz, Dmitri Demler, Luke McDermott, Nhan Tran, and Javier Duarte. Neural Architecture Codesign for Fast Physics Applications. Machine Learning: Science and Technology, 6(3):035009, jul 2025. URL: https://dx.doi.org/10.1088/2632-2153/adede1, doi:10.1088/2632-2153/adede1.
  14. [14]Ashish Vaswani, Noam Shazeer, Niki Parmar, Jakob Uszkoreit, Llion Jones, Aidan N. Gomez, Lukasz Kaiser, and Illia Polosukhin. Attention Is All You Need. CoRR, abs/1706.03762, 2017. URL: http://arxiv.org/abs/1706.03762, arXiv:1706.03762.
  15. [15]Sinong Wang, Belinda Z. Li, Madian Khabsa, Han Fang, and Hao Ma. Linformer: Self-Attention with Linear Complexity, 2020. URL: https://arxiv.org/abs/2006.04768, arXiv:2006.04768.
  16. [16]Zhiqiang Que, Chang Sun, Sudarshan Paramesvaran, Emyr Clement, Katerina Karakoulaki, Christopher Brown, Lauri Laatu, Arianna Cox, Alexander Tapper, Wayne Luk, and Maria Spiropulu. JEDI-linear: Fast and Efficient Graph Neural Networks for Jet Tagging on FPGAs. In 2025 International Conference on Field-Programmable Technology (FPT). IEEE, 2025.DOI

Paper details

vlnc:W_cq5armqu
v1 · latestHistory (1)

published · Fresh — added to the Hub within the last 30 days

added ·

Usage

views · 0

downloads · 0

A view counts once per browser per day, a download each time the PDF is requested.

CC BY 4.0

Original source

  • Computer Science

Not recorded for this paper · View statement →

Looking for related papers…
Contents