Next Article in Journal
High-Capacitance Gold Nanoparticles from Rhus coriaria: Green Synthesis, Characterization and Electrochemical Evaluation for Supercapacitor Technologies
Next Article in Special Issue
Impact of Fabrication Defects on FPGA Logic Using Memristor-Based Memory Cells
Previous Article in Journal
Numerical Study on Heat Transfer Performance of Turbulence Enhancement Configurations for Galinstan Based Mini-Channel Cooling
Previous Article in Special Issue
Hardware Accelerators for Cardiovascular Signal Processing: A System-on-Chip Perspective
 
 
Font Type:
Arial Georgia Verdana
Font Size:
Aa Aa Aa
Line Spacing:
Column Width:
Background:
Article

Hardware-Oriented Approximations of Softmax and RMSNorm for Efficient Transformer Inference

1
Institute of Information Science, Beijing Jiaotong University, Beijing 100044, China
2
Beijing Key Laboratory of Advanced Information Science and Network Technology, Beijing 100044, China
*
Author to whom correspondence should be addressed.
Micromachines 2026, 17(1), 84; https://doi.org/10.3390/mi17010084
Submission received: 9 November 2025 / Revised: 26 December 2025 / Accepted: 30 December 2025 / Published: 7 January 2026
(This article belongs to the Special Issue Advances in Field-Programmable Gate Arrays (FPGAs))

Abstract

With the rapid advancement of Transformer-based large language models (LLMs), these models have found widespread applications in industrial domains such as code generation and non-functional requirement (NFR) classification in software engineering. However, recent research has primarily focused on optimizing linear matrix operations, while nonlinear operators remain relatively underexplored. This paper proposes hardware-efficient approximation and acceleration methods for the Softmax and RMSNorm operators to reduce resource cost and accelerate Transformer inference while maintaining model accuracy. For the Softmax operator, an additional range reduction based on the SafeSoftmax technique enables the adoption of a bipartite lookup table (LUT) approximation and acceleration. The bit-width configuration is optimized through Pareto frontier analysis to balance precision and hardware cost, and an error compensation mechanism is further applied to preserve numerical accuracy. The division is reformulated as a logarithmic subtraction implemented with a small LOD-driven lookup table, eliminating expensive dividers. For RMSNorm, LOD is further leveraged to decompose the reciprocal square root into mantissa and exponent parts, enabling parallel table lookup and a single multiplication. Based on these optimizations, an FPGA-based pipelined accelerator is implemented, achieving low operator-level latency and power consumption with significantly reduced hardware resource usage while preserving model accuracy.

1. Introduction

Since the Transformer model was proposed in 2017 [1], it has demonstrated strong capabilities in parallel sequence processing through global attention modeling and has become the dominant architecture for large language models (LLMs). In recent years, the Transformer architecture has continued to evolve, and the emergence of open-source models such as OPT, LLaMA, LLaMA2 [2,3,4], and LLaMA3 has made the private deployment of LLMs increasingly feasible. Despite these advances, the parameter scale of LLMs has increased extremely rapidly in recent years, while hardware performance—constrained by Moore’s Law—has improved by only about 1.5× every 18 months [5]. This imbalance introduces significant challenges in storage, computation, and power consumption, particularly for inference on edge devices where energy budgets are extremely limited. As a result, it hinders the widespread adoption of LLMs in real-world applications. Field Programmable Gate Arrays (FPGAs), with their inherent low-power characteristics and reconfigurable computing resources, offer a promising platform for energy-efficient and flexible inference acceleration in embedded and edge systems. Consequently, operator-level optimization of Transformer inference on FPGA and other embedded platforms has become an active research direction [6,7,8,9].
Deploying Transformer models on FPGAs presents significant challenges due to the high computational cost of nonlinear operations. While linear layers benefit from low-bit quantization and specialized matrix–vector multiplication (MVM) engines, key nonlinear functions such as Softmax and RMSNorm still rely on high-precision floating-point arithmetic. Beyond conventional digital accelerators, analog and mixed-signal in-memory computing has been explored to speed up large-scale MVM in neural networks [10,11]. However, these approaches mainly target linear operations and do not address the FPGA challenges of nonlinear operators.
As a result, nonlinear functions such as Softmax and RMSNorm introduce considerable latency and resource overhead. This effect is particularly pronounced for long-context inference (e.g., 4096 tokens), where these operators can account for a significant fraction of the total inference runtime [12]. Many existing accelerator designs provide limited implementation details or rely on floating-point arithmetic and dynamic-shift operations [9,13,14], which are inefficient on FPGAs.
To address these challenges, this work presents hardware-oriented algorithmic designs for the two key nonlinear operators—Softmax and RMSNorm and implements them on an FPGA platform. The main contributions are summarized as follows:
  • Softmax Approximation and Acceleration: The exponential function is approximated over a wide input range using lookup tables (LUTs) and a single adder, enabling an efficient, fully fixed-point implementation without requiring any DSP resources.
  • RMSNorm Approximation and Acceleration: The reciprocal square root function x 0.5 is approximated using an LOD–LUT–MUL structure, where exponent and mantissa components are independently processed by 32- and 256-entry LUTs, respectively. Their outputs are multiplied to reconstruct x 0.5 , enabling a fully fixed-point realization with minimal DSP usage while preserving numerical precision.
  • Hardware Implementation and Evaluation: A deeply pipelined fixed-point architecture is designed for both operators and deployed on the Xilinx Alveo U55C accelerator card, achieving low resource utilization, reduced inference latency, and competitive precision.

2. Related Work

As large language models (LLMs) are rapidly expanding into industrial applications, including operation log analysis, real-time production monitoring, and QA systems, there is an urgent need for hardware architectures that can execute Transformer operators with low resources and power consumption.
Numerous studies have explored hardware-friendly approximations and accelerators of the Softmax function to enhance Transformer inference efficiency. Softermax [15] replaces the exponential function with a base-2 power form and introduces Online-Softmax to reduce the number of iterations. Although this approach improves computational efficiency, it introduces an additional exponential computation and requires fine-tuning to recover precision loss, thereby limiting its practicality on FPGA platforms. Mei [16] applies a three-segment PLAC (Piecewise Linear Approximation Calculation) method for exponential approximation, where each segment requires an independent multiplier, leading to considerable hardware cost. Koca [17] expresses the exponential function as e x 2 1.5 x , where the constant log 2 e 1.5 replaces the multiplication factor, allowing the use of shift operations instead of costly multipliers. However, the method relies on dynamic shifters to scale the exponential output, which incurs substantial hardware overhead on FPGA devices. Wang [18] proposes SOLE, which employs power-of-two scaling to approximate e x as 2 k x and replaces the normalization term with its nearest power of two, thereby eliminating division operations and significantly reducing hardware cost. Nevertheless, the method has not been evaluated on FPGA platforms. Overall, these approaches alleviate the Softmax bottleneck to varying degrees. However, most are not tailored to FPGA architectures or fail to meet the high-precision requirements of attention.
Compared with Softmax and LayerNorm, hardware optimization studies on RMSNorm remain relatively limited. RMSNorm removes mean subtraction, which reduces data dependency and makes it more hardware friendly. However, it still requires squaring, accumulation, and reciprocal square root. Lu [19] computes reciprocal square root using direct arithmetic. Yu [20] uses piecewise polynomials but incurs high cost under a wide dynamic range. Kim [12] uses Newton–Raphson iteration, which needs extra multipliers and adders and is less suitable for resource-constrained FPGAs. The SOLE architecture [18] quantizes the x 2 operation to a lower bit-width representation to reduce complexity, but it depends on a quantization scheme poorly suited for models with large parameter scales. Li [21] proposes a general division approximation technique. However, its direct extension to LayerNorm results in excessive lookup-table overhead. In general, dedicated hardware designs for RMSNorm remain largely unexplored. Overall, dedicated RMSNorm hardware designs remain largely unexplored.
Compared to the SOLE [18] method, which relies on a resource-intensive dynamic shifter, our Softmax approximation adopts a LUT-based scheme. By transforming division into the log domain, we reuse the same exp-LUT and eliminate the need for a dedicated divider. Compared to Li’s LayerNorm approximation [21], which extends general division to square-root division but overlooks the sign and parity of k in 1 / x = 2 k / 2 ( 1 + s ) , requiring two large LUTs and four processing branches. Our design replaces these with only two small LUTs and a multiplier, simplifying structure while preserving accuracy. Compared to HAAN [22], our reciprocal–root scheme stays fully in the fixed-point domain and avoids costly FX–FP–FX conversions, reducing logic and DSP usage. Compared to Kim [12], which supports a narrow input range (0, 2), our method extends the valid range, which is more suitable for LLM workloads.

3. Preliminary

3.1. Softmax and RMSNorm

In the Transformer architecture, nonlinear normalization and activation functions are essential for stable training and numerical robustness. Among them, Softmax and RMSNorm are core operations in the self-attention and residual normalization modules, respectively. Softmax converts the similarity scores between Query and Key into normalized attention weights. Given the attention vector x = [ x 1 , x 2 , , x n ] , it is defined as:
Softmax ( x i ) = e x i j = 1 n e x j .
To prevent numerical overflow, a stabilized version is typically adopted [23,24]:
SafeSoftmax ( x i ) = e x i max ( x ) j = 1 n e x j max ( x ) .
Its main challenge arises from the exponential and division operations, which introduce significant computational complexity and hardware overhead in float implementations.
RMSNorm is a simplified variant of LayerNorm that removes the mean subtraction step, and then normalizes using the root mean square (RMS) of the input vector. Given x = [ x 1 , x 2 , , x d ] , RMSNorm is defined as:
RMSNorm ( x ) = x 1 d i = 1 d x i 2 + ϵ ,
where d is the input dimension, ϵ is a small constant for numerical stability. By eliminating the mean subtraction term ( x i x ¯ ) of Layernorm, RMSNorm reduces computation and intermediate storage, making it more hardware-friendly, particularly for low-latency and resource-constrained devices. Its main challenge lies in the reciprocal square root operation, which remains expensive in hardware, motivating further research into efficient approximation and accelerator methods.

3.2. Bipartite-Table

The Bipartite Table [25] method is a lookup-based algorithm for high-precision function approximation. Figure 1 illustrates its structure. The method partitions the input into multiple segments. It performs parallel table lookups. This design reduces storage requirements and preserves high computational accuracy. The basic idea is as follows: given an input operand x, it is divided into three parts x 0 , x 1 , x 2 with bit widths n 0 , n 1 , n 2 , respectively, such that the target function f ( x ) can be approximated by a two-term expansion:
f ( x ) a 0 ( x 0 , x 1 ) + a 1 ( x 0 , x 2 ) .
Here, the first term a 0 ( x 0 , x 1 ) is generated by the n 0 + n 1 bits (the x 0 and x 1 segments) and accessed from the first lookup table (Table a 0 ) to provide the main approximation value, while the second term a 1 ( x 0 , x 2 ) uses the n 0 + n 2 bits segments as input to the second table (Table a 1 ) to generate a local correction term.
The outputs of the two tables are then summed to produce the final approximation result. The Bipartite Table method is hardware-friendly because it replaces a single large lookup table with two much smaller ones, significantly reducing the number of stored entries while maintaining high-precision function approximation.

3.3. Compensation-Based Approximation Principle

To further reduce the accelerator’s approximation bias introduced by table-based nonlinear function estimation, a compensation mechanism was introduced in prior work [21]. The key idea is that when a continuous function f ( x ) is uniformly quantized into discrete segments, the value retrieved from the lookup table f ˜ ( x ) may deviate from the true mean of f ( x ) over that interval. To correct this systematic bias, the average deviation between f ( x ) and its quantized representation is precomputed for each segment and stored as a small compensation table. During inference, the corresponding compensation value is subtracted from the lookup output, yielding a bias-corrected approximation as:
f corr ( x ) = f ˜ ( x ) Δ k , Δ k = 1 Δ x x k x k + 1 f ˜ ( x k ) f ( x ) d x .
This formulation can be applied generically to functions such as the reciprocal and square-root operations, providing a simple yet effective way to enhance accelerator approximation accuracy without increasing table resolution or computational complexity. In this work, we adopt and refine this decomposition strategy for RMSNorm.

4. Methods

4.1. Range-Reduced LUT-Based Approximation for Softmax

In the Softmax function, the exponential input spans from negative infinity to positive infinity, making direct hardware approximation infeasible for accelerator implementations. The SafeSoftmax technique mitigates this issue by subtracting the maximum element, constraining the input to ( , 0 ] as introduced in Section 3.1. However, this range remains too wide for lookup-table (LUT) implementation.
By examining the numerical magnitude of the exponential term under fixed-point inference, we observe that when x < 16 , the exponential value satisfies e x e 16 1.1 × 10 7 , which is negligible compared with the dominant terms in the Softmax denominator. In our experiments on LLaMA2-7B inference, truncating exponential inputs below this threshold results in only a very small and practically negligible increase in perplexity. Similar exponential range truncation strategies have also been adopted in prior works [26]. Therefore, in this work, we empirically restrict the effective exponential input range to ( 16 , 0 ] to simplify FPGA implementation while preserving numerical accuracy.
Within this bounded range, the Bipartite Table method described in Section 3.2 is employed to approximate the exponential efficiently. Since all input terms ( x i max ( x ) ) are non-positive, the index is redefined as ( max ( x ) x i ) [ 0 , 16 ) , avoiding additional sign-bit processing. Because the clipped input range is [0, 16), its integer part can be represented using only 4 bits. As shown in Table 1, experiments indicate that allocating 7 bits for intput fractional part is sufficient to maintain accuracy. The output bit width is determined by referring to the settings in [21] and combined with experimental results. 15 fractional bits are required to represent the self-attention scores in the range [0, 1] with sufficient precision. Ultimately, using an 11-bit input (4 integer bits and 7 fractional bits) and a 16-bit output (1 integer bit and 15 fractional bits) achieves accuracy comparable to floating-point computation while maintaining hardware efficiency.
The input variable x [ 0 , 16 ) is decomposed into three non-overlapping parts:
x = x 0 + x 1 + x 2 ,
where each segment corresponds to distinct bit widths. The Bipartite Table method then approximates the exponential function using two compact LUTs and one adder, achieving high precision with minimal memory overhead.

4.2. Bipartite LUT Configuration and Error Compensation

In the Bipartite Table method [25], the input x is divided into three parts x 0 , x 1 , x 2 with bit widths n 0 , n 1 , n 2 , respectively. The total bit width is n = n 0 + n 1 + n 2 . Increasing precision in one segment exponentially enlarges the table size, leading to higher storage and latency. Therefore, determining an appropriate bit-width allocation is essential to balance precision and resource utilization.

4.2.1. Two-Stage Bit-Width Search via SNDR Analysis and Pareto Pruning

To balance approximation accuracy and hardware storage cost, we adopt a two-stage configuration exploration strategy. In the first stage, an analytical error model based on the signal-to-noise-and-distortion ratio (SNDR) is developed to eliminate inefficient bit-width configurations. In these configurations, the overall SNDR is dominated by a single error source, such that increasing other bit widths no longer leads to meaningful accuracy improvement. In the second stage, the remaining feasible configurations are further pruned by a Pareto frontier analysis in the accuracy-cost space to obtain a compact candidate set for empirical evaluation.
Following [25], the total approximation error is decomposed into three components: E 0 , the truncation error from Taylor expansion; E 1 , the coefficient quantization error; and E 2 , the output quantization error. The overall SNDR is defined as
SNDR = 10 log 10 P s P n + P D = 10 log 10 f ( x ) 2 E 0 2 + E 1 2 + E 2 2 ,
where P s denotes the signal power and P n + P D represents the total noise and distortion power.
Assuming that the three error sources are independent and uniformly distributed, their magnitudes can be bounded as
E 0 <   | f ( ξ 1 ) |   ·   2 2 n 0 2 n 1 2 ,
E 1 <   | f ( ξ 2 ) |   ·   2 2 n 0 n 1 2 ,
E 2 2 n out .
Given the clipped input range [ 0 , 16 ) , the average signal power can be approximated as
P s = E [ e 2 x ] = 1 16 0 16 e 2 x d x 1 32 .
Substituting the error bounds yields
SNDR 10 log 10 1 / 32 2 4 n 0 4 n 1 4 + 2 4 n 0 2 n 1 4 + 2 2 n out .
The SNDR expression shows that the total error is dominated by the largest of the three error sources. Once a single error term becomes dominant, reducing other errors provides little SNDR improvement. Therefore, bit-width allocation should aim to balance the major error sources.
Since the first error term E 0 is always smaller than E 1 , the effective balance can be achieved by equating E 1 and E 2 , which yields the bit-width relation:
n out 2 n 0 + n 1 + 2 ,
n i n = n 0 + n 1 + n 2 .
After applying the SNDR-based constraint, multiple configurations may still satisfy the condition while exhibiting significantly different hardware costs and approximation accuracies. Therefore, a second pruning step is introduced using a Pareto frontier analysis.
The hardware cost metric C is defined as the total number of LUT entries required by a 0 ( x 0 , x 1 ) and a 1 ( x 0 , x 2 ) :
C = 2 n 0 + n 1 + 2 n 0 + n 2 .
The accuracy metric A is defined based on the dominant error term E 1 2 ( 2 n 0 + n 1 ) after SNDR balancing:
A = 2 n 0 + n 1 ,
In the ( C , A ) space, a configuration i is said to be dominated if there exists another configuration j such that
C j C i and A j A i ,
and at least one inequality is strict. Only non-dominated configurations on the Pareto frontier are retained for further experimental evaluation.
As shown in Figure 2, the red points are filtered out in the first stage using the SNDR-based constraint in Equation (13), the orange points are further removed by the Pareto optimality criterion in Equation (17), and the remaining green points are selected for subsequent experimental evaluation.
As shown in Table 2, we select ( 5 , 3 , 3 ) as the final bit-width configuration for ( n 0 , n 1 , n 2 ) . Accordingly, n 0 = 5 and n 1 = 3 are used to index the a 0 lookup table, while n 0 = 5 and n 2 = 3 are used to index the a 1 lookup table. In total, this configuration requires 2 5 + 3 + 2 5 + 3 = 512 table entries.

4.2.2. Error Compensation and LUT Optimization

Even with optimal bit-width allocation, the bipartite LUT structure still introduces residual quantization errors caused by input truncation, function approximation, and output rounding. To further enhance numerical accuracy, this work introduces a lightweight error compensation mechanism that fine-tunes the LUT coefficients through parameterized optimization.
Let the n-bit quantization operator be defined as
Q n ( x ) = 2 n · 2 n x ,
where · denotes rounding to the nearest integer. Based on this operator, the compensated LUT entries are expressed as:
a ˜ 0 ( x 0 , x 1 ) = 2 n out 2 n out exp Q n 0 ( x 0 ) Q n 1 ( x 1 ) δ 2 ,
a ˜ 1 ( x 0 , x 2 ) = 2 n out 2 n out exp Q n 0 ( x 0 ) δ 1 δ 2 Q n 2 ( x 2 ) δ 2 ,
where δ 1 and δ 2 are exactly halfway between the minimum and maximum values for x 1 and x 2 :
δ 1 = 2 ( n 0 + 1 ) 2 ( n 0 + n 1 + 1 ) , δ 2 = 2 ( n 0 + n 1 + 1 ) 2 ( n 0 + n 1 + n 2 + 1 ) .
The final exponential approximation is then given by
f ^ ( x ) = a ˜ 0 ( x 0 , x 1 ) + a ˜ 1 ( x 0 , x 2 ) .
To jointly minimize mean squared error (MSE) and maximum absolute error (MAX) approximation errors, a hybrid loss function is employed.
L ( f , f ^ ) = α 1 N i = 1 N f ( x i ) f ^ ( x i ) 2 + β max 1 i N | f ( x i ) f ^ ( x i ) | ,
where α , β > 0 are weighting coefficients. This optimization ensures smooth convergence of LUT coefficients and numerical stability in hardware deployment.
The final compensated exponential can thus be efficiently evaluated as:
e x i max ( x ) LUT a 0 max ( x ) x i + LUT a 1 max ( x ) x i ,
Near–floating-point precision is achieved with minimal hardware cost.

4.2.3. Training and Experimental Setup

This section details the error compensation training procedure, parameter settings, and evaluation results. The training data cover the range [ 0 , 16 ] , corresponding to the absolute value of the exponent input after clipping in the Softmax function, and consist of 10,000 uniformly sampled points. A separate test set of 1,000,000 randomly generated samples is used for final error evaluation.
The weighting coefficients in the hybrid loss are set to α = 0.5 and β = 1.0 , determined via the best trade-off between mean squared error and maximum absolute error after several tries. Optimization is performed in PyTorch 3.9.23 using the Adam optimizer with a learning rate of 10 4 for 1000 epochs.
The trainable lookup table (LUT) entries a 0 and a 1 are initialized using the analytical expressions provided in Equations (19) and (20), respectively. The parameters n 0 , n 1 , and n 2 are set to the Pareto-optimal configuration ( 5 , 3 , 3 ) , as determined in the previous Section 4.2.1. During training, fake quantization is applied in the forward pass. The Straight-Through Estimator (STE) is then employed to approximate the gradient of the rounding operation during backpropagation.
The absolute error distribution evaluated on a test set of 1,000,000 samples is visualized in Figure 3.
We compare three LUT-based exponential approximation methods: (1) Naive-lut, which uses a single LUT over the range [ 0 , 16 ] ; (2) Bi-lut, the uncompensated dual-table approach; and (3) Bi-lut-comp, the compensated dual-table method. The comparison results are summarized in Table 3. The compensated Bipartite method (Bi-lut-comp) reduces the maximum absolute error by approximately 50% compared to the uncompensated version, demonstrating the effectiveness of the gradient-based compensation. Across all error metrics, Bi-lut-comp consistently outperforms Bi-lut-uncomp, while requiring only one-fourth of the LUT entries of Naive-lut. Although its absolute error remains slightly higher than that of Naive-lut (approximately twice), the resulting perplexity (PPL) degradation remains within an acceptable range.

4.3. Low-Cost Division Approximation for Softmax via Log-Domain Transformation

Inspired by previous work [27] on reformulating the Softmax function, we propose a division-free implementation based on lookup tables. Starting from the conventional SafeSoftmax expression, the function can be written as:
f ( x i ) = e x i j = 1 N e x j , i = 1 , 2 , , N .
To avoid expensive division operations, the exponential-to-logarithmic transformation is adopted:
f ( x i ) = e ln   f ( x i ) = exp ( x i ln ( j = 1 N e x j ) ) = exp ( ( x i + ln ( j = 1 N e x j ) ) ) .
The term ln ( e x j ) can be efficiently approximated using a leading-one detector (LOD) and small lookup tables, while the outer exponential is handled by reusing the inner lookup table, as illustrated in the following subsections.

4.3.1. Efficient Approximation of the Logarithmic Sum

Given S u m = e x j , the LOD module detects the most significant bit of S u m in its binary form, decomposing it as:
S u m = 2 k · ( 1 + s ) ,
where k is an integer and s [ 0 , 1 ) is the normalized mantissa. Thus,
ln ( S u m ) = k · ln ( 2 ) + ln ( 1 + s ) .
After SafeSoftmax processing, all input terms satisfy x j 0 , yielding 1 Sum < N . Thus, k [ 0 , log 2 N ) , and only log 2 ( log 2 N ) bits are required to represent its integer part. The fractional part s is quantized to several bits (e.g., 4–8 bits), and its logarithm can be efficiently retrieved from a small LUT.
Truncating s to b s fractional bits introduces a bounded error:
δ = ln S ln S ˜ = ln ( 1 + s ) ln 1 + T ( s ) 0 ,
where S = e x j , S ˜ = 2 k 1 + T ( s ) , and T ( s ) = s 2 b s / 2 b s . Consequently, the overall Softmax output is scaled by α = e δ with a one-sided bound:
Softmax ˜ ( x i ) = e ( x i + ln S ˜ ) = e ( x i + ln S δ ) = Softmax ( x i ) e δ , e δ e 2 b s 1 , e 2 b s 1 + O ( 2 b s ) .
It was observed that truncating s to 4 bits results in a scaling variation of approximately 3–6%. This variation is tolerable for large-scale transformer models because RMSNorm following Softmax exhibits scale invariance. For z R d and α > 0 , the scaling property of RMSNorm can be expressed as:
RMSNorm ϵ ( α z ) = γ α z α 2 z 2 2 / d + ϵ RMSNorm ϵ ( z ) , when ϵ z 2 2 / d .
Thus, RMSNorm is exactly scale-invariant when ϵ = 0 , and approximately invariant when ϵ z 2 2 / d  [28].
To verify the scale-invariance property in Equation (31) under practical conditions, we analyze the relative magnitude of the ϵ term and the relative error of RMSNorm outputs with scaled input. On Wikitext-2, the RMSNorm ϵ is set to 10 6 , and the scaling factor is set to the worst case α = 1.06 corresponding to a 6 % scaling error caused by Softmax approximation. The experiment shows that the median (P50) value of ϵ / ( z 2 2 / d ) is 3.1 × 10 2 , and the 95th percentile is below 1.6 × 10 1 . This indicates that, for most tokens, the normalization term z 2 2 / d dominates ϵ , and RMSNorm therefore operates in an approximately scale-invariant regime. A small fraction of tokens exhibits larger ratios. Since ϵ is 10 6 , the corresponding z 2 2 / d values are small as well, indicating that the hidden-state activations are very small in magnitude. Therefore, even when these activations are scaled by α = 1.06 due to the Softmax approximation, their impact on subsequent computations remains limited.
To directly quantify the effect of input scaling on RMSNorm outputs, we measure the relative 2 deviation between RMSNorm outputs before and after scaling. While the Softmax approximation introduces a 6 % relative scaling perturbation at the input, the resulting RMSNorm output deviation is much smaller: the mean relative 2 deviation is 0.3 % , and the 95th percentile remains below 0.78 % . This demonstrates that RMSNorm effectively suppresses the input scaling error in practice.

4.3.2. Reuse of Exponential Unit

To further reduce hardware cost, the inner-stage exponential e x inner = e x i max ( x ) and the outer-stage exponential e x outer = e ( x i max ( x ) ) ln j e x j max ( x ) share the same lookup-table based exponential unit. First, since both x inner 0 and x outer 0 , the outputs of e x inner and e x outer both lie in the range ( 0 , 1 ] , allowing a unified LUT design for exponential approximation. Second, the input of the outer-stage exponential can be expressed as
x outer = ( x i max ( x ) ) ln e x j max ( x ) = x inner ln e x inner .
Since 1 e x inner < N after SafeSoftmax processing, substituting this range into the logarithmic formulation yields the range of x outer is ( 16 ln N , 0 ] . Again, inputs below 16 are clipped to zero, consistent with the inner exponential LUT input.
Thus, both exponentials can share one hardware unit. The proposed design achieves a complete division-free Softmax computation using only one subtractor and a small lookup table. By leveraging log-domain decomposition and the scale-invariance of RMSNorm, it maintains numerical precision while significantly reducing hardware complexity in Algorithm 1.
Algorithm 1: Proposed Hardware-Efficient Softmax with Log-Domain Approximation
Micromachines 17 00084 i001

4.4. Approximation of Reciprocal Root Computation in RMSNorm

Figure 4 illustrates the statistical distribution of the input to the reciprocal square root operation in RMSNorm, which corresponds to the mean square value d computed across all layers. The dynamic range of d spans several orders of magnitude, making a direct lookup-based implementation infeasible.
To reduce bit-width and enable efficient table access, the denominator is decomposed using the logarithmic leading-one decomposition (LOD) method as:
1 d = 1 2 k ( 1 + s ) = 2 k / 2 · 1 1 + s ,
where k denotes the position of the leading one in d, and s [ 0 , 1 ) represents the fractional part after normalization. For example, if d = 110 . 111 2 , then k = 2 and s = 0 . 10111 2 . Motivated by [21], the mantissa s is truncated to α bits (e.g., α = 4 ), yielding s = 0 . 1011 2 , which is further compensated by a precomputed mean bias to reduce quantization error.
Following the correction approach described in Section 3.3, the truncation error of s can be compensated by using a lookup table (LUT) defined as:
LUT s [ k α ] = 1 1 + s 2 α + 1 1 + ( k α + 1 ) 2 α 1 + k α 2 α ,
where k α is the integer obtained by truncating s to α bits.
Although the exponent term 2 k / 2 seems shift-friendly, its half exponent prevents exact realization through bit shifts. Specifically, when k is even, the factor can be computed as a power of two; however, when k is odd, it becomes
2 k / 2 = 2 k / 2 · 2 1 / 2 = 2 k / 2 / 2 ,
which introduces an additional scaling factor of 2 . Consequently, the baseline design must distinguish between even and odd k values, requiring two separate lookup tables (for 1 / 1 + s and 1 / 2 ( 1 + s ) ) and four conditional branches to select the appropriate case, which increases both control complexity and hardware cost.
To eliminate these redundant operations, a unified approach is proposed. Instead of applying shift-based logic and parity checks, we precompute 2 k / 2 directly using a single small LUT indexed by k, thereby implicitly covering both even and odd cases without explicit multiplication by 1 / 2 . Since the range of d in RMSNorm is bounded, a 5-bit representation ( k [ 0 , 31 ] ) is sufficient, requiring only a 32-entry table for the exponent term. Combining the two lookup stages, the complete reciprocal root operation can be expressed as:
1 d = 2 k / 2 · 1 1 + s LUT k [ k ] · LUT s [ k α ] .
The proposed design minimizes control complexity and memory consumption, utilizing only two compact LUTs together with an integer multiplier: a 32-entry table for the exponent term and a 256-entry table for the mantissa term. The resulting reciprocal root module achieves high precision with minimal hardware overhead, laying the foundation for the proposed hardware-efficient RMSNorm operator described in Algorithm 2.
Algorithm 2: RMSNorm with Separate Lookup Tables
Micromachines 17 00084 i002
As shown in Table 4, we evaluate the approximation accuracy on 500,000 uniformly sampled points from [0, 2048]. Our Hybrid-LUT approach significantly outperforms the Double-LUT baseline [21] in both accuracy and storage efficiency. The compensated version (Hybrid-LUT*) reduces MAE by 82.4% compared to the compensated Double-LUT* while using 41.3% less storage. Although the improvement from error compensation alone is limited, it still shows certain effectiveness. All configurations maintain similar PPL scores, confirming their practical viability for language modeling tasks.

5. Pipelined Implementation of Softmax and RMSNorm Operators

Both Softmax and RMSNorm adopt a unified three-stage pipeline to reduce latency and resource usage. Since we use group-wise fixed-point quantization, we add a fractional-bit alignment unit to unify scaling across groups. Each stage maps to one algorithm phase, enabling high utilization and low dependency.
The complete hardware flow of Softmax is illustrated in Figure 5. In the first stage of the Softmax pipeline, each input value is concatenated with its quantization parameter, namely the fractional-bit position, into a 16-bit short format. Multiple elements are then packed into a 512-bit data block and transmitted to the Softmax processing unit to fully utilize the available bus bandwidth. On-chip, the packed data are unpacked to restore both the input values and their quantization parameters. During this traversal, all elements along the normalization dimension are shifted so that their binary fractional points are aligned to the same position. After alignment, a maximum value search is performed immediately, corresponding to the first loop in the algorithm. After completing n cycles, the detected maximum value is forwarded to the next pipeline stage.
In the second stage, each input x i is processed to compute e x i max ( x ) , followed by accumulation to obtain the sum. Prior to exponential evaluation, inputs exceeding the lookup table (LUT) index range are clipped to prevent overflow. This mechanism can also be exploited to mask invalid elements by setting their values and quantization parameters to large numbers, ensuring their exponential outputs clipped to zero. For the 11-bit input, the lower three bits and upper five bits are used as indices for L U T 0 , while the lower three bits and upper five bits index L U T 1 . The outputs from both lookup tables are summed to generate the exponential value, which is then accumulated across all elements. After another n-cycle accumulation, the resulting sum is passed to the final pipeline stage.
In the third stage, the leading-one detection (LOD) method is employed to decompose the accumulated sum for logarithmic-domain computation. The leading-one position k and mantissa s are extracted and concatenated using logic gates to form the final L U T 3 index. A subsequent fixed bit-shift operation ensures that the computed q_lnsum is aligned with the fractional point of the original sum before accumulation. Finally, the exponential computation unit developed in the second stage is reused in the output stage, achieving efficient hardware reuse and reduced resource overhead.
For the RMSNorm operator, the overall pipeline structure remains the same, with differences only in the operations performed in the second and third stages. The complete hardware flow is illustrated in Figure 6. The first stage follows the same unpacking and fractional-bit alignment procedure as Softmax, where the 16-bit short is decomposed into an 8-bit activation value and its corresponding 8-bit quantization parameter. After alignment, each preprocessed input is streamed to the second stage, which performs squaring and accumulation to compute the mean-square value. After n cycles, the accumulated result is passed to the third stage, where a fixed bit-shift division is applied to obtain the mean value. An LOD-based decomposition is then performed to extract the leading-one position k and the truncated mantissa s, which serve as indices for two lookup tables: LUT_inv_sqrt (dependent on k) and LUT_comp (dependent on s). The corresponding lookup results are multiplied by two integer multipliers to generate the final normalized output. This design requires only two compact lookup tables and two integer multipliers, achieving high numerical precision with minimal hardware cost while preserving a unified pipelined control structure.

6. Experiment Results

6.1. Experimental Environment

The proposed approximation algorithms for Softmax and RMSNorm were integrated into the LLaMA2-7B model. They were deployed on the AMD Alveo U55C (Advanced Micro Devices, Inc., Santa Clara, CA, USA) accelerator card to evaluate hardware resource usage, performance, and energy efficiency. To ensure that the proposed approximations do not introduce unacceptable numerical degradation, model accuracy was evaluated on the Wikitext dataset under identical experimental conditions. In addition, a non-functional requirement (NFR) classification dataset for industrial software development scenarios was used to evaluate the proposed methods in a downstream application task.
Software-level simulation of the proposed approximation algorithms was conducted using the PyTorch framework, while heterogeneous inference was executed through the llama.cpp runtime. The heterogeneous computing platform consisted of an AMD Ryzen 9 7950X (Advanced Micro Devices, Inc., Santa Clara, CA, USA) host processor and a AMD Alveo U55C accelerator card, operating under Ubuntu 20.04.3 LTS (Canonical Group Limited, London, UK) The hardware acceleration circuits were implemented with the Vitis HLS 2022.1 (Advanced Micro Devices, Inc., Santa Clara, CA, USA) toolchain, and bitstreams were generated using Vivado 2022.1 (Advanced Micro Devices, Inc., Santa Clara, CA, USA). The generated bitstream was loaded to the U55C accelerator via a PCIe interface. The accelerator provides abundant on-chip resources, including approximately 1.304 × 10 6 lookup tables (LUTs), 9024 DSP slices, 70.9 Mbit of BRAM, and 16 GB of high-bandwidth memory (HBM), enabling high-throughput computation for transformer-based model inference.

6.2. Datasets

Two datasets were used in this study for evaluating both language modeling accuracy and downstream software engineering requirement classification tasks. The Wikitext-2 dataset [29] is a language modeling corpus constructed from high-quality English Wikipedia articles. It preserves the original document structure while removing machine-generated content. Wikitext-2 is employed as a benchmark for evaluating model perplexity (PPL) and assessing text prediction capability.
The PROMISE-relabeled-NICE dataset, on the other hand, is a benchmark widely used in the software engineering domain for non-functional requirement (NFR) identification and classification. It originates from early studies by Cleland-Huang et al., who manually annotated requirement documents for evaluating automated NFR detection and classification methods. It is later re-labeled by Dalpiaz et al., introducing a multi-label scheme that allows each requirement to simultaneously exhibit F (functional aspects), Q (quality aspects), OnlyF (only functional aspects), and OnlyQ (only quality aspects) attributes. The NFR subset is further extended in the NICE approach [30] into 12 subcategories, and the final dataset contains 622 labeled instances. This dataset is used to evaluate the model performance in the downstream requirement classification task.

6.3. Software Engineering Requirement Classification

To perform multi-label requirement classification in the software engineering domain, a general-purpose prompt was constructed to inform the model of the task background, detailed instructions, required output format, and the concatenated requirement description. The overall structure of the prompt and corresponding output format are illustrated in Figure 7, which defines the instruction template, output schema, and example of requirement-to-label mapping.
The model is quantized to W8A8 precision. To preserve perplexity performance, group-wise quantization is applied to the inputs of both the Softmax and RMSNorm operators, and the quantized model is deployed on the Alveo U55C hardware platform based on the llama.cpp framework. Each input prompt containes approximately 550 tokens, and the corresponding output classification information consisted of about 106 tokens. The measured average latency from receiving a requirement text to generating the complete JSON label output is approximately 6 s per instance. This level of latency is suitable for offline requirement analysis and decision-support scenarios. For requirement engineering practices where analysts determine requirement categories interactively for each item, such latency remains acceptable. The model achieves a precision of 0.7769, a macro recall of 0.6533, and a macro F1 score of 0.7097, as shown in Table 5. Importantly, these results are obtained with the temperature parameter set to zero (‘temp = 0’), which eliminates sampling randomness and ensures completely deterministic predictions. The approximation shows selective impact across categories: while overall performance degradation is minimal ( Δ m a c r o = 0.016 ), Portability (PO) and Fault Tolerance (FT) experience notable declines, whereas Scalability (SC) and Availability (A) show improvement. The core IsFunctional category remains unaffected. This demonstrates engineering applicability with respect to inference latency. Furthermore, additional optimization opportunities remain through prompt compression and output simplification, which could further reduce overall response time and enable real-time or high-concurrency industrial deployment.

6.4. Analysis and Comparison

Table 6 reports the perplexity (PPL) of the proposed Softmax and RMSNorm approximation methods under different quantization and deployment settings on the Wikitext dataset. The FP16 configuration serves as the baseline, while the W8A8 setup introduces quantization and operator approximations stepwise to assess their impact on model accuracy.
Under FP16 precision, PyTorch and CPU simulation yield nearly identical PPLs (5.4762 vs. 5.4736), confirming that platform differences do not affect model behavior in the absence of quantization or approximation. Across all configurations, the discrepancy between CPU simulation and FPGA deployment remains below 0.002, confirming that our design precisely reproduces the software model. Based on the CPU results in Table 6, the total perplexity increase from the FP16 baseline (PPL = 5.4736) to the configuration with both Softmax and RMSNorm approximations (PPL = 5.4973) is 0.0237. Among this increase, W8A8 quantization alone contributes 0.0204 (from 5.4736 to 5.4940), accounting for approximately 86% of the total, while the combined Softmax and RMSNorm approximations contribute the remaining 14%.
To explicitly quantify the impact of individual nonlinear operator approximations under quantization, we conduct an operator-level ablation study on Wikitext-2 under W8A8 group-wise quantization (group size = 32). In this study, Softmax and RMSNorm are approximated independently while keeping all other components unchanged, allowing us to isolate the contribution of each approximation to the overall perplexity degradation.
As shown in Table 7, both Softmax and RMSNorm approximations introduce only marginal additional perplexity degradation beyond quantization. Among the evaluated components, Softmax exhibits slightly higher sensitivity to approximation, especially when log-domain division is applied, due to the exponential and normalization operations involved. In contrast, RMSNorm with the hybrid LUT-based reciprocal square root introducing only +0.0015. These results confirm that the proposed operator-level approximations are well-balanced.
The hardware comparisons in Table 8 and Table 9 are based on resource utilization results reported in the original publications. The FPGA platforms used in the compared works are mainstream Xilinx devices that share a common programmable logic abstraction, including LUT-based logic fabric and DSP slices, enabling meaningful operator-level comparison. To improve fairness, we additionally report the resource utilization ratio (%) on our target device. Although different FPGA devices and toolchains may lead to variations in absolute resource usage, such variations are generally limited and do not affect the overall trends reflected in our results. Given the very low utilization levels of the proposed operators, the impact of cross-platform differences is further reduced, making operator-level qualitative comparison across different FPGA platforms reasonable.
The hardware comparisons in Table 8 and Table 9 are based on results reported in prior works. The compared designs are implemented on different FPGA devices that belong to the same generation and fabrication process. Differences among these devices mainly lie in available resource capacity, rather than architectural differences. Additionally, since the proposed Softmax and RMSNorm operators occupy less than 5% of on-chip resources, and all compared designs are implemented using the Vivado toolchain, the impact of placement-and-routing variability is negligible.
Table 8 compares the hardware resource utilization of the proposed Softmax implementation with several representative prior works. Compared with previous designs, the proposed implementation achieves the lowest DSP usage and significantly better LUT efficiency. Specifically, on the Xilinx Alveo U55C platform, the design operates at 300 MHz and consumes only 3112 LUTs and 6215 registers, representing an 83% reduction in LUT utilization compared with [31], while maintaining comparable register usage to lightweight implementations such as [32]. Furthermore, by employing a log-domain transformation and a Bi-lut-comp scheme to replace exponential and division operations, the proposed design requires zero DSPs, whereas [33] rely on up to 128 DSPs for high-precision exponentiation. Although the method uses 10.5 BRAMs for table storage, this overhead remains substantially lower than the 72 KB memory reported in [34] for floating-point computation. These results demonstrate that the proposed Softmax achieves superior hardware efficiency and is highly suitable for low-power or resource-constrained FPGA deployment scenarios.
Table 8. Resource utilization comparison of the proposed Softmax implementation with representative prior works.
Table 8. Resource utilization comparison of the proposed Softmax implementation with representative prior works.
FPGA DeviceOursRef. [31]Ref. [35]Ref. [33]Ref. [19]Ref. [34]Ref. [32]
TypeXilinx Alveo U55CXilinx ZynqXilinx Kintex-7 KC705Xilinx ZCU102Xilinx XCVU13PXilinx Virtex6 ML605Xilinx Zynq-7000 ZC706
Freq. (MHz)300150154300200400294
LUT3112 (0.239%)17,870222922,86521,1903001858
Registers6215 (0.238%)16,40022421,77032,6235582086
DSP0 (0%)128058
BRAM10.5 (0.530%)0072K
Table 9 compares the hardware resource utilization of the proposed RMSNorm implementation with several representative prior works. Our implementation operates at 300 MHz while utilizing only 3954 LUTs and 5810 registers—substantially fewer than the 10k+ LUT designs reported in [19,33], and over 95% fewer logic resources compared with [22]. Moreover, the design consumes only 18 DSPs for reciprocal square root approximation, significantly less than the 74, 129, and 1025 DSPs required in [19,22,33] for floating-point computation, underscoring its hardware-friendly nature. In terms of memory usage, 16 BRAMs are employed for lookup-table storage—slightly higher than some integer-based implementations, yet far below the 27.5 BRAMs required for CORDIC iterations in [19]. Overall, the proposed RMSNorm achieves high numerical precision with minimal hardware overhead, making it well-suited for efficient FPGA deployment.
To provide a clearer system-level perspective, we analyze the resource utilization and scalability of the proposed Softmax and RMSNorm operators on the AMD Alveo U55C FPGA. As reported in Table 8 a single Softmax instance consumes only 0.239% of LUTs, 0.238% of registers, 0% of DSPs, and 0.53% of BRAM. Similarly, a single RMSNorm instance occupies 0.303% of LUTs, 0.223% of registers, 0.199% of DSPs, and 0.81% of BRAM as shown in Table 9. When deployed together as a paired Softmax-RMSNorm pipeline, the combined resource usage remains small, amounting to 0.54% of LUTs, 0.46% of registers, 0.20% of DSPs, and 1.35% of BRAM. Such a low per-instance footprint allows the proposed operators to be replicated many times on a single device. Based on available on-chip resources, up to approximately 192 Softmax instances, 126 RMSNorm instances, or 76 paired Softmax–RMSNorm pipelines could theoretically be instantiated in parallel on U55C. In all cases, BRAM capacity becomes the first limiting resource, while LUT, register, and DSP utilization remains well below saturation. This analysis indicates that the proposed operators are lightweight, highly scalable, and unlikely to form a bottleneck in a full Transformer inference pipeline.
Table 9. Resource utilization comparison of the proposed RMSNorm implementation with representative prior works.
Table 9. Resource utilization comparison of the proposed RMSNorm implementation with representative prior works.
FPGA DeviceOursRef. [33]Ref. [19]Ref. [22]Ref. [36]
TypeXilinx Alveo U55CXilinx ZCU102Xilinx XCVU13PXilinx U280Xilinx Alveo U50
Freq. (MHz)300300200100100
LUT3954 (0.303%)10,55810,55186K2817
Registers5810 (0.223%)4038532525K2145
DSP18 (0.199%)7412910257
BRAM16 (0.810%)927.52
The proposed Softmax and RMSNorm operators are integrated into the standard Transformer inference pipeline, where Softmax is applied within the self-attention module and RMSNorm is used both before and after attention along the residual paths. In our implementation, activations are first grouped and quantized to 8-bit precision, after which all Softmax and RMSNorm computations are carried out using the proposed fixed-point approximation modules. Although these operators account for fewer FLOPs than attention matrix multiplications and MLP layers, they are executed for every layer and every token and therefore lie on the critical inference path.
To evaluate the practical performance of the proposed operators, we report the measured execution latency and power consumption of the FPGA implementation under representative workload configurations. Power consumption is estimated using the Vivado Report Power utility on the post-implementation design at 300 MHz. For Softmax with a data size of 32 × 2048 , the FPGA implementation achieves a latency of 0.292 ms at 300 MHz, with a power consumption of 17.7 W. This corresponds to an effective throughput of 224.4 M elements/s. For RMSNorm with a data size of 128 × 4096 , the measured latency is 1.837 ms, while consuming 17.6 W. The corresponding throughput is 285.4 M elements/s. These results reflect the operator-level execution cost of the proposed pipelined designs on FPGA and complement the resource and scalability analysis discussed above.

7. Conclusions

This paper presented a hardware-efficient approximation and accelerator framework for the Softmax and RMSNorm operators, targeting transformer inference acceleration on FPGA platforms. By combining range-reduced bipartite lookup tables with bit-width optimization, the proposed Softmax achieves high numerical accuracy while eliminating costly division operations through log-domain reformulation. For RMSNorm, a leading-one-based logarithmic decomposition and Hybrid LUT-based reciprocal–root approximation effectively replace floating-point arithmetic with integer operations, preserving precision and simplifying control logic.
Experimental results show that, when integrated into the LLaMA2-7B model, the proposed designs maintain nearly identical accuracy to the FP16 baseline, with only 0.026 perplexity deviation on Wikitext-2. On the Xilinx Alveo U55C, the Softmax and RMSNorm modules run at 300 MHz while consuming only 3112 and 3954 LUTs, respectively, and requiring merely 0 and 18 DSPs—achieving substantial resource savings. Both operators run at 300 MHz with low operator-level latency and modest power consumption, while requiring only a small fraction of on-chip logic and DSP resources.
Overall, the proposed approximation and accelerator achieve a favorable balance between precision, efficiency, and generality, demonstrating strong potential for low-power transformer inference and other resource-constrained AI deployments on FPGA platforms.

Author Contributions

Conceptualization, Y.K. and D.W.; methodology, Y.K. and D.W.; software, Y.K.; validation, Y.K.; formal analysis, Y.K. and D.W.; investigation, Y.K. and D.W.; resources, D.W.; data curation, Y.K. and D.W.; writing—original draft preparation, Y.K.; writing—review and editing, D.W.; visualization, Y.K.; supervision, D.W.; project administration, D.W. All authors have read and agreed to the published version of the manuscript.

Funding

This work was supported by Beijing Natural Science Foundation under Grant L244050 and L252018.

Data Availability Statement

The original contributions presented in the study are included in the article, further inquiries can be directed to the corresponding author.

Acknowledgments

Thanks to the editor and reviewers for their insightful viewpoints for improving this paper. During the preparation of this manuscript, the author(s) used [GenAI, GPT5] for the purposes of [language polishing]. The authors have reviewed and edited the output and take full responsibility for the content of this publication.

Conflicts of Interest

The authors declare no conflicts of interest.

References

  1. Vaswani, A.; Shazeer, N.; Parmar, N.; Uszkoreit, J.; Jones, L.; Gomez, A.N.; Kaiser, Ł.; Polosukhin, I. Attention is all you need. Adv. Neural Inf. Process. Syst. 2017, 30, 5998–6008. [Google Scholar]
  2. Zhang, S.; Roller, S.; Goyal, N.; Artetxe, M.; Chen, M.; Chen, S.; Dewan, C.; Diab, M.; Li, X.; Lin, X.V.; et al. Opt: Open pre-trained transformer language models. arXiv 2022, arXiv:2205.01068. [Google Scholar] [CrossRef]
  3. Touvron, H.; Lavril, T.; Izacard, G.; Martinet, X.; Lachaux, M.A.; Lacroix, T.; Rozière, B.; Goyal, N.; Hambro, E.; Azhar, F.; et al. Llama: Open and efficient foundation language models. arXiv 2023, arXiv:2302.13971. [Google Scholar] [CrossRef]
  4. Touvron, H.; Martin, L.; Stone, K.; Albert, P.; Almahairi, A.; Babaei, Y.; Bashlykov, N.; Batra, S.; Bhargava, P.; Bhosale, S.; et al. Llama 2: Open foundation and fine-tuned chat models. arXiv 2023, arXiv:2307.09288. [Google Scholar] [CrossRef]
  5. Thompson, N.C.; Greenewald, K.; Lee, K.; Manso, G.F. The computational limits of deep learning. arXiv 2020, arXiv:2007.05558. [Google Scholar]
  6. Lu, L.; Jin, Y.; Bi, H.; Luo, Z.; Li, P.; Wang, T.; Liang, Y. Sanger: A co-design framework for enabling sparse attention using reconfigurable architecture. In Proceedings of the MICRO-54: 54th Annual IEEE/ACM International Symposium on Microarchitecture, Virtual, 18–22 October 2021; pp. 977–991. [Google Scholar]
  7. Zeng, K.; Ma, Q.; Wu, J.W.; Chen, Z.; Shen, T.; Yan, C. FPGA-based accelerator for object detection: A comprehensive survey. J. Supercomput. 2022, 78, 14096–14136. [Google Scholar] [CrossRef]
  8. Kachris, C. A survey on hardware accelerators for large language models. Appl. Sci. 2025, 15, 586. [Google Scholar] [CrossRef]
  9. Sanh, V.; Wolf, T.; Rush, A. Movement pruning: Adaptive sparsity by fine-tuning. Adv. Neural Inf. Process. Syst. 2020, 33, 20378–20389. [Google Scholar]
  10. Antolini, A.; Zavalloni, F.; Lico, A.; Quqa, S.; Greco, L.; Mangia, M.; Pareschi, F.; Pasotti, M.; Franchi Scarselli, E. The Role of Phase-Change Memory in Edge Computing and Analog In-Memory Computing: An Overview of Recent Research Contributions and Future Challenges. Sensors 2025, 25, 3618. [Google Scholar] [CrossRef] [PubMed]
  11. Ashok, M.; Maji, S.; Zhang, X.; Cohn, J.; Chandrakasan, A.P. Digital In-Memory Compute for Machine Learning Applications With Input and Model Security. IEEE J. Solid-State Circuits 2025, 60, 3390–3402. [Google Scholar] [CrossRef]
  12. Kim, R.; Lee, D.; Kim, J.; Park, J.; Lee, S.E. Hardware Accelerator for Approximation-Based Softmax and Layer Normalization in Transformers. Electronics 2025, 14, 2337. [Google Scholar] [CrossRef]
  13. Bhandare, A.; Sripathi, V.; Karkada, D.; Menon, V.; Choi, S.; Datta, K.; Saletore, V. Efficient 8-bit quantization of transformer neural machine language translation model. arXiv 2019, arXiv:1906.00532. [Google Scholar] [CrossRef]
  14. Zafrir, O.; Boudoukh, G.; Izsak, P.; Wasserblat, M. Q8bert: Quantized 8bit bert. In Proceedings of the 2019 Fifth Workshop on Energy Efficient Machine Learning and Cognitive Computing-NeurIPS Edition (EMC2-NIPS), Vancouver, BC, Canada, 13 December 2019; pp. 36–39. [Google Scholar]
  15. Milakov, M.; Gimelshein, N. Online normalizer calculation for softmax. arXiv 2018, arXiv:1805.02867. [Google Scholar] [CrossRef]
  16. Mei, Z.; Dong, H.; Wang, Y.; Pan, H. TEA-S: A tiny and efficient architecture for PLAC-based softmax in transformers. IEEE Trans. Circuits Syst. II Express Briefs 2023, 70, 3594–3598. [Google Scholar] [CrossRef]
  17. Koca, N.A.; Do, A.T.; Chang, C.H. Hardware-efficient softmax approximation for self-attention networks. In Proceedings of the 2023 IEEE International Symposium on Circuits and Systems (ISCAS), Monterey, CA, USA, 21–25 May 2023; pp. 1–5. [Google Scholar]
  18. Wang, W.; Zhou, S.; Sun, W.; Sun, P.; Liu, Y. Sole: Hardware-software co-design of softmax and layernorm for efficient transformer inference. In Proceedings of the 2023 IEEE/ACM International Conference on Computer Aided Design (ICCAD), San Francisco, CA, USA, 28 October–2 November 2023; pp. 1–9. [Google Scholar]
  19. Lu, S.; Wang, M.; Liang, S.; Lin, J.; Wang, Z. Hardware accelerator for multi-head attention and position-wise feed-forward in the transformer. In Proceedings of the 2020 IEEE 33rd International System-on-Chip Conference (SOCC), Las Vegas, NV, USA, 8–11 September 2020; pp. 84–89. [Google Scholar]
  20. Yu, J.; Park, J.; Park, S.; Kim, M.; Lee, S.; Lee, D.H.; Choi, J. NN-LUT: Neural approximation of non-linear operations for efficient transformer inference. In Proceedings of the 59th ACM/IEEE Design Automation Conference, Francisco, CA, USA, 10–14 July 2022; pp. 577–582. [Google Scholar]
  21. Li, W.; Lyu, D.; Wang, G.; Hu, A.; Xu, N.; He, G. Hardware-oriented algorithms for softmax and layer normalization of large language models. Sci. China Inf. Sci. 2024, 67, 200404. [Google Scholar] [CrossRef]
  22. Peng, T.; Xia, T.; Qin, J.; Zhang, S.Q. HAAN: A Holistic Approach for Accelerating Normalization Operations in Large Language Models. In Proceedings of the 2025 Design, Automation & Test in Europe Conference (DATE), Lyon, France, 31 March–2 April 2025; pp. 1–7. [Google Scholar]
  23. Paszke, A.; Gross, S.; Chintala, S.; Chanan, G.; Yang, E.; DeVito, Z.; Lin, Z.; Desmaison, A.; Antiga, L.; Lerer, A. Automatic differentiation in PyTorch. In Proceedings of the NeurIPS 2017 Workshop on Autodiff (The Future of Gradient-Based Machine Learning Software & Techniques), Long Beach, CA, USA, 9 December 2017; Available online: https://openreview.net/forum?id=BJJsrmfCZ (accessed on 29 December 2025).
  24. Seide, F.; Agarwal, A. CNTK: Microsoft’s Open-Source Deep-Learning Toolkit. In Proceedings of the 22nd ACM SIGKDD International Conference on Knowledge Discovery and Data Mining, San Francisco, CA, USA, 13–17 August 2016; p. 2135. [Google Scholar]
  25. Schulte, M.J.; Stine, J.E. Symmetric bipartite tables for accurate function approximation. In Proceedings of the 13th IEEE Sympsoium on Computer Arithmetic, Asilomar, CA, USA, 6–9 July 1997; pp. 175–183. [Google Scholar]
  26. Hu, X.; Cheng, Y.; Yang, D.; Yuan, Z.; Yu, J.; Xu, C.; Zhou, S. I-llm: Efficient integer-only inference for fully-quantized low-bit large language models. arXiv 2024, arXiv:2405.17849. [Google Scholar]
  27. Wang, M.; Lu, S.; Zhu, D.; Lin, J.; Wang, Z. A high-speed and low-complexity architecture for softmax function in deep learning. In Proceedings of the 2018 IEEE Asia Pacific Conference on Circuits and Systems (APCCAS), Chengdu, China, 26–30 October 2018; pp. 223–226. [Google Scholar]
  28. Zhang, B.; Sennrich, R. Root mean square layer normalization. Adv. Neural Inf. Process. Syst. 2019, 32, 12381–12392. Available online: https://proceedings.neurips.cc/paper/2019/file/1e8a19426224ca89e83cef47f1e7f53b-Paper.pdf (accessed on 29 December 2025).
  29. Merity, S.; Xiong, C.; Bradbury, J.; Socher, R. Pointer sentinel mixture models. arXiv 2016, arXiv:1609.07843. [Google Scholar] [CrossRef]
  30. Rejithkumar, G.; Anish, P.R. Nice: Non-functional requirements identification, classification, and explanation using small language models. In Proceedings of the 2025 IEEE/ACM 47th International Conference on Software Engineering: Software Engineering in Practice (ICSE-SEIP), Ottawa, ON, Canada, 27 April–3 May 2025; pp. 284–295. [Google Scholar]
  31. Sun, Q.; Di, Z.; Lv, Z.; Song, F.; Xiang, Q.; Feng, Q.; Fan, Y.; Yu, X.; Wang, W. A high speed softmax VLSI architecture based on basic-split. In Proceedings of the 2018 14th IEEE International Conference on Solid-State and Integrated Circuit Technology (ICSICT), Qingdao, China, 31 October–3 November 2018; pp. 1–3. [Google Scholar]
  32. Zhu, D.; Lu, S.; Wang, M.; Lin, J.; Wang, Z. Efficient precision-adjustable architecture for softmax function in deep learning. IEEE Trans. Circuits Syst. II Express Briefs 2020, 67, 3382–3386. [Google Scholar] [CrossRef]
  33. Huang, M.; Luo, J.; Ding, C.; Wei, Z.; Huang, S.; Yu, H. An integer-only and group-vector systolic accelerator for efficiently mapping vision transformer on edge. IEEE Trans. Circuits Syst. I Regul. Pap. 2023, 70, 5289–5301. [Google Scholar] [CrossRef]
  34. Chughtai, M.K.; Babar, M.B.; Qadri, M.Y.; Qayyum, U. A high speed and resource efficient approximation of softmax loss function. In Proceedings of the 2019 16th International Bhurban Conference on Applied Sciences and Technology (IBCAST), Islamabad, Pakistan, 8–12 January 2019; pp. 526–530. [Google Scholar]
  35. Gao, Y.; Liu, W.; Lombardi, F. Design and implementation of an approximate softmax layer for deep neural networks. In Proceedings of the 2020 IEEE International Symposium on Circuits and Systems (ISCAS), Seville, Spain, 12–14 October 2020; pp. 1–5. [Google Scholar]
  36. Wang, T.; Gong, L.; Wang, C.; Yang, Y.; Gao, Y.; Zhou, X.; Chen, H. Via: A novel vision-transformer accelerator based on fpga. IEEE Trans. Comput.-Aided Des. Integr. Circuits Syst. 2022, 41, 4088–4099. [Google Scholar] [CrossRef]
Figure 1. The bipartite table method. The method partitions the input and performs parallel lookup for high-precision approximation accelerator.
Figure 1. The bipartite table method. The method partitions the input and performs parallel lookup for high-precision approximation accelerator.
Micromachines 17 00084 g001
Figure 2. Two-Stage Filtering and Pareto-Optimal Configurations. The green five-pointed star highlights the selected configuration ( n 0 , n 1 , n 2 ) = ( 5 , 3 , 3 ) .
Figure 2. Two-Stage Filtering and Pareto-Optimal Configurations. The green five-pointed star highlights the selected configuration ( n 0 , n 1 , n 2 ) = ( 5 , 3 , 3 ) .
Micromachines 17 00084 g002
Figure 3. Comparison of absolute error distributions before and after compensation.
Figure 3. Comparison of absolute error distributions before and after compensation.
Micromachines 17 00084 g003
Figure 4. Distribution of the input to the reciprocal square root operation in RMSNorm. The input d spans a wide dynamic range, motivating the use of logarithmic leading-one decomposition (LOD) to constrain it into a normalized interval [ 1 , 2 ) .
Figure 4. Distribution of the input to the reciprocal square root operation in RMSNorm. The input d spans a wide dynamic range, motivating the use of logarithmic leading-one decomposition (LOD) to constrain it into a normalized interval [ 1 , 2 ) .
Micromachines 17 00084 g004
Figure 5. Hardware architecture of the proposed three-stage Softmax pipeline, including input unpacking, exponential computation, and logarithmic-domain normalization.
Figure 5. Hardware architecture of the proposed three-stage Softmax pipeline, including input unpacking, exponential computation, and logarithmic-domain normalization.
Micromachines 17 00084 g005
Figure 6. Hardware pipeline of the RMSNorm operator. The overall structure follows the same three-stage design as Softmax, with specific modifications in the squaring, accumulation, and inverse square-root computation stages.
Figure 6. Hardware pipeline of the RMSNorm operator. The overall structure follows the same three-stage design as Softmax, with specific modifications in the squaring, accumulation, and inverse square-root computation stages.
Micromachines 17 00084 g006
Figure 7. Illustration of the requirement classification prompt and output format. The upper part shows the designed instruction prompt used for model inference, and the lower part presents the corresponding structured JSON output.
Figure 7. Illustration of the requirement classification prompt and output format. The upper part shows the designed instruction prompt used for model inference, and the lower part presents the corresponding structured JSON output.
Micromachines 17 00084 g007
Table 1. Different configurations of input and output fractional bitwidths.
Table 1. Different configurations of input and output fractional bitwidths.
Input Fraction BitwidthOutput Fraction BitwidthPPL
6145.5013
6155.5002
7145.4993
7155.4940
Table 2. Error experiments under different bit-width configuration.
Table 2. Error experiments under different bit-width configuration.
Configuration ( n 0 , n 1 , n 2 ) MSEMAEMAXTotal Storage (bits)PPL
(5, 3, 3)0.000023390.003576130.01893544512 × 16 (8192) 5.4955 ± 0.02154
(5, 4, 2)0.000003070.001410500.00530612640 × 16 (10,240) 5.4948 ± 0.02150
(6, 3, 2)0.000002390.001268170.00463378768 × 16 (12,288) 5.4944 ± 0.02149
Table 3. Accuracy and storage requirements comparison under (5, 3, 3) configuration.
Table 3. Accuracy and storage requirements comparison under (5, 3, 3) configuration.
MethodMSEMAEMAXTotal Storage (bit)PPL
Naive-lut0.000002200.001237270.003890082048 × 15 (30,720)5.4943 ± 0.02146
Bi-lut-uncomp0.000023390.003576130.01893544512 × 15 (7680)5.4949 ± 0.02157
Bi-lut-comp (ours)0.000005100.001764820.00784302512 × 15 (7680)5.4946 ± 0.02147
Table 4. Accuracy and storage comparison for 1 / d approximation.
Table 4. Accuracy and storage comparison for 1 / d approximation.
MethodRMSE ( × 10 3 )MAE ( × 10 3 )MAX ( × 10 3 )Total Storage (bit)PPL
Double-LUT [21]74.60023.475362.39 256 × 16 + 256 × 16 (8192) 5.5010 ± 0.02144
Double-LUT * [21]72.08222.305362.74 256 × 16 + 256 × 16 (8192) 5.5008 ± 0.02157
Hybrid-LUT (ours)18.0053.9321187.88 256 × 16 + 34 × 21 (4810) 5.4956 ± 0.02148
Hybrid-LUT * (ours)17.9213.9184186.88 256 × 16 + 34 × 21 (4810) 5.4955 ± 0.02147
* Methods with asterisk indicate versions with error compensation.
Table 5. Performance Comparison of NFR Classification Before and After Model Approximation (F1-Score).
Table 5. Performance Comparison of NFR Classification Before and After Model Approximation (F1-Score).
Requirement Category (Label)After ApproximationOriginal FP16 ModelDifference ( Δ )
IsFunctional0.880.880.00
Availability (A)0.860.83+0.03
Look & Feel (LF)0.870.85+0.02
Scalability (SC)0.860.79+0.07
Legal (L)0.830.81+0.02
Usability (US)0.770.73+0.04
Security (SE)0.720.76−0.04
IsQuality0.720.70+0.02
Performance (PE)0.700.67+0.03
Fault Tolerance (FT)0.670.78−0.11
Portability (PO)0.510.71−0.20
Maintainability (MN)0.450.48−0.03
Operability (O)0.400.45−0.05
Macro Average0.7100.726−0.016
Table 6. Accuracy comparison of Softmax and RMSNorm approximation methods across platforms on the Wikitext dataset. Here, “CPU” denotes the software simulation environment implemented in the llama.cpp framework, used to verify the numerical equivalence of the proposed approximation before FPGA deployment.
Table 6. Accuracy comparison of Softmax and RMSNorm approximation methods across platforms on the Wikitext dataset. Here, “CPU” denotes the software simulation environment implemented in the llama.cpp framework, used to verify the numerical equivalence of the proposed approximation before FPGA deployment.
QuantizationConfigurationPyTorchCPUCPU+FPGAPPL
FP165.4762
5.4736
5.4825
W8A85.4940
5.4799
+Softmax_Approx5.4971
5.4984
5.4792
+RMSNorm_Approx5.4955
5.4967
5.4821
+Softmax_A+RMSNorm_A5.4973
5.4992
Table 7. Operator-level ablation of Softmax and RMSNorm approximations under W8A8 group-wise quantization (group size = 32) on CPU.
Table 7. Operator-level ablation of Softmax and RMSNorm approximations under W8A8 group-wise quantization (group size = 32) on CPU.
ComponentApproximation VariantPPL Δ PPL
BaselineQuantization only (no approximation)5.4940
SoftmaxLUT-based exp + standard division5.4951+0.0011
LUT-based exp + log-domain division (ours)5.4971+0.0021
RMSNormstandard division5.4958+0.0018
Hybrid LUT-based division (ours)5.4955+0.0015
Disclaimer/Publisher’s Note: The statements, opinions and data contained in all publications are solely those of the individual author(s) and contributor(s) and not of MDPI and/or the editor(s). MDPI and/or the editor(s) disclaim responsibility for any injury to people or property resulting from any ideas, methods, instructions or products referred to in the content.

Share and Cite

MDPI and ACS Style

Kang, Y.; Wang, D. Hardware-Oriented Approximations of Softmax and RMSNorm for Efficient Transformer Inference. Micromachines 2026, 17, 84. https://doi.org/10.3390/mi17010084

AMA Style

Kang Y, Wang D. Hardware-Oriented Approximations of Softmax and RMSNorm for Efficient Transformer Inference. Micromachines. 2026; 17(1):84. https://doi.org/10.3390/mi17010084

Chicago/Turabian Style

Kang, Yiwen, and Dong Wang. 2026. "Hardware-Oriented Approximations of Softmax and RMSNorm for Efficient Transformer Inference" Micromachines 17, no. 1: 84. https://doi.org/10.3390/mi17010084

APA Style

Kang, Y., & Wang, D. (2026). Hardware-Oriented Approximations of Softmax and RMSNorm for Efficient Transformer Inference. Micromachines, 17(1), 84. https://doi.org/10.3390/mi17010084

Note that from the first issue of 2016, this journal uses article numbers instead of page numbers. See further details here.

Article Metrics

Back to TopTop