[Paper Review] Demystify Mamba in Vision: A Linear Attention Perspective
The paper shows Mamba is closely related to linear attention Transformers and identifies forget gate and block design as key factors for Mamba’s vision performance, then derives MLLA, a Mamba-inspired linear attention model that outperforms vision Mambas on classification and dense prediction tasks.
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.
Motivation & Objective
- Reveal the relationship between Mamba and linear attention Transformer within a unified framework.
- Identify which design choices in Mamba drive its superior performance in vision tasks.
- Demonstrate that core ideas from Mamba can be integrated into linear attention to form a competitive vision model.
- Provide practical guidance on when forget gate is beneficial and how positional encoding can substitute it in vision.
Proposed method
- Reformulate selective state space model (SSM) and linear attention in a unified notation to compare them directly.
- Characterize six distinctions between Mamba and linear attention Transformer: input gate, forget gate, shortcut, no attention normalization, single-head vs multi-head, and modified block design.
- Conduct ablation studies to assess the impact of each distinction on ImageNet-1K, COCO, and ADE20K tasks.
- Propose Mamba-Like Linear Attention (MLLA) by transplanting the two core contributors (forget gate alternatives and block design) into linear attention.
- Evaluate MLLA against various vision Mamba models to show improved performance and speed.
Experimental results
Research questions
- RQ1How does Mamba align with and differ from linear attention Transformer in core computation?
- RQ2Which design components of Mamba are critical to its vision performance, and why?
- RQ3Can the beneficial aspects of Mamba be integrated into linear attention to yield a superior vision model (MLLA)?
- RQ4How do input gate, forget gate, shortcut, normalization, heads, and block design individually affect performance and efficiency in vision benchmarks?
Key findings
- Mamba can be viewed as a variant of linear attention Transformer with six distinctions: input gate, forget gate, shortcut, no normalization, single-head, and modified block design.
- The forget gate and block design are the primary contributors to Mamba’s superior performance in vision tasks.
- Replacing the forget gate with suitable positional encodings (APE, LePE, CPE, RoPE) preserves performance gains while enabling parallelizable computation.
- The proposed MLLA model, which incorporates the two core ideas into linear attention, achieves superior results to various vision Mamba models on ImageNet-1K, COCO, and ADE20K.
- MLLA maintains faster inference relative to recurrent components and demonstrates competitive or superior accuracy across classification and dense prediction benchmarks.
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.