Share your thoughts, 1 month free Claude Pro on usSee more
WorkDL logo mark

Demystify Mamba in Vision: A Linear Attention Perspective

About

Mamba is an effective state space model with linear computation complexity. It has recently shown impressive efficiency in dealing with high-resolution inputs across various vision tasks. In this paper, we reveal that the powerful Mamba model shares surprising similarities with linear attention Transformer, which typically underperform conventional Transformer in practice. By exploring the similarities and disparities between the effective Mamba and subpar linear attention Transformer, we provide comprehensive analyses to demystify the key factors behind Mamba's success. Specifically, we reformulate the selective state space model and linear attention within a unified formulation, rephrasing Mamba as a variant of linear attention Transformer with six major distinctions: input gate, forget gate, shortcut, no attention normalization, single-head, and modified block design. For each design, we meticulously analyze its pros and cons, and empirically evaluate its impact on model performance in vision tasks. Interestingly, the results highlight the forget gate and block design as the core contributors to Mamba's success, while the other four designs are less crucial. Based on these findings, we propose a Mamba-Inspired Linear Attention (MILA) model by incorporating the merits of these two key designs into linear attention. The resulting model outperforms various vision Mamba models in both image classification and high-resolution dense prediction tasks, while enjoying parallelizable computation and fast inference speed. Code is available at https://github.com/LeapLabTHU/MLLA.

Dongchen Han, Ziyi Wang, Zhuofan Xia, Yizeng Han, Yifan Pu, Chunjiang Ge, Jun Song, Shiji Song, Bo Zheng, Gao Huang• 2024

Related benchmarks

TaskDatasetResultRank
Object DetectionCOCO 2017 (val)--
2643
Image ClassificationImageNet-1K 1.0 (val)
Top-1 Accuracy85.3
1952
Image ClassificationImageNet-1K
Top-1 Acc83.5
1239
Instance SegmentationCOCO 2017 (val)
APm0.45
1201
Semantic segmentationADE20K--
1024
Image ClassificationImageNet 1k (test)
Top-1 Accuracy85.3
450
Object DetectionCOCO
AP50 (Box)71
237
Image ClassificationImageNet V2 (test)
Top-1 Accuracy76.7
216
Object DetectionPCB surface-defect dataset
mAP@0.593.19
22
Object Detectionaluminum-defect
mAP@0.597.36
22
Showing 10 of 11 rows

Other info

Code

Follow for update