應用於大型語言模型中之高效能線性與非線性運算的高速Transformer硬體加速器

A High-Speed Hardware-Accelerated Transformer for Efficient Linear and Non-Linear Operations in Large Language Models

檔案

全文未公開。

日期

2025

類型

語言

英文

摘要

現今各領域的尖端AI模型,幾乎都包含Transformer架構,與先前CNN和RNN架構時代的運算一樣,主要為線性運算如矩陣乘法、Fully connected layer,和非線性運算如Softmax、Activation function、Normalization,但隨著模型增大和應用任務更複雜,非線性運算比例快速提高,在大型語言模型中(LLM)甚至突破50%,且非線性運算用到的公式各不相同,無法有效的用同種方法加速運算。
本論文為解決上述問題,設計出不需要重新訓練和fine-tune模型的線性和非線性運算加速方法。非線性運算部分,將自然數指數及開根號,用2為底指數逼近,並搭配Floating point (FP)格式,讓2為底指數和除法能用加減法和bit shift替代近似原值,使得電路最長的Critical path timing降至FP的加減法,大幅減少整體運算時間39.66%,簡化電路複雜度使面積降低27.41%。
線性部分使用1 bit量化Query,Key的矩陣乘法運算,將估計後數值太小的運算Pruning,相較於其他論文使用延遲較長的複雜硬體估算,雖然加速能減少48.12%運算時間,但面積會比實際算一遍的電路多出82.42%,我們的方法能減少29.43%運算時間,但面積只會多12.69%。
為驗證加速方法的有效性,使用只含有Transformer的LLM, Bidirectional Encoder Representations from Transformers (BERT)來驗證加速方法的精確度,將我們有做的加速部分跟原版本對比,使用全部非線性(Softmax, GELU, Layer Normalization)加速方法下,準確度為原本的99.78%,能減少58.06%運算時間,使用全部線性和非線性加速方法,準確度能維持原本的99.54%,能減少48.54%運算時間。
Today's AI models across various domains almost universally incorporate the Transformer architecture. Similar to the computational patterns of earlier CNN and RNN architectures, these models primarily involve linear operations like matrix multiplication and fully connected layers, and non-linear operations such as Softmax, Activation functions, and Normalization. However, as models grow larger and application tasks become more complex, the proportion of non-linear operations has rapidly increased, even exceeding 50% in Large Language Models (LLMs). The diverse formulas used in non-linear operations also make it challenging to accelerate them effectively using a single method.
To address these challenges, this paper designs acceleration methods for both linear and non-linear operations that don't require retraining or fine-tuning existing models. For the non-linear portion, we approximate natural exponential and square root functions using base-2 exponents. By leveraging the Floating Point (FP) format, base-2 exponentiation and division can be approximated using addition, subtraction, and bit shifts. This reduces the longest critical path timing in the circuit to that of FP addition/subtraction, significantly cutting overall computation time by 39.66% and simplifying circuit complexity to reduce area by 27.41%.
For the linear operations, we use 1-bit quantization for the Query and Key matrix multiplications and prune computations where estimated values are too small. Compared to other papers that use complex hardware for estimation, which while accelerating computation time by 48.12%, increases area by 82.42% compared to direct computation, our method reduces computation time by 29.43% while only increasing area by 12.69%.
To validate the effectiveness of our acceleration methods, we use BERT (Bidirectional Encoder Representations from Transformers), an LLM solely containing the Transformer architecture, to verify accuracy. When comparing our accelerated portions to the original version, using all non-linear acceleration methods on Softmax, GELU, Layer Normalization maintains 99.78% accuracy of the original, while reducing computation time by 58.06%. When applying all linear and non-linear acceleration methods, accuracy is maintained at 99.54% of the original, with a 48.54% reduction in computation time.

所屬典藏

電子研究所
顯示完整詮釋資料 統計資料

引用此條目

Fu, S.-Y. (2025). A High-Speed Hardware-Accelerated Transformer for Efficient Linear and Non-Linear Operations in Large Language Models. https://thesis.lib.nycu.edu.tw/handle/20.500.14371/85122

BibTeX RIS

引用文字依 APA 第 7 版格式自動產生,使用前請再核對。

分享

永久網址:https://thesis.lib.nycu.edu.tw/handle/20.500.14371/85122