[Paper Review] Efficient Softmax Approximation for Deep Neural Networks with Attention Mechanism
This paper proposes two LUT-based methods for efficient softmax approximation in attention-based deep neural networks, enabling hardware acceleration without costly dividers. The approach achieves under 1% accuracy loss with 8-bit quantization across diverse NLP and vision tasks, demonstrating strong generalization and low memory overhead (700 bytes).
There has been a rapid advance of custom hardware (HW) for accelerating the inference speed of deep neural networks (DNNs). Previously, the softmax layer was not a main concern of DNN accelerating HW, because its portion is relatively small in multi-layer perceptron or convolutional neural networks. However, as the attention mechanisms are widely used in various modern DNNs, a cost-efficient implementation of softmax layer is becoming very important. In this paper, we propose two methods to approximate softmax computation, which are based on the usage of LookUp Tables (LUTs). The required size of LUT is quite small (about 700 Bytes) because ranges of numerators and denominators of softmax are stable if normalization is applied to the input. We have validated the proposed technique over different AI tasks (object detection, machine translation, sentiment analysis, and semantic equivalence) and DNN models (DETR, Transformer, BERT) by a variety of benchmarks (COCO17, WMT14, WMT17, GLUE). We showed that 8-bit approximation allows to obtain acceptable accuracy loss below $1.0\%$.
Motivation & Objective
- Address the growing computational cost of softmax layers in attention-based models like Transformers and BERT, especially in resource-constrained edge environments.
- Overcome the inefficiency of offloading softmax computation to host CPUs in edge accelerators, which hinders performance in latency-sensitive NLP workloads.
- Develop a hardware-friendly softmax approximation method that avoids complex divisions and reduces power consumption and latency in on-device inference.
- Validate the method across diverse AI tasks and models to ensure generalization and robustness under varying sequence lengths and model architectures.
Proposed method
- Use piecewise-constant approximation of the softmax function via pre-computed lookup tables (LUTs) to replace direct computation.
- Leverage input normalization to stabilize the range of numerators and denominators, enabling a compact LUT size (~700 bytes) across diverse models.
- Implement two variants: one using a single LUT for the entire softmax computation, and another using separate LUTs for numerators and denominators to improve precision.
- Integrate the LUT-based softmax into hardware accelerators (e.g., NPUs) to eliminate the need for high-area divider units, reducing power and latency.
- Apply the method during post-training quantization (PTQ-D) without requiring retraining, ensuring compatibility with existing quantization workflows.
- Optimize LUT size and resolution (e.g., 256–512 bytes) to balance accuracy and memory footprint, especially for models with high-magnitude activations like DETR+DC5.
Experimental results
Research questions
- RQ1Can a compact LUT-based softmax approximation achieve high accuracy while minimizing hardware complexity in edge AI accelerators?
- RQ2How does the proposed method perform across diverse attention-based models (e.g., BERT, DETR, Transformer) and tasks (NLP, object detection)?
- RQ3What is the impact of LUT size and quantization precision (e.g., 8-bit) on accuracy loss in models with high-magnitude softmax inputs?
- RQ4How does the LUT-based approximation compare to standard PTQ-D quantization in terms of accuracy degradation and generalization?
- RQ5To what extent does the method generalize to models with skewed activation distributions, such as DETR with dilation (DC5) layers?
Key findings
- The proposed LUT-based softmax approximation achieves less than 1.0% accuracy loss across all evaluated tasks (object detection, machine translation, sentiment analysis, semantic equivalence) when using 8-bit quantization.
- For machine translation (WMT14/WMT17), the BLEU score deviation from the full-precision baseline was below 0.5%, indicating minimal performance degradation.
- In sentiment analysis and semantic equivalence (GLUE benchmark), the accuracy drop due to the LUT method was consistently smaller than that caused by PTQ-D quantization alone.
- For DETR models with dilation (DETR+DC5), increasing LUT size from 256 to 512 bytes reduced accuracy drop from 9% to 3% at 8-bit precision, showing scalability.
- The method generalizes well across models: DETR, BERT, and Transformer showed consistent performance with minimal accuracy loss, confirming robustness.
- The LUT size remains small (around 700 bytes), making it practical for deployment on memory-constrained edge devices without significant area or power overhead.
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.