簡易檢索 / 詳目顯示

研究生: 林子傑
Lin, Zi-Jie
論文名稱: 基於MXInt之Vision Transformer非線性函數近似方法於Novella NPU之實現
MXInt-based Approximation of Vision Transformer Nonlinear Functions for Novella NPU
指導教授: 陳中和
Chen, Chung-Ho
學位類別: 碩士
Master
系所名稱: 智慧半導體及永續製造學院 - 晶片設計學位學程
Program on Integrated Circuit Design
論文出版年: 2026
畢業學年度: 114
語文別: 中文
論文頁數: 89
中文關鍵詞: Vision TransformerNPU 架構設計非線性函數區塊浮點數查找表
外文關鍵詞: VisionTransformer, NPU Architecture Design, Nonlinear Function, Block Floating Point, Lookup Table
相關次數: 點閱:8下載:0
分享至:
查詢本校圖書館目錄 查詢臺灣博碩士論文知識加值系統 勘誤回報
  • 針對 Vision Transformer(ViT)高參數量與運算複雜度,設計專用神經網路處理器(Neural Processing Unit, NPU)為提升推論效率之重要方向。本實驗室開發之 Novella Brown NPU 已於核心運算單元導入微縮放整數格式(Microscaling Integer, MXInt),以提升線性運算效率。然而,現有架構在處理 LayerNorm、Softmax 與 GeLU 等 ViT 主要非線性函數時,後處理單元(PPU)仍依賴 BFloat16 浮點資料路徑,需配置成本較高的浮點運算單元,增加硬體面積負擔。此外,MXInt 及其他共享指數格式多應用於矩陣乘法與卷積等線性算子,對 LayerNorm、Softmax 與 GeLU 等 ViT 主要非線性函數的系統化支援仍相對有限。
    本論文提出一套基於 MXInt 格式之全整數非線性函數近似架構,並實現於 Novella NPU 之硬體設計中。本研究針對 LayerNorm、Softmax 與 GeLU 設計 MXInt 近似演算法,將原先依賴浮點資料路徑的非線性計算轉換為純尾數域之整數運算,使所提出之非線性運算路徑可由整數運算單元支援。針對反平方根、倒數、指數函數與 GeLU 等特殊函數,本研究設計 MXInt-ISQRT、MXInt-RECIP、MXInt-EXP 與 MXInt-GeLU 等可重用運算子,並以整數資料路徑與小容量查找表(Look-Up Table, LUT)共同支援。透過演算法與硬體共同設計,本架構以整數運算單元與小容量 LUT 取代原有浮點運算單元,降低 PPU 支援 ViT 非線性函數所需的硬體成本。
    本研究透過 AlgoSim 模擬 DeiT-Tiny 於 ImageNet-1K 進行模型層級驗證,且未重新訓練或微調模型。實驗結果顯示,所提出之 MXInt 非線性函數近似演算法相較於 FP32 baseline 僅造成 0.13% Top-1 準確度損失與 0.06% Top-5 準確度損失,顯示本方法在模型層級具有可行性。硬體層級方面,相較於 BFloat16 設計,單一 MXInt kernel 面積下降 24.91%,並使整體 PPU 面積由 173,181.74 μm² 降至 156,163.5441 μm²,下降 9.83%。實驗結果顯示,MXInt 資料格式可有效延伸至 ViT 主要非線性函數,在維持模型準確度的同時,降低 Novella NPU 中 PPU 支援非線性函數所需之硬體面積成本。

    Vision Transformers (ViTs) have high parameter counts and computational complexity, motivating dedicated neural processing units (NPUs) for efficient inference. The Novella Brown NPU developed by our laboratory already uses the Microscaling Integer (MXInt) format in its core compute unit to improve the efficiency of linear operators. However, its Post-Processing Unit (PPU) still relies on a BFloat16 (BF16) datapath for major ViT nonlinear functions, including LayerNorm, Softmax, and GeLU. The required floating-point arithmetic units increase the PPU area. Moreover, MXInt and other shared-exponent formats have mainly been applied to linear operators, while systematic support for these nonlinear functions remains limited.
    This thesis proposes an all-integer MXInt nonlinear function approximation architecture and implements it in the Novella NPU. The proposed LayerNorm, Softmax, and GeLU algorithms convert calculations that originally depend on a floating-point datapath into integer operations in the mantissa domain. MXInt-ISQRT, MXInt-RECIP, MXInt-EXP, and MXInt-GeLU are designed as reusable operators supported by integer arithmetic and small look-up tables (LUTs). Through algorithm-hardware co-design, the proposed architecture replaces the original floating-point arithmetic units with integer arithmetic units and small LUTs.
    DeiT-Tiny inference on ImageNet-1K is evaluated in AlgoSim without retraining or fine-tuning. Relative to the FP32 baseline, the proposed MXInt nonlinear approximation causes only 0.13% Top-1 accuracy drop and 0.06% Top-5 accuracy loss. Compared with the BF16 design, the area of a single nonlinear kernel is reduced by 24.91%, resulting in a 9.83% reduction in the overall PPU wrapper area. These results show that MXInt can be extended to the major ViT nonlinear functions while maintaining model accuracy and reducing the PPU hardware area.

    摘要 i 英文延伸摘要 ii 誌謝 xi 目錄 xii 表目錄 xiv 圖目錄 xv Chapter 1. 緒論 (Introduction) 1 1.1. 研究背景與動機 1 1.2. 論文貢獻 2 1.3. 論文架構 3 Chapter 2. 背景知識與相關研究(Background & Related Work) 4 2.1. Transformer 模型 4 2.2. ViT 模型 5 2.2.1. Preprocess 5 2.2.2. Encoder 5 2.2.3. 非線性函數 7 2.3. NPU 之數值格式與非線性函數支援 9 2.3.1. NPU 之數值格式 9 2.3.2. NPU 對非線性函數與 MXInt 格式的支援方式 12 2.4. Novella Brown NPU Micro Architecture 14 2.5. Novella NPU 跨層級驗證平台 15 2.5.1. 演算法模擬器(Algorithm Simulator, AlgoSim) 15 2.5.2. 指令集模擬器(Instruction Set Simulator, ISS) 16 2.5.3. 電子系統層級(Electronic System Level, ESL) 16 2.5.4. 暫存器傳輸層級(Register Transfer Level, RTL) 16 Chapter 3. 基於 MXInt 之非線性函數近似演算法(Proposed Algorithms) 18 3.1. MXInt LayerNorm 近似演算法 18 3.1.1. 消除 LayerNorm 中的除法運算 19 3.1.2. Global Alignment 與共享指數消去 20 3.1.3. MXInt-ISQRT 查表設計 21 3.1.4. MXInt LayerNorm 演算法 23 3.2. MXInt Softmax 近似演算法 26 3.2.1. MXInt-EXP 查表設計 26 3.2.2. MXInt-RECIP 設計 28 3.2.3. MXInt Softmax 演算法 29 3.3. MXInt GeLU 近似演算法 31 3.3.1. GeLU 函數特性與查表設計動機 31 3.3.2. MXInt GeLU 查表設計 32 3.3.3. MXInt GeLU 演算法 34 Chapter 4. 硬體架構設計與實作(Hardware Implementation) 36 4.1. MXInt 非線性運算所需運算子類型 36 4.2. MXInt PPU 整體架構 38 4.3. Micro-op 執行契約與 Unified Buffer 資料格式 39 4.3.1. Micro-op 執行契約 39 4.3.2. Unified Buffer 資料格式與讀寫 41 4.4. Micro-op 控制流程與資料遍歷 43 4.4.1. Micro-op 執行流程 43 4.4.2. 運算子分類與控制 43 4.4.3. Element-wise 資料遍歷方式 44 4.4.4. Reduction 資料遍歷方式 45 4.4.5. 控制訊號與資料管線對齊 45 4.5. MXInt kernel 與運算子實作 46 4.5.1. 共享硬體單元 47 4.5.2. 運算子之硬體實作 48 Chapter 5. 實驗結果與分析(Experimental Results) 52 5.1. 實驗設計 52 5.1.1. 軟硬體驗證流程 52 5.1.2. 近似演算法實驗層級與評估目標 53 5.1.3. 實驗資料來源 54 5.2. 演算法近似準確度分析 54 5.2.1. LUT 設定選擇與設計取捨 54 5.2.2. MXInt 近似函數準確度分析 59 5.2.3. 模型層級準確度分析 62 5.3. 硬體成本分析 63 Chapter 6. 結論(Conclusion) 68 6.1. 結論 68 6.2. 未來工作 69 References 70

    [1] Bita Darvish Rouhani, Daniel Lo, Ritchie Zhao, Ming Liu, Jeremy Fowers, Kalin Ovtcharov, Anna Vinogradsky, Sarah Massengill, Lita Yang, Ray Bittner, Alessandro Forin, Haishan Zhu, Taesik Na, Prerak Patel, Shuai Che, Lok Chand Koppaka, Xia Song, Subhojit Som, Kaustav Das, Saurabh Tiwary, Steve Reinhardt, Sitaram Lanka, Eric Chung, and Doug Burger. Pushing the limits of narrow precision inferencing at cloud scale with microsoft floating point. In Advances in Neural Information Processing Systems, volume 33, pages 10271–10281, 2020.
    [2] Bita Darvish Rouhani, Ritchie Zhao, Ankit More, Mathew Hall, Alireza Khodamoradi, Summer Deng, Dhruv Choudhary, Marius Cornea, Eric Dellinger, Kristof Denolf, Stosic Dusan, Venmugil Elango, Maximilian Golub, Alexander Heinecke, Phil James-Roxby, Dharmesh Jani, Gaurav Kolhe, Martin Langhammer, Ada Li, Levi Melnick, Maral Mesmakhosroshahi, Andres Rodriguez, Michael Schulte, Rasoul Shafipour, Lei Shao, Michael Siu, Pradeep Dubey, Paulius Micikevicius, Maxim Naumov, Colin Verrilli, Ralph Wittig, Doug Burger, and Eric Chung. Microscaling data formats for deep learning. arXiv preprint arXiv:2310.10537, 2023.
    [3] Peiyan Dong, Jinming Zhuang, Zhuoping Yang, Shixin Ji, Yanyu Li, Dongkuan Xu, Heng Huang, Jingtong Hu, Alex K. Jones, Yiyu Shi, Yanzhi Wang, and Peipei Zhou. Eq-vit: Algorithm-hardware co-design for end-to-end acceleration of real-time vision transformer inference on versal acap architecture. IEEE Transactions on Computer-Aided Design of Integrated Circuits and Systems, 43(11):3949–3960, 2024.
    [4] Alexey Dosovitskiy, Lucas Beyer, Alexander Kolesnikov, Dirk Weissenborn, Xiaohua Zhai, Thomas Unterthiner, Mostafa Dehghani, Matthias Minderer, Georg Heigold, Sylvain Gelly, Jakob Uszkoreit, and Neil Houlsby. An image is worth 16x16 words: Transformers for image recognition at scale. In International Conference on Learning Representations, 2021.
    [5] Dan Hendrycks and Kevin Gimpel. Gaussian error linear units (gelus). arXiv preprint arXiv:1606.08415, 2016.
    [6] Erik Hertz, Niclas Thuning, Leo Bärring, Bertil Svensson, and Peter Nilsson. Algorithms for implementing roots, inverse and inverse roots in hardware. Unpublished manuscript in dissertation, 2016.
    [7] Benoit Jacob, Skirmantas Kligys, Bo Chen, Menglong Zhu, Matthew Tang, Andrew Howard, Hartwig Adam, and Dmitry Kalenichenko. Quantization and training of neural networks for efficient integer-arithmetic-only inference. In 2018 IEEE/CVF Conference on Computer Vision and Pattern Recognition, pages 2704–2713, 2018.
    [8] Dhiraj Kalamkar, Dheevatsa Mudigere, Naveen Mellempudi, Dipankar Das, Kunal Banerjee, Sasikanth Avancha, Dharma Teja Vooturi, Nataraj Jammalamadaka, Jianyu Huang, Hector Yuen, Jiyan Yang, Jongsoo Park, Alexander Heinecke, Evangelos Georganas, Sudarshan Srinivasan, Abhisek Kundu, Misha Smelyanskiy, Bharat Kaul, and Pradeep Dubey. A study of bfloat16 for deep learning training. arXiv preprint arXiv:1905.12322, 2019.
    [9] Piotr Kluska, Adrián Castelló, Florian Scheidegger, A. Cristiano I. Malossi, and Enrique S. Quintana-Ortí. QAttn: Efficient gpu kernels for mixed-precision vision transformers. In 2024 IEEE/CVF Conference on Computer Vision and Pattern Recognition Workshops (CVPRW), pages 3648–3657, 2024.
    [10] Zhengang Li, Mengshu Sun, Alec Lu, Haoyu Ma, Geng Yuan, Yanyue Xie, Hao Tang, Yanyu Li, Miriam Leeser, Zhangyang Wang, Xue Lin, and Zhenman Fang. Auto-vit-acc: An fpga-aware automatic acceleration framework for vision transformer with mixed-scheme quantization. In 2022 32nd International Conference on Field-Programmable Logic and Applications (FPL), pages 109–116, 2022.
    [11] Zhikai Li and Qingyi Gu. I-ViT: Integer-only quantization for efficient vision transformer inference. In Proceedings of the IEEE/CVF International Conference on Computer Vision, 2023. arXiv:2207.01405.
    [12] Yang Lin, Tianyu Zhang, Peiqin Sun, Zheng Li, and Shuchang Zhou. FQ-ViT: Post-training quantization for fully quantized vision transformer. In Proceedings of the Thirty-First International Joint Conference on Artificial Intelligence, pages 1173–1179, 2022.
    [13] Siyuan Lu, Meiqi Wang, Shuang Liang, Jun Lin, and Zhongfeng Wang. Hardware accelerator for Multi-Head Attention and Position-Wise Feed-Forward in the transformer. In 2020 IEEE 33rd International System-on-Chip Conference (SOCC), pages 84–89, 2020.
    [14] Jacob R. Stevens, Rangharajan Venkatesan, Steve Dai, Brucek Khailany, and Anand Raghunathan. Softermax: Hardware/software co-design of an efficient softmax for transformers. In 2021 58th ACM/IEEE Design Automation Conference (DAC), pages 469–474, 2021.
    [15] Hugo Touvron, Matthieu Cord, Matthijs Douze, Francisco Massa, Alexandre Sablayrolles, and Herve Jegou. Training data-efficient image transformers & distillation through attention. In Proceedings of the 38th International Conference on Machine Learning, volume 139 of Proceedings of Machine Learning Research, pages 10347–10357. PMLR, 2021.
    [16] Ashish Vaswani, Noam Shazeer, Niki Parmar, Jakob Uszkoreit, Llion Jones, Aidan N. Gomez, Lukasz Kaiser, and Illia Polosukhin. Attention is all you need. In Advances in Neural Information Processing Systems, volume 30, 2017.
    [17] Chin-Cheng Wei, Chun-Han Wang, En-Yu Pong, and Chung-Ho Chen. Low-cost non-linear function approximation for transformer deployment on edge NPU. In 2025 1st International Conference on Consumer Technology (ICCT-Pacific), pages 1–4, 2025.
    [18] Can Xiao, Jianyi Cheng, and Yiren Zhao. Refining datapath for microscaling ViTs. In 2025 35th International Conference on Field-Programmable Logic and Applications (FPL), pages 263–272, 2025.
    [19] 彭恩宇. 非線性函數近似及其於TVM編譯器的NPU運算子合法化. Master's thesis, 國立成功大學電機工程學系, 2025.

    QR CODE