Quamba:一种面向选择性状态空间模型的训练后量化方案
Quamba: A Post-Training Quantization Recipe for Selective State Space Models
AI总结:
针对现有量化技术难以适配状态空间模型(SSMs)的问题,提出Quamba静态8比特逐张量量化方案,通过抑制输入激活最大值、Hadamard变换处理输出离群值实现高效量化,在边缘平台上大幅降低延迟且准确率损失极小。
摘要:
状态空间模型(State Space Models, SSMs)已成为大语言模型领域中Transformer的有力替代方案,凭借恒定内存复杂度实现了当前最优的准确率,支持比基于注意力的网络更长的上下文长度。SSMs在长序列建模中表现出的卓越计算效率,使其在诸多场景中优于Transformer。然而,提升SSMs在高请求量云服务场景和资源受限边缘应用中的效率,仍是一项艰巨任务。SSM量化是解决该问题的可行方案,既能让SSMs更适合广泛部署,又能保持其准确率。量化是一种常用的模型压缩技术,可减小模型体积并利用现代计算单元的低位宽加速特性,但现有量化技术难以适配SSMs。最突出的问题是,SSMs的选择性扫描机制(即线性递归)内的特征图对量化高度敏感,且输出激活中存在大量离群值,这是自注意力模块的token混合输出中不存在的特性。为解决这一问题,我们提出了一种静态8比特逐张量SSM量化方法:该方法抑制输入到选择性SSM的激活最大值,以获得更精细的量化精度;同时通过Hadamard变换在无离群值空间中对输出激活进行量化。我们的8比特权重-激活量化Mamba 2.8B SSM可充分利用硬件加速,在Nvidia Orin Nano 8G平台上生成延迟降低1.72倍,而零样本任务的平均准确率仅下降0.9%。实验证明,我们的方法对于在云端和边缘平台部署各种规模的基于SSM的模型,均具备有效性和实际适用性。
英文摘要:
State Space Models (SSMs) have emerged as an appealing alternative to Transformers for large language models, achieving state-of-the-art accuracy with constant memory complexity which allows for holding longer context lengths than attention-based networks. The superior computational efficiency of SSMs in long sequence modeling positions them favorably over Transformers in many scenarios. However, improving the efficiency of SSMs on request-intensive cloud-serving and resource-limited edge applications is still a formidable task. SSM quantization is a possible solution to this problem, making SSMs more suitable for wide deployment, while still maintaining their accuracy. Quantization is a common technique to reduce the model size and to utilize the low bit-width acceleration features on modern computing units, yet existing quantization techniques are poorly suited for SSMs. Most notably, SSMs have highly sensitive feature maps within the selective scan mechanism (i.e., linear recurrence) and massive outliers in the output activations which are not present in the output of token-mixing in the self-attention modules. To address this issue, we propose a static 8-bit per-tensor SSM quantization method which suppresses the maximum values of the input activations to the selective SSM for finer quantization precision and quantizes the output activations in an outlier-free space with Hadamard transform. Our 8-bit weight-activation quantized Mamba 2.8B SSM benefits from hardware acceleration and achieves a 1.72x lower generation latency on an Nvidia Orin Nano 8G, with only a 0.9% drop in average accuracy on zero-shot tasks. The experiments demonstrate the effectiveness and practical applicability of our approach for deploying SSM-based models of all sizes on both cloud and edge platforms.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。