LightMamba: Efficient Mamba Acceleration on FPGA with Quantization and Hardware Co-design
Renjie Wei, Songqiang Xu, Linfeng Zhong, Zebin Yang, Qingyu Guo, Yuan Wang, Runsheng Wang, Meng Li
TL;DR
This work tackles accelerating Mamba on FPGA by co-designing a rotation-assisted post-training quantization and an FPGA accelerator. It introduces a PoT-based, FPGA-friendly quantization for the SSM, enabling low-bit computations, and a three-module accelerator (MMU, SSMU, HTU) with computation reordering and fine-grained tiling/fusion. The approach yields substantial gains, achieving up to 93 tokens/s on Alveo U280 and 7.21 tokens/s on Versal VCK190, with energy efficiency improvements of up to 6.06x over a RTX 2070 GPU baseline and 4.65x over a 4090. These results demonstrate practical, end-to-end FPGA acceleration for Mamba, enabling efficient autoregressive generation with reduced memory and compute costs. The methods are implemented in LightMamba and publicly available at the project repository.
Abstract
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.
