Skip to main navigation Skip to search Skip to main content

EcoFormer: Energy-Saving Attention with Linear Complexity

  • Jing Liu
  • , Felix Pan
  • , Haoyu He
  • , Jianfei Cai
  • , Bohan Zhuang

Research output: Chapter in Book/Report/Conference proceeding › Conference Paper › Research › peer-review

Abstract

Transformer is a transformative framework for deep learning which models sequential data and has achieved remarkable performance on a wide range of tasks, but with high computational and energy cost. To improve its efficiency, a popular choice is to compress the models via binarization which constrains the floating point values into binary ones to save resource consumption owing to cheap bitwise operations significantly. However, existing binarization methods only aim at minimizing the information loss for the input distribution statistically, while ignoring the pairwise similarity modeling at the core of the attention mechanism. To this end, we propose a new binarization paradigm customized to high-dimensional softmax attention via kernelized hashing, called EcoFormer, to map the original queries and keys into low-dimensional binary codes in Hamming space. The kernelized hash functions are learned to match the ground-truth similarity relations extracted from the attention map in a self-supervised way. Based on the equivalence between the inner product of binary codes and the Hamming distance as well as the associative property of matrix multiplication, we can approximate the attention in linear complexity by expressing it as a dot-product of binary codes. Moreover, the compact binary representations of queries and keys in EcoFormer enable us to replace most of the expensive multiply-accumulate operations in attention with simple accumulations to save considerable on-chip energy footprint on edge devices. Extensive experiments on both vision and language tasks show that EcoFormer consistently achieves comparable performance with standard attentions while consuming much fewer resources. For example, based on PVTv2-B0 and ImageNet-1K, EcoFormer achieves a 73% reduction in on-chip energy footprint with only a slight performance drop of 0.33% compared to the standard attention. Code is available at https://github.com/ziplab/EcoFormer.
Original languageEnglish
Title of host publicationAdvances in Neural Information Processing Systems 35 (NeurIPS 2022)
EditorsS. Koyejo, S. Mohamed, A. Agarwal, D. Belgrave, K. Cho, A. Oh
Place of PublicationSan Diego CA USA
PublisherNeural Information Processing Systems (NIPS)
Number of pages14
ISBN (Electronic)9781713871088
Publication statusPublished - 2022
EventAdvances in Neural Information Processing Systems 2022 - New Orleans Convention Center, New Orleans, United States of America
Duration: 28 Nov 2022 → 9 Dec 2022
Conference number: 36th
https://proceedings.neurips.cc/paper_files/paper/2022 (Proceedings)
https://nips.cc/Conferences/2022
https://openreview.net/group?id=NeurIPS.cc/2022/Conference (Peer Reviews)

Conference

ConferenceAdvances in Neural Information Processing Systems 2022
Abbreviated titleNeurIPS 2022
Country/TerritoryUnited States of America
CityNew Orleans
Period28/11/22 → 9/12/22
Internet address

Cite this