一句话:系统评估 FP8 与 Posit8 在 Transformer 全操作推理和 LoRA 微调中的量化效果,并设计高效 posit softmax 加速器。
Transformer 在边缘端推理与微调受限于计算和内存。现有 int8 仅适合推理,FP8 训练又只量化矩阵乘法输入;本文则对前向和反向传播的所有运算进行 8 位量化,研究 FP8 与 Posit8 两种格式,并将 LoRA 适配到二者以支持 8 位 GEMM 微调。作者通过算子融合,在无需缩放因子下使推理精度损失低于 1%;还设计用位运算近似指数和倒数的 posit softmax。结果表明,Posit8/FP8 的推理与微调精度可与 BFloat16 相当,加速器面积分别减少 30% 和 34%,功耗降低 26% 和 32%;Posit8 向量单元比 FP8 平均小 33%、功耗低 35%。
Transformer models achieve state-of-the-art accuracy on natural language processing (NLP) and vision tasks, but demand significant computation and memory resources, which makes it difficult to perform inference and training (fine-tuning) on edge accelerators. Quantization to lower precision data types is a promising way to reduce computation and memory resources. Prior work has employed 8-bit integer (int8) quantization for Transformer inference, but int8 lacks the precision and range required for training. 8-bit floating-point (FP8) quantization has been used for Transformer training, but prior work only quantizes the inputs to matrix multiplications and leaves the rest of the operations in high precision. This work conducts an in-depth analysis of Transformer inference and fine-tuning at the edge using two 8-bit floating-point data types: FP8 and 8-bit posit (Posit8). Unlike FP8, posit has variable length exponent and fraction fields, leading to higher precision for values around 1, making it well suited for storing Transformer weights and activations. As opposed to prior work, we evaluate the impact of quantizing all operations in both the forward and backward passes, going beyond just matrix multiplications. Specifically, our work makes the following contributions: (1) We perform Transformer inference in FP8 and Posit8, achieving less than 1% accuracy loss compared to BFloat16 through operation fusion, without the need for scaling factors. (2) We perform Transformer fine-tuning in 8 bits by adapting low-rank adaptation (LoRA) to Posit8 and FP8, enabling 8-bit GEMM operations with increased multiply-accumulate efficiency and reduced memory accesses. (3) We design an area- and power-efficient posit softmax, which employs bitwise operations to approximate the exponential and reciprocal functions. The resulting vector unit in the Posit8 accelerator, that performs both softmax computation and other element-wise operations in Transformers, is on average 33% smaller and consumes 35% less power than the vector unit in the FP8 accelerator, while maintaining the same level of accuracy. Our work demonstrates that both Posit8 and FP8 can achieve inference and fine-tuning accuracy comparable to BFloat16, while reducing accelerator's area by 30% and 34%, and power consumption by 26% and 32%, respectively.
@inproceedings{YuPURHR24,
title = {8-bit Transformer Inference and Fine-tuning for Edge Accelerators},
author = {Jeffrey Yu and Kartik Prabhu and Yonatan Urman and Robert M. Radway and Eric Han and Priyanka Raina},
booktitle = {ASPLOS},
year = {2024},
doi = {10.1145/3620666.3651368}
}