As the core building block of vision transformers, attention is a powerful tool to capture long-range dependency. However, such power comes at a cost: it incurs a huge computation burden and heavy memory footprint as pairwise token interaction across all spatial locations is computed. A series of works attempt to alleviate this problem by introducing handcrafted and content-agnostic sparsity into attention, such as restricting the attention operation to be inside local windows, axial stripes, or dilated windows. In contrast to these approaches, we propose a novel dynamic sparse attention via bi-level routing to enable a more flexible allocation of computations with content awareness. Specifically, for a query, irrelevant key-value pairs are first filtered out at a coarse region level, and then fine-grained token-to-token attention is applied in the union of remaining candidate regions (\ie, routed regions). We provide a simple yet effective implementation of the proposed bi-level routing attention, which utilizes the sparsity to save both computation and memory while involving only GPU-friendly dense matrix multiplications. Built with the proposed bi-level routing attention, a new general vision transformer, named BiFormer, is then presented. As BiFormer attends to a small subset of relevant tokens in a \textbf{query adaptive} manner without distraction from other irrelevant ones, it enjoys both good performance and high computational efficiency, especially in dense prediction tasks. Empirical results across several computer vision tasks such as image classification, object detection, and semantic segmentation verify the effectiveness of our design. Code is available at \url{https://github.com/rayleizhu/BiFormer}.
Pubic Symphysis-Fetal Head Segmentation Network Using BiFormer Attention Mechanism and Multipath Dilated Convolution
College of Computer Science and Engineering, Chongqing University of Technology(重庆理工大学计算机科学与工程学院);College of Artificial Intelligence, Chongqing University of Technology(重庆理工大学人工智能学院)
Dual-R-DETR: Resolving Query Competition with Pairwise Routing in Transformer Decoders
University of Pittsburgh(匹兹堡大学);University of California, Irvine(加州大学尔湾分校);Stevens Institute of Technology(史蒂文斯理工学院);Illinois Institute of Technology(伊利诺伊理工学院);New York University(纽约大学)
SAGE: Shape-Adapting Gated Experts for Adaptive Histopathology Image Segmentation
University of Science, VNU-HCM(越南国家大学科学学院);Trivita AI;University of Technology, VNU-HCM(越南国家大学技术学院);Michigan State University, USA(美国密歇根州立大学);The University of Texas at Austin(德克萨斯大学奥斯汀分校)
Routing Matters in MoE: Scaling Diffusion Transformers with Explicit Routing Guidance
Fudan University(复旦大学);Tongyi Lab, Alibaba Group(阿里云实验室,阿里巴巴集团);Zhejiang University(浙江大学);The University of Hong Kong(香港大学);MMLab;Institute of Science and Technology for Brain-inspired Intelligence, MOE Frontiers Center for Brain Science, Key Laboratory of Computational Neuroscience and Brain-Inspired Intelligence, and State Key Laboratory of Brain Function and Disorders, Fudan University(脑启发智能科学技术研究院、MOE前沿脑科学中心、计算神经科学与脑启发智能重点实验室、脑功能与疾病国家重点实验室,复旦大学)
Sparse Mixture-of-Experts Routing in Visual Diffusion Transformers:Diagnosis, Boundary Calibration and Evolutionary Roadmap from Routing Collapse to Selective Deadlock
Semantic Routing: Exploring Multi-Layer LLM Feature Weighting for Diffusion Transformers
Peking University(北京大学);School of Artificial Intelligence, University of Chinese Academy of Sciences(中国科学院大学人工智能学院);Nanjing University(南京大学);Fudan University(复旦大学)
LGEST: Dynamic Spatial-Spectral Expert Routing for Hyperspectral Image Classification
Information Hub, The Hong Kong University of Science and Technology (Guangzhou)(香港科学与技术大学信息中心(广州));Faculty of Geographical Science, Beijing Normal University(北京师范大学地理学部);School of Electronic and Communication Engineering, Guangzhou University(广州大学电子与通信工程学院)
Probing Routing-Conditional Calibration in Attention-Residual Transformers
Adelaide University(阿德莱德大学);Australian Institute for Machine Learning (AIML), Adelaide University(澳大利亚机器学习研究所(AIML),阿德莱德大学);The University of Queensland(昆士兰大学)
Adaptive Routing for Efficient Diffusion Transformer-Based PNI Prediction
Seoul National University(首尔国立大学);Kyung Hee University(庆熙大学);OUTTA;Chung-Ang University(Chung-Ang 大学);Seoul National University School of Medicine(首尔国立大学医学院);Samsung Changwon Hospital(三星昌原医院);Samsung Medical Center(三星医疗中心);NVIDIA AI Technology Center(NVIDIA AI 技术中心)
Attention Is All You Need For Mixture-of-Depths Routing
Bosch Center for Artificial Intelligence(博世人工智能中心);CISPA Helmholtz Center for Information Security(CISPA亥姆霍兹信息安全中心);University of Stuttgart(斯图加特大学);University of Tübingen(蒂宾根大学)
Memory Efficient Matting with Adaptive Token Routing
Institute of Information Science, Beijing Jiaotong University(北京交通大学信息科学研究所);Visual Intelligence + X International Joint Laboratory of the Ministry of Education(教育部视觉智能+X国际联合实验室);Pengcheng Laboratory(鹏城实验室);MT Lab, Meitu Inc.(美图公司MT实验室)
HeadRouter: A Training-free Image Editing Framework for MM-DiTs by Adaptively Routing Attention Heads
Institute of Computing Technology, Chinese Academy of Sciences(中国科学院计算技术研究所);University of Chinese Academy of Sciences(中国科学院大学);Beihang University(北京航空航天大学);National Cheng-Kung University(国立成功大学)