提出BWTA方法,实现高效低比特的Transformer推理。
BWTA: Accurate and Efficient Binarized Transformer by Algorithm-Hardware Co-design
- 通过二值权值与三值激活的量化设计,缓解二值化精度损失。
- 在BERT上仅丢3.5%性能,推理速度提升16至24倍。
- 适合需要低延迟、高效率部署的大模型应用。
超低比特量化能显著提升基于Transformer模型的效率,但精度下降和GPU支持有限制约了其广泛应用。本文分析了二值化中的零点偏差问题,提出二值权值与三值激活(BWTA)量化方案,将微小值映射为零,保持极低比特模型的精度。训练方面,提出平滑多阶段量化,结合逐层退化策略与幅度对齐投影因子,实现稳定快速收敛。推理方面,开发了针对BWTA的CUDA矩阵乘核,支持指令级并行位打包及完整的二/三值矩阵乘实现,适用于线性与注意力模块。实验表明,BWTA在BERT上接近全精度性能,GLUE平均下降3.5%,五个任务降幅低于2%;大语言模型也达到相当困惑度与准确率。在效率上,相比FP16在NVIDIA GPU上获得16至24倍内核级加速,大模型端到端预填充速度提升216至330 tokens/s,内存占用更低。作为软硬件协同设计,BWTA实现了无需牺牲模型质量的低延迟超低比特推理。
原文摘要 · Abstract (English)
Ultra low-bit quantization brings substantial efficiency for Transformer-based models, but the accuracy degradation and limited GPU support hinder its wide usage. In this paper, we analyze zero-point distortion in binarization and propose a Binary Weights & Ternary Activations (BWTA) quantization scheme, which projects tiny values to zero and preserves the accuracy of extremely low-bit models. For training, we propose Smooth Multi-Stage Quantization, combining a Levelwise Degradation Strategy and a Magnitude-Alignment Projection Factor to enable stable and fast convergence. For inference, we develop a BWTA MatMul CUDA kernel with instruction-level parallel bit-packing and comprehensive binary/ternary MatMul implementations for both linear and attention operators, allowing seamless integration across Transformer architectures. Experiments show that BWTA approaches full-precision performance for BERT, with an average 3.5% drop on GLUE and less than 2% drop on five tasks, and achieves comparable perplexity and accuracy for LLMs. In efficiency, it delivers 16 to 24 times kernel-level speedup over FP16 on NVIDIA GPUs, and 216 to 330 tokens/s end-to-end prefill speedup with lower memory footprint on LLMs. As an algorithm-hardware co-design, BWTA demonstrates practical, low-latency ultra-low-bit inference without sacrificing model quality.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。