arXivDaily arXiv每日学术速递 周一至周五更新
感恩节,周五至周末无更新,大家顺遂。周一再来吧
arXiv 2603.09582cs.CV
收藏

BinaryAttention: 一比特QK-注意力用于视觉和扩散变换器

BinaryAttention: One-Bit QK-Attention for Vision and Diffusion Transformers

The Hong Kong Polytechnic University(香港理工大学);OPPO Research Institute(OPPO研究院)

Chaodong Xiao, Zhengqiang Zhang, Lei Zhang

AI总结:

BinaryAttention通过1比特QK-注意力实现视觉和扩散变换器的高效加速,有效提升计算效率并保持准确性。

摘要:

变换器在视觉任务中取得了广泛而显著的成功,但其注意力模块的计算复杂性仍然是主要瓶颈。现有方法主要采用8比特或4比特量化来平衡效率和精度。在本文中,我们通过理论论证表明,注意力的二值化能保留本质的相似性关系,并提出BinaryAttention,一种有效的快速且准确的1比特qk-注意力方法。具体而言,在计算注意力时,我们仅保留查询和键的符号,并用位运算替代浮点点积,显著降低了计算成本。我们通过引入可学习的偏置来缓解1比特量化下的固有信息损失,并实现端到端的加速。为了保持注意力的准确性,我们采用量化感知训练和自我蒸馏技术,减少量化误差并确保符号对齐的相似性。BinaryAttention在A100 GPU上比FlashAttention2快超过2倍。在视觉变换器和扩散变换器基准上的广泛实验表明,BinaryAttention与全精度注意力匹配甚至超过了全精度注意力,验证了其有效性。我们的工作提供了一种高效且有效的全精度注意力替代方案,推动了低比特视觉和扩散变换器的前沿。代码和模型可在https://github.com/EdwardChasel/BinaryAttention找到。

英文摘要:

Transformers have achieved widespread and remarkable success, while the computational complexity of their attention modules remains a major bottleneck for vision tasks. Existing methods mainly employ 8-bit or 4-bit quantization to balance efficiency and accuracy. In this paper, with theoretical justification, we indicate that binarization of attention preserves the essential similarity relationships, and propose BinaryAttention, an effective method for fast and accurate 1-bit qk-attention. Specifically, we retain only the sign of queries and keys in computing the attention, and replace the floating dot products with bit-wise operations, significantly reducing the computational cost. We mitigate the inherent information loss under 1-bit quantization by incorporating a learnable bias, and enable end-to-end acceleration. To maintain the accuracy of attention, we adopt quantization-aware training and self-distillation techniques, mitigating quantization errors while ensuring sign-aligned similarity. BinaryAttention is more than 2x faster than FlashAttention2 on A100 GPUs. Extensive experiments on vision transformer and diffusion transformer benchmarks demonstrate that BinaryAttention matches or even exceeds full-precision attention, validating its effectiveness. Our work provides a highly efficient and effective alternative to full-precision attention, pushing the frontier of low-bit vision and diffusion transformers. The codes and models can be found at https://github.com/EdwardChasel/BinaryAttention.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑