BinaryViT: Toward Efficient and Accurate Binary Vision Transformers
Vision Transformers (ViTs) have emerged as the new fundamental architecture for most computer vision fields. However, the considerable memory and computation costs also hinder their application on resource-limited devices. Currently, binarization has demonstrated remarkable potential as a model compression technique in traditional Convolutional Neural Networks (CNNs), albeit with some accuracy loss. In this paper, we focus on binarization of ViTs, which is still under-studied and suffering a significant performance drop. We start with constructing a strong baseline of binary ViTs, integrating some of the best practices from binary CNNs, which forms the foundation of our exploration. Subsequently, we identify that the severe performance degradation of the baseline is mainly caused by the weight oscillation around the quantization boundary and the information distortion in the activation of ViTs. To address these challenges, we introduce BinaryViT, a precise full binarization framework tailored for Vision Transformers (ViTs), effectively pushing the binarization of ViTs to its limit. Specifically, we propose a novel gradient regularization scheme (GRS), which mitigates oscillations by fostering a smooth moving of latent weights to be away from the quantization boundary during the training process. Additionally, we have devised an Activation Shift Module (ASM) that dynamically adjusts the activation distribution prior to the sign function, thereby minimizing the information distortion stemming from the significant inter-channel variations. Extensive experiments on ImageNet dataset show that our BinaryViT consistently surpasses the strong baseline by 2.05% and improves the accuracy of fully binarized ViTs to a usable level. Furthermore, our method achieves impressive savings of <inline-formula xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:xlink="http://www.w3.org/1999/xlink"> <tex-math notation="LaTeX">$16.2\times $ </tex-math></inline-formula> and <inline-formula xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:xlink="http://www.w3.org/1999/xlink"> <tex-math notation="LaTeX">$17.7\times $ </tex-math></inline-formula> in model size and OPs compared to the full-precision DeiT-S.
Authors
- Qingyi Gu (ORCID: https://orcid.org/0000-0001-8332-5350)
- Junrui Xiao (ORCID: https://orcid.org/0000-0002-5256-1091)
- Jianquan Li (ORCID: https://orcid.org/0000-0003-1127-2039)
- Zhikai Li (ORCID: https://orcid.org/0000-0002-6483-1597)
- Lianwei Yang (ORCID: https://orcid.org/0000-0003-1180-711X)
Institutions
- Chinese Academy of Sciences (CN)
- Shandong Institute of Automation (CN)
Publication Details
- Journal
- IEEE Transactions on Circuits and Systems for Video Technology
- Published
- 2024-09-10
- DOI
- https://doi.org/10.1109/tcsvt.2024.3457610
- Citations
- 4
- Primary Topic
- Advanced Memory and Neural Computing
- Type
- article
- Field-Weighted Citation Impact
- 0.83
Funders
- National Natural Science Foundation of China