LightMamba:基于量化和硬件协同设计的高效FPGA Mamba加速
LightMamba: Efficient Mamba Acceleration on FPGA with Quantization and Hardware Co-design
AI总结:
针对Mamba模型因激活异常值和计算依赖难以加速的问题,提出LightMamba,通过协同设计旋转辅助量化算法与部分展开的FPGA加速器架构,大幅提升硬件与内存效率,实现显著优于GPU基线的能效与吞吐量。
摘要:
像Mamba这样的状态空间模型(SSMs)最近引起了广泛关注。与基于Transformer的大语言模型(LLMs)相比,Mamba实现了与序列长度呈线性的计算复杂度,并展现出更优的性能。然而,由于分散的激活异常值和复杂的计算依赖性,Mamba难以加速,导致现有的LLM加速器效率低下。在本文中,我们提出了LightMamba,它通过协同设计量化算法和FPGA加速器架构来实现高效的Mamba推理。我们首先提出了一种FPGA友好的训练后量化算法,该算法具有旋转辅助量化和二的幂次SSM量化特性,将大部分计算减少到4位。我们进一步设计了一个FPGA加速器,部分展开Mamba计算以平衡效率和硬件成本。通过计算重排以及细粒度的分块和融合,加速器的硬件利用率和内存效率得到了大幅提升。我们在Xilinx Versal VCK190 FPGA上实现了LightMamba,其能效比GPU基线高出4.65倍至6.06倍。在Alveo U280 FPGA上进行评估时,LightMamba达到93 tokens/s,是GPU基线的1.43倍。我们的代码可在https://github.com/PKU-SEC-Lab/LightMamba获取。
英文摘要:
State space models (SSMs) like Mamba have recently attracted much attention. Compared to Transformer-based large language models (LLMs), Mamba achieves linear computation complexity with the sequence length and demonstrates superior performance. However, Mamba is hard to accelerate due to the scattered activation outliers and the complex computation dependency, rendering existing LLM accelerators inefficient. In this paper, we propose LightMamba that co-designs the quantization algorithm and FPGA accelerator architecture for efficient Mamba inference. We first propose an FPGA-friendly post-training quantization algorithm that features rotation-assisted quantization and power-of-two SSM quantization to reduce the majority of computation to 4-bit. We further design an FPGA accelerator that partially unrolls the Mamba computation to balance the efficiency and hardware costs. Through computation reordering as well as fine-grained tiling and fusion, the hardware utilization and memory efficiency of the accelerator get drastically improved. We implement LightMamba on Xilinx Versal VCK190 FPGA and achieve 4.65x to 6.06x higher energy efficiency over the GPU baseline. When evaluated on Alveo U280 FPGA, LightMamba reaches 93 tokens/s, which is 1.43x that of the GPU baseline. Our code is available at https://github.com/PKU-SEC-Lab/LightMamba.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。