Abstract
Non-linear operations such as GELU, Layer normalization, and Softmax are essential yet costly building blocks of Transformer models. Several prior works simplified these operations with look-up tables or integer computations, but such approximations suffer inferior accuracy or considerable hardware cost with long latency. This paper proposes an accurate and hardware-friendly approximation framework for efficient Transformer inference. Our framework employs a simple neural network as a universal approximator with its structure equivalently transformed into a LUT. The proposed framework called NN-LUT can accurately replace all the non-linear operations in popular BERT models with significant reductions in area, power consumption, and latency.
Introduction
While the acceleration of matrix multiplications in Transformer models (e.g., BERT, GPT) has seen significant progress, non-linear operations remain a critical bottleneck. Functions like GELU, Softmax, and LayerNorm are computationally expensive, typically requiring high-precision 32-bit floating-point (FP32) arithmetic. On specialized hardware like Neural Processing Units (NPUs), these operations often lead to high latency and power consumption. Previous approximation methods, such as integer-only arithmetic (I-BERT) or standard Look-Up Tables (LUTs), often struggle with accuracy due to fixed, evenly-spaced breakpoints or require complex, operation-specific hardware logic.
The NN-LUT Framework
To address these challenges, the authors introduce NN-LUT, a framework that treats function approximation as a machine learning optimization problem. The core innovation lies in the mathematical equivalence between a single-hidden-layer neural network with ReLU activation and a piecewise linear function.
Neural-to-LUT Transformation
By training a tiny neural network to mimic a target function (e.g., GELU or $1/x$), the network learns optimal slopes ($s_i$) and intercepts ($t_i$). These parameters are then directly mapped into a hardware LUT. Unlike traditional LUTs with fixed intervals, NN-LUT utilizes learnable breakpoints. During training, the network optimizes the positions of these breakpoints (defined by $-b_i/n_i$), allowing for higher precision in regions with high curvature and wider segments in flatter areas.
Hardware Generality and Calibration
NN-LUT employs a unified hardware unit capable of approximating any non-linear function simply by updating the LUT memory. To further enhance accuracy without expensive fine-tuning, the framework includes a dataset-free calibration step. This process fine-tunes LUT parameters for specific model layers using a small amount of unlabeled data, requiring less than 5% of the time typically needed for standard fine-tuning.
Experimental Results
The researchers evaluated NN-LUT using RoBERTa on the GLUE benchmark and MobileBERT on SQuAD v1.1. The hardware design was synthesized using a commercial 7-nm process.
Hardware and System Efficiency
Compared to the state-of-the-art I-BERT approximation, the NN-LUT hardware unit is 2.63x smaller in area and consumes 36.4x less power. At the system level, integrating NN-LUT into a full accelerator provided up to a 26% total speedup for RoBERTa inference.
Accuracy
On the GLUE benchmark, NN-LUT maintained accuracy within 0.1–0.3% of the original FP32 baseline, often outperforming I-BERT. The learnable breakpoints allow NN-LUT to capture the nuances of non-linear functions far more effectively than standard linear interpolation methods.
Conclusion
NN-LUT provides a highly efficient and accurate solution for accelerating non-linear operations in Transformers. By leveraging the representational power of simple neural networks and mapping them to optimized hardware LUTs, the framework achieves significant gains in power, area, and latency. Future work may explore the application of NN-LUT to Vision Transformers (ViTs) and its performance in multi-tenant cloud environments.
Summary updated