Title: Demystify Mamba in Vision: A Linear Attention Perspective
Venue: NeurIPS 2024
Accepted: yes
Keywords: Mamba

Linear Attention Transformer
Abstract: 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.

Demystify Mamba in Vision: A Linear Attention Perspective

Abstract

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 MambaInspired 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.

1 Introduction

Recently, state space models, exemplified by Mamba, have rapidly gained wide research interest. In contrast to the quadratic complexity of prevailing Transformer models, the state-space-based Mamba offers effective sequence modeling with linear complexity. This crucial property allows Mamba to handle extremely long sequences with manageable computational costs, making it a promising architecture for both natural language processing [14, 29] and visual recognition [57, 31].

However, Mamba is not the first model to achieve global modeling with linear complexity. Linear attention [26], an early work, was proposed as an computationally efficient alternative to the widely adopted Softmax attention [42], namely dot-product attention. Specifically, linear attention replaces the non-linear Softmax function in attention operation with linear normalization. This enables a change in computation order from ( QK ⊤ ) V to Q ( K ⊤ V ) , thus reducing computation complexity from O ( N 2 ) to O ( N ) . Despite its efficiency, previous works [4, 39, 15, 16] proved that linear attention suffers from insufficient expressive power, making it impractical for real applications. Surprisingly, we find a very close relationship between the formulas of high-performance Mamba

ൌ

𝒉௜

𝑨 ෩

௜

𝒉௜ିଵ

𝑩௜

∆௜

𝒙௜

ൌ

൅

𝑪௜

𝒉௜

ൌ

൅

𝑫

𝒙௜

𝒁௜ିଵ

𝑲௜

ୃ

𝑺௜

𝑺௜ିଵ

𝑽௜

ൌ

𝑲௜

ୃ

൅

;

𝑺௜

ൌ

൅

𝑸௜

𝑸௜

𝒁௜

(a) SSM in Mamba

(b) Single Head Linear Attention

𝒚௜

𝒚௜

𝒁௜

൅

and subpar linear attention Transformer. Therefore, a compelling research question emerges: What factors contribute to Mamba's success and its significant superiority to linear attention Transformer?

In this paper, we offer both theoretical and empirical analyses to unveil Mamba through the lens of linear attention Transformer. Specifically, we rewrite the formulas of selective state space model and linear attention within a unified formulation, depicting Mamba as a variation of linear attention Transformer with six distinctions: input gate, forget gate, shortcut, no attention normalization, single-head, and modified block design. To demystify what factors lead to Mamba's effectiveness, empirical studies on vision tasks are conducted to assess the impact of each special design. The results demonstrate that the forget gate and block design tend to be the two core contributors to Mamba's superiority. While the block design can be easily adopted, the forget gate necessitates recurrent computation, which may not be well-suited for non-auto-regressive vision models. Therefore, we delve into the essence of the forget gate and verify that it can be replaced by suitable positional encoding in vision tasks. Based on our findings, we introduce the two core contributors or their alternatives to linear attention Transformer, presenting our Mamba-Inspired Linear Attention (MILA) model. Experimental results demonstrate that MILA achieves superior results to various vision Mamba models in both image classification and high-resolution dense prediction tasks, validating that linear attention can surpass Mamba with the merits of two core designs.

Our main contributions and takeaways are as follows:

We reveal Mamba's close relationship to linear attention Transformer: Mamba and linear attention Transformer can be formulated within a unified framework, with Mamba exhibiting six distinct designs compared to the conventional linear attention paradigm: input gate, forget gate, shortcut, no attention normalization, single-head and modified block design.

We provide detailed analyses of each special design and empirically validate that the forget gate and block design largely lead to Mamba's superiority. Additionally, we demonstrate that the recurrent calculation of the forget gate might not be ideal for vision models. Instead, proper positional encoding can function as the forget gate in vision tasks, while preserving parallelizable computation and fast inference speed.

We develop a series of linear attention vision Transformer models named MILA, which inherit the core merits of Mamba and tend to be more suitable for vision tasks than the original Mamba model.

2 Related Works

Vision Transformer and attention. Originating from natural language processing, Transformer and attention have been highly successful in vision tasks [32, 3, 36, 37], demonstrating superiority to the conventional CNN models[18, 7, 12]. However, the quadratic complexity of widely adopted Softmax attention [42] poses challenges in handling high-resolution images. Numerous works have attempted to reduce the computational cost by introducing local attention windows [32, 9, 20] or sparsity [43, 45, 56]. Linear attention [26], another approach, inherently offers linear complexity O ( N ) and is

capable of modeling long sequences. Despite its efficiency, previous works [4, 39, 47, 17] have shown that linear attention always fails to deliver satisfactory results, limiting its applicability.

Mamba [14] is a recently proposed state space model that achieves effective sequence modeling with linear complexity. Motivated by its potential for modeling high-resolution images, many researchers try to apply Mamba to vision tasks [14, 31, 27, 25, 38, 49, 48, 23]. For instance, VMamba [31] introduces a cross-scan module to enable 1D selective scanning in 2D image space. LocalMamba [25] utilizes local windows to enhance local modeling capability. EfficientVMamba [38] designs an atrous-based selective scan approach to enhance efficiency. In addition, MambaOut [51] analyzes whether Mamba is needed for vision, and explainability methods [1] have also been proposed.

In contrast to incorporating Mamba into vision, this paper reveals the surprising similarities between the formulas of inferior linear attention Transformer and powerful Mamba model. This interesting finding gives us the opportunity to demystify the key factors behind Mamba's success.

3 Preliminaries

This section revisits the formulations of attention and selective state space model. To facilitate comparison in Sec. 4, we employ identical notations for the dimensions of certain variables in both linear attention and selective state space model, and make some modifications to the formula formats.

3.1 Attention Mechanism

Let x ∈ R N × C denote a sequence of N features with dimension C . Single head Softmax attention [42], also known as dot-product attention, can be written as:

where W Q , W K ∈ R C × d , W V ∈ R C × C denote projection matrices, Q , K ∈ R N × d , V ∈ R N × C represent query/key/value matrices, and Q i , K i ∈ R 1 × d , V i ∈ R 1 × C are individual query/key/value tokens. Softmax attention computes the similarities between each query-key pair, leading to O ( N 2 ) complexity. Therefore, it incurs unbearable computational cost in long-sequence modeling scenarios.

Linear attention [26], another attention paradigm, is proposed to effectively address this problem by reducing the computation complexity to O ( N ) . Specifically, linear attention replaces the non-linear Softmax function with linear normalization, and adopts an additional kernel function ϕ in Q and K :

This enables the rearrangement of the computation order from ( QK ⊤ ) V to Q ( K ⊤ V ) based on the associative property of matrix multiplication, thus reducing computation complexity to O ( N ) .

Equation (2) defines linear attention with a global receptive field, where each query aggregates information from all keys and values. In practice, linear attention can also be implemented in autoregressive models, restricting the receptive field of the i -th token to proceeding tokens, i.e., token j, j ≤ i . This causal linear attention is formulated as follows:

This results in a recurrent linear attention form:

3.2 Selective State Space Model

State space model (SSM). The classical state space model is a continuous system that maps the input x ( t ) ∈ R to output y ( t ) ∈ R through a hidden state h ( t ) ∈ R d × 1 , which can be written as follows:

Discrete SSM. To be applied to deep neural networks, SSM is first transformed into its discrete version through zero-order hold discretization. Specifically, the continuous parameters A , B are transformed into their discretized counterparts A , B using a timescale parameter ∆ ∈ R :

Therefore, discrete SSM rewrite eq. (5) as:

Selective State Space Model. Mamba [14] improves SSM with selection, presenting the selective state space model. The parameters B , C , ∆ is set as the function of x i , thus becoming input-dependent parameters B i , C i , ∆ i . As a result, the discretized parameters A i = exp(∆ i A ) , B i = ∆ i B i are also input-dependent. The selective state space model can be written as:

(a) Selective SSM Model

·

൅

·

ൌ

𝑨 ഥ

௜

𝑩 ഥ

௜

𝒉௜ିଵ

ൌ

൅ 𝑩௜

∆௜

𝑦௜

𝑪௜

𝒉௜

𝐷

ൌ

·

൅

⋅

𝑥௜

(b) Equivalent Form

𝑨 ෩

௜

𝑥௜

𝒉௜ିଵ

𝒉௜

𝒉௜

𝑥௜

𝑦௜

𝑪௜

𝒉௜

𝐷

ൌ

൅

⋅

𝑥௜

For the convenience of subsequent derivation, we make three modifications to eq. (8):

Mamba practically sets A , A i as diagonal matrices. Therefore, A i h i -1 = ˜ A i ⊙ h i -1 , where ˜ A i = diag( A i ) ∈ R d × 1 denotes the matrix composed of diagonal elements of A i .

Given B i = ∆ i B i and ∆ i ∈ R , we have B i x i = ∆ i B i x i = B i (∆ i x i ) = B i (∆ i ⊙ x i ) .

Dx i = D ⊙ x i , where ⊙ denotes the Hadamard product, i.e., element-wise multiplication.

Consequently, we rewrite eq. (8) as:

The selective state space model formulated in eq. (9) can only deal with scalar input x i ∈ R . To operate over an input sequence x ∈ R N × C , x i ∈ R 1 × C , Mamba applies eq. (9) independently to each channel, leading to the following formulations:

where B i , C i , ∆ i are derived from the input. Specifically, Mamba employs B =( x W B ) ⊤ , C = x W C , ∆ =Softplus( x W 1 W 2 ) to produce the parameters B ∈ R d × N , C ∈ R N × d , ∆ ∈ R N × C , where W B , W C ∈ R C × d , W 1 ∈ R C × C 0 , W 2 ∈ R C 0 × C are projection matrices. Notably, eq. (10) is exactly the selective SSM employed in Mamba, we only make modifications to formula formats.

4 Connecting Mamba and Linear Attention Transformer

In this section, we reveal the similarities and disparities between Mamba and linear attention Transformer from two perspectives: core operation and macro architecture.

4.1 Interpreting Selective State Space Model as Linear Attention

As detailed in Sec. 3, for an input sequence of N tokens x ∈ R N × C , the formulations of selective state space model and linear attention are provided by eq. (10) and eq. (4), respectively. Many underlying similarities exist between the formulas of these two operations. To facilitate comprehension, we rewrite eq. (10) and eq. (4) with a unified formulation as follows:

As illustrated in Fig. 1, a close relationship between eq. (11) and eq. (12) is evident. Specifically, h i ∼ S i ∈ R d × C , B i ∼ K ⊤ i ∈ R d × 1 , x i ∼ V i ∈ R 1 × C , and C i ∼ Q i ∈ R 1 × d . Therefore, selective SSM can be viewed as a special variation of linear attention, indicating a very close connection between these two mechanisms. Furthermore, four major differences can be observed:

In eq. (11), the input x i is augmented by Hadamard product with ∆ i . Since ∆ = Softplus( x W 1 W 2 ) , all elements of ∆ i are positive. Therefore, we view ∆ i as an input gate , controlling whether to let the input x i into the hidden state.

There is an additional ˜ A i in eq. (11). Mamba sets A as a diagonal matrix with negative diagonal elements, thus ensuring all elements of ˜ A i = diag( A i ) = exp(diag( A ) ∆ i ) to fall between 0 and 1. Hence, we interpret ˜ A i as a forget gate , which decides the degree of attenuation for the previous hidden state h i -1 .

A learnable shortcut from the input x i to the output y i is employed in eq. (11), i.e. D ⊙ x i .

As depicted in eq. (12), linear attention divides the output by Q i Z i to maintain that the attention weights sum up to 1, while eq. (11) does not have such normalization .

In addition to these four differences, it is also important to note that eq. (12) represents single-head linear attention as there is only one group of Q,K . This indicates that the selective state space model is akin to single-head linear attention and does not incorporate a multi-head design.

In a word, the similarities and disparities between selective SSM and linear attention can be summarized as: selective state space model resembles linear attention with additional input gate, forget gate and shortcut, while omitting normalization and multi-head design.

4.2 Analysis of Differences in Core Operations

Input gate. As discussed before, ∆ i actually functions as an input gate for x i , determining its access to the hidden state. The values of this input gate are predicted from the current input x i as ∆ i = Softplus( x i W 1 W 2 ) . Therefore, by learning the weight of W 1 , W 2 , the model can discern the 'utility' of x i , generating large ∆ i values for 'useful' x i and small ones for 'less useful' x i . For example, in vision tasks, tokens representing foreground objects may yield larger input gate values, while background tokens may yield smaller ones.

Forget gate. ˜ A i acts as a forget gate in selective state space model, offering two essential properties: local bias and positional information. Firstly, all elements of ˜ A i strictly range from 0 to 1, indicating that the model consistently decays the previous hidden state h i -1 upon the arrival of the current token x i . This results in a strong local bias. Secondly, ˜ A i provides positional information for the model. It ensures that the model is sensitive to the order of input sequences. Without this forget gate, rearranging the order of the preceding sequence will not affect subsequent outputs. For instance, in recurrent linear attention, if we change the order of x 1 and x 2 , the outputs y i , i ≥ 3 will not change. Hence, the forget gate ˜ A i plays an important role in selective SSM.

Despite its effectiveness, incorporating the forget gate also poses significant challenges. Firstly, it forces the model to adopt the recurrent formulation during both training and inference . Previous state space models typically use global convolution for efficient parallelizable training, which is incompatible with selective SSM due to the input-dependency of ˜ A i . As a remedy, Mamba [14] proposes a hardware-aware algorithm to speed up computation by performing parallel scan in recurrent mode (see the abstract of [14]). Although effective, such recurrent calculation unavoidably reduces model throughput and is still slower than parallel linear attention (eq. (2)). Secondly, the

𝝈

Norm

Norm

LA Block

Linear

Linear

Linear

Linear

Linear Attention

MLP

(a) Linear Attention Transformer

Norm

SSM Block

Linear

Linear

Conv

SSM

Linear

(b) Mamba

(c) M

I

LA (ours)

Linear Attention

: Elementwise Sum

𝝈

: Hadamard Product

: SiLU Activation

𝝈

Norm

Norm

Linear

Linear

Conv

Linear

Linear

Linear

MLP

MLLA Block

𝝈

𝝈

/1

I1

I

I

forget gate inherently functions in causal mode, which may not be very suitable for non-autoregressive vision models. Using the forget gate ˜ A i in vision tasks requires transforming the image into a 1D sequence and conducting recurrent computation, which limits the receptive field of each image token to its preceding sequence and incurs extra latency. Therefore, we believe that the forget gate is ideally suited for modeling causal data, which naturally needs auto-regressive training and recurrent calculation. However, it may not be as suitable for non-causal data like images. We further speculate that a suitable positional encoding can substitute for the forget gate, since certain positional encodings, such as LePE [9] and RoPE [41], can also provide local bias and positional information.

Shortcut. Selective SSM employs a learnable shortcut D ⊙ x i , making it resemble a residual block [22]. This shortcut may aid in optimizing the model and stabilizing training.

Normalization. The output in linear attention is divided by Q i Z i to ensure the attention weights sum up to 1. We believe this normalization is crucial for stabilizing training and improving model capacity. Let's consider an input α x i , α > 0 . It is transformed into α Q i , α K i , α V i through projections. If there is no normalization on attention weights, as α increases, α Q i exhibits larger similarities with all keys α Q i K ⊤ j , ∀ j . This indicates that longer tokens will have larger attention scores with every token, leading to longer output. Additionally, as α grows bigger, α K i yields bigger similarities with all queries α Q j K ⊤ i , ∀ j . This implies that all queries will focus more on longer tokens. As a result, longer tokens tend to dominate the whole feature map, while shorter tokens may fail to represent their corresponding semantics. This may result in training instability and could possibly lower model's expressiveness. Normalizing the attention weights can significantly alleviate this issue.

Multi-head. Linear attention commonly utilizes multi-head design [42] for better outcome. Multihead attention employs multiple groups of Q,K to produce attention matrices and allows the model to simultaneously attend to information from various representation subspaces at different positions, thus enhancing its expressive power.

4.3 Analysis of Macro Architecture Design

Modern linear attention Transformer models commonly adopt the block design depicted in Fig. 3(a), which are comprised of a linear attention sub-block and a MLP sub-block. In contrast, Mamba modifies the block design by combining two basic designs, H3 [13] and Gated Attention [24], resulting in the architecture illustrated in Fig. 3(b). The improved Mamba block integrates multiple operations such as selective SSM, depth-wise convolution, linear mapping, activation function, gating mechanism, etc., and tends to be more effective than the conventional Transformer block design.

4.4 Relationship between Mamba and Linear Attention Transformer

Mamba can be seen as a variant of linear attention Transformer with specialized linear attention and modified block design. The special linear attention variation, i.e. selective state space model, has five major distinctions from the common linear attention paradigm, detailed in Sec. 4.2. And the differences in block designs are analyzed in Sec. 4.3. In summary, Sec. 4.2 and Sec. 4.3 reveal the intimate relationship between Mamba and linear attention Transformer, highlighting a total of six differences: five in core operation and one in macro design.

Image

𝑨 ෩

௜ ൌ

0.2

𝑨 ෩

௜ ൌ

0.6

𝑨 ෩

௜ ൌ

0.8

(c) Forget Gate Illustration

(b) Forget Gate Average

1.0

ForgetGateValues

0.8

0.6

0.4

0.2

0.0

123456789101112

Layer

5 Empirical Study

Mamba [14] is seen as a powerful alternative to Transformer [42], while linear attention models generally being considered inferior [39, 15]. In Sec. 4, we illustrated the surprisingly close relationship between Mamba and linear attention Transformer and pointed out six major distinctions. In this section, we conduct experiments to assess the impact of each distinction, shedding some light on the core contributors behind Mamba's success.

5.1 Implementation

We employ the widely used Swin Transformer [32] architecture to verify the effects of the six differences. Firstly, we substitute the Softmax attention in Swin Transformer with linear attention to create our baseline model. Subsequently, we separately introduce each distinction to the baseline model to assess its impact. Based on the results, we further validate whether linear attention can achieve superior results with the merits of Mamba. Specifically, we integrate the useful designs into linear attention Transformer to create our Mamba-Inspired Linear Attention (MILA) model, and assess its effectiveness by comparing it with various vision Mamba designs across multiple tasks, including ImageNet-1K classification [8], COCO object detection [30], and ADE20K semantic segmentation [55]. Detailed model architectures and training setups are shown in the Appendix.

5.2 Empirical Analysis of the Differences

As shown in Tab. 1, we separately apply each distinction to the baseline linear attention model and assess their performances on ImageNet-1K.

Input Gate. Introducing the input gate results in a modest accuracy improvement of 0.2, indicating that it is slightly helpful for the model. Visualizations in Fig. 4(a) aid in understanding the impact of the input gate. It can be seen that the model tends to generate higher input gate values for more informative regions like fore-

ground objects, while suppressing less useful tokens. However, the model struggles to generate highly effective input gates, since the input gate values ∆ i = Softplus( x i W 1 W 2 ) are predicted solely from the current input token x i without considering the overall semantics of the image. For example, in one image, the dog may be the area of interest, whereas in another, it might simply be part of the background. Without leveraging information from the entire image, assigning large input gate values to the dog in one image while blocking it in another is impractical. Moreover, employing input gate results in a 7% decrease in model throughput.

Forget Gate. Employing the forget gate in linear attention leads to an obvious performance improvement from 77.6 to 78.4. However, such accuracy gain comes at a cost: the model throughput drops severely from 1152 to 743. This is because the forget gate has to employ recurrent calculation, which is slower than the parallelizable matrix multiplication in linear attention. It's worth noting that we already utilize the hardware-aware algorithm proposed in Mamba to speed up the recurrent computation. Thus, we believe the forget gate might not be very suitable for modeling non-causal data like

images, which do not inherently require recurrence. As an alternative, we analyze the fundamental properties of the forget gate and attempt to substitute it with other parallelizable operations.

In Fig. 4, we calculate the average of forget gate values in each layer and illustrate the attenuation effect of different forget gate values. In shallow layers, the forget gate values ˜ A i ≈ 0 . 2 , indicating that each token primarily focuses on itself and the preceding two tokens, demonstrating strong local bias. In deeper layers, the average is approximately 0.6-0.8, suggesting a broad receptive field for each token. This confirms our previous analysis that the forget gate offers two crucial properties for the model, namely local bias and positional information. We conduct

experiments to verify whether the forget gate can be replaced with proper positional encoding, which can also provide local bias and positional information. Results in Tab. 2 show that APE [42], LePE [9], CPE [5] and RoPE [41] can both help the model yield better results than the forget gate, while maintaining high throughput. We attribute the improved outcomes to a broader receptive field. Specifically, when using the forget gate, we have to adopt the recurrent linear attention format which restricts the receptive field of each token to the preceding sequence. In contrast, without the forget gate, it is natural to utilize parallel linear attention to achieve a global receptive field.

Shortcut. As illustrated in Tab. 1, the usage of learnable shortcut in linear attention provides a 0.2 accuracy gain, while decreasing the throughput from 1152 to 1066.

Normalization. Without normalization, the model suffers from severe performance degradation from 77.6 to 72.4. This can be attributed to the issue of long tokens dominating, as discussed in Sec. 4.2. To confirm this, we compute the standard deviation of token lengths (l2 norm) in each layer using both the baseline model and the model without attention normalization. As depicted in Fig. 5, without normalization, the standard devia-

1

2

3

4

5

6

7

8

9

10

11

12

Layer

10

1

10 0

10 1

10 2

Standard Deviation

w/ Normalization

w/o Normalization

tion of token lengths tends to be much larger than the baseline, particularly in the last two layers. This supports our analysis that without normalization, the difference in token length becomes significant, with some long tokens dominating the model while others struggling to convey their semantics.

Multi-head. Modern Transformers typically adopt the multi-head design [42] to enhance their expressive power. As shown in Tab. 1, removing this design reduces computational cost and accelerates the model but significantly diminishes performance. We consider this trade-off unwarranted.

Block Design. We employ two ways to assess the effects of Mamba's block design: 1. Substituting the entire Transformer block with Mamba's block architecture. 2. Replacing the attention sub-block with Mamba's block design, while preserving the MLP sub-block. In both settings, the selective SMMin Mamba's block is substituted with linear attention. To maintain similar FLOPs, we employ Mamba expansion factors [14] E = 2 . 0 and E = 1 . 0 for the two settings, respectively. The results are presented in Tab. 1 as 'Block Design all' and 'Block Design sub'. Both replacement approaches result in performance improvements, demonstrating the efficacy of Mamba's macro design. Substituting the attention sub-block yields better result, which creates our MILA block shown in Fig. 3(c). Notably, we omit the V projection before linear attention calculation, as a similar input projection already exists. The module complexity of a MILA block is expressed as:

which is slightly larger than the complexity of a Transformer block (Fig. 3a), 4 NC 2 +2 NCd +8 NC 2 .

5.3 Comparison with Mamba in Vision

Based on our findings, we integrate the forget gate and block design into linear attention, introducing our MILA model. Notably, we practically use LePE, CPE, and RoPE to replace the forget gate's local bias, input-dependent positional information, and global positional information, respectively.

ImageNet classification. As shown in Tab. 3, our MILA models consistently outperform various vision Mamba models across all model sizes, owing to the integration of useful designs from both Mamba and linear attention. These results also validate that with the merits of Mamba's two key designs, the inferior linear attention Transformer can surpass high-performance Mamba. Notably, we empirically observe that MILA exhibits greater scalability compared to vision Mamba models, as MILA-B achieves an accuracy of 85.3, surpassing other models by a significant margin. Additionally, MILA also outperforms various CNN and vision Transformer designs. For instance, MILA exhibits better performance than MambaOut [51], a recent work that removes the selective SSM in Mamba and employs a gated convolution architecture.

Inference time. We offer real speed measurements in Fig. 6. Substituting the forget gate with positional encoding, our MILA models benefit from parallelizable computation, resulting in significantly faster inference speeds compared to vision Mamba models. For instance, our model achieves 4.5x faster inference speed than Mamba2D [27], while maintaining better accuracy. Compared to the highly optimized VMamba model [31], our model also delivers a 1.5x speedup accompanied by a 0.5 accuracy gain. These sub-

1.0

3.0

5.0

7.0

9.0

Runtime (ms)

82

83

84

85

Accuracy (%)

VMamba

LocalVMamba

PlainMamba

EfficientVMamba

M

I

LA (ours)

4.5x

0.5

1.5x

0.5

1.7

stantial improvements in model speed further support our analysis that the parallelizable MILA is more suitable than Mamba for modeling non-causal data such as images.

COCO object detection. As shown in Tab. 4, on the COCO dataset, MILA models also achieve superior results to vision Mamba models, implying their effectiveness in high-resolution dense prediction tasks. MILA offers effective global modeling with linear complexity O ( N ) (see eq. (13)) and parallelizable computation , making it ideally suitable for high-resolution image modeling scenarios. Notably, MILA outperforms MambaOut [51] by a significant margin, which aligns with the findings in MambaOut [51].

ADE-20K semantic segmentation. We report the results on ADE-20K dataset in Tab. 5, where 'SS' and 'MS' denote single-scale and multi-scale testing, respectively. Similar to the object detection task, MILA yields better results in semantic segmentation, further verifying our analyses and the effectiveness of MILA model.

6 Conclusion

This paper reveals the surprisingly close relationship between the powerful Mamba and subpar linear attention Transformer, shedding some light on Mamba's superiority and success. We rephrase Mamba as a variant of linear attention Transformer and identify its six major special designs: input gate, forget gate, shortcut, no attention normalization, single-head and modified block design. Empirical validation shows that the forget gate and block design largely enhance performance, while the other distinctions offer marginal contributions or impair model performance. Based on our findings, we propose our Mamba-Inspired Linear Attention (MILA) model by incorporating the merits of these two key designs into linear attention. MILA surpasses various vision Mamba models across multiple tasks, while maintaining parallel computation and high inference speed.

References

Ameen Ali, Itamar Zimerman, and Lior Wolf. The hidden attention of mamba models. arXiv preprint arXiv:2403.01590 , 2024. 3

Daniel Bolya, Cheng-Yang Fu, Xiaoliang Dai, Peizhao Zhang, and Judy Hoffman. Hydra attention: Efficient attention with many heads. In ECCVW , 2022. 15

Nicolas Carion, Francisco Massa, Gabriel Synnaeve, Nicolas Usunier, Alexander Kirillov, and Sergey Zagoruyko. End-to-end object detection with transformers. In ECCV , 2020. 2

Krzysztof Choromanski, Valerii Likhosherstov, David Dohan, Xingyou Song, Andreea Gane, Tamas Sarlos, Peter Hawkins, Jared Davis, Afroz Mohiuddin, Lukasz Kaiser, et al. Rethinking attention with performers. In ICLR , 2021. 1, 3

Xiangxiang Chu, Zhi Tian, Bo Zhang, Xinlong Wang, and Chunhua Shen. Conditional positional encodings for vision transformers. arXiv preprint arXiv:2102.10882 , 2021. 8

Ekin D Cubuk, Barret Zoph, Jonathon Shlens, and Quoc V Le. Randaugment: Practical automated data augmentation with a reduced search space. In CVPRW , 2020. 15

Jifeng Dai, Min Shi, Weiyun Wang, Sitong Wu, Linjie Xing, Wenhai Wang, Xizhou Zhu, Lewei Lu, Jie Zhou, Xiaogang Wang, et al. Demystify transformers & convolutions in modern image deep networks. arXiv preprint arXiv:2211.05781 , 2022. 2

Jia Deng, Wei Dong, Richard Socher, Li-Jia Li, Kai Li, and Li Fei-Fei. Imagenet: A large-scale hierarchical image database. In CVPR , 2009. 7

Xiaoyi Dong, Jianmin Bao, Dongdong Chen, Weiming Zhang, Nenghai Yu, Lu Yuan, Dong Chen, and Baining Guo. Cswin transformer: A general vision transformer backbone with cross-shaped windows. In CVPR , 2022. 2, 6, 8, 10

Alexey Dosovitskiy, Lucas Beyer, Alexander Kolesnikov, Dirk Weissenborn, Xiaohua Zhai, Thomas Unterthiner, Mostafa Dehghani, Matthias Minderer, Georg Heigold, Sylvain Gelly, et al. An image is worth 16x16 words: Transformers for image recognition at scale. In ICLR , 2021. 8

Jiawei Du, Daquan Zhou, Jiashi Feng, Vincent Tan, and Joey Tianyi Zhou. Sharpness-aware training for free. In NeurIPS , 2022. 15

Yuxin Fang, Xinggang Wang, Rui Wu, and Wenyu Liu. What makes for hierarchical vision transformer? TPAMI , 2023. 2

Daniel Y Fu, Tri Dao, Khaled K Saab, Armin W Thomas, Atri Rudra, and Christopher Ré. Hungry hungry hippos: Towards language modeling with state space models. In ICLR , 2023. 6

Albert Gu and Tri Dao. Mamba: Linear-time sequence modeling with selective state spaces. arXiv preprint arXiv:2312.00752 , 2023. 1, 3, 4, 5, 7, 9

Dongchen Han, Xuran Pan, Yizeng Han, Shiji Song, and Gao Huang. Flatten transformer: Vision transformer using focused linear attention. In ICCV , 2023. 1, 7, 15

Dongchen Han, Yifan Pu, Zhuofan Xia, Yizeng Han, Xuran Pan, Xiu Li, Jiwen Lu, Shiji Song, and Gao Huang. Bridging the divide: Reconsidering softmax and linear attention. In NeurIPS , 2024. 1

Dongchen Han, Tianzhu Ye, Yizeng Han, Zhuofan Xia, Shiji Song, and Gao Huang. Agent attention: On the integration of softmax and linear attention. In ECCV , 2024. 3

Qi Han, Zejia Fan, Qi Dai, Lei Sun, Ming-Ming Cheng, Jiaying Liu, and Jingdong Wang. On the connection between local attention and dynamic depth-wise convolution. In ICLR , 2022. 2

Ali Hassani and Humphrey Shi. Dilated neighborhood attention transformer. arXiv preprint arXiv:2209.15001 , 2022. 8

Ali Hassani, Steven Walton, Jiachen Li, Shen Li, and Humphrey Shi. Neighborhood attention transformer. In CVPR , 2023. 2, 8

Kaiming He, Georgia Gkioxari, Piotr Dollár, and Ross Girshick. Mask r-cnn. In ICCV , 2017. 15

Kaiming He, Xiangyu Zhang, Shaoqing Ren, and Jian Sun. Deep residual learning for image recognition. In CVPR , 2016. 6

Vincent Tao Hu, Stefan Andreas Baumann, Ming Gui, Olga Grebenkova, Pingchuan Ma, Johannes S Fischer, and Björn Ommer. Zigma: A dit-style zigzag mamba diffusion model. In ECCV , 2024. 3

Weizhe Hua, Zihang Dai, Hanxiao Liu, and Quoc Le. Transformer quality in linear time. In ICML , 2022. 6

Tao Huang, Xiaohuan Pei, Shan You, Fei Wang, Chen Qian, and Chang Xu. Localmamba: Visual state space model with windowed selective scan. arXiv preprint arXiv:2403.09338 , 2024. 3, 8, 10, 16

Angelos Katharopoulos, Apoorv Vyas, Nikolaos Pappas, and François Fleuret. Transformers are rnns: Fast autoregressive transformers with linear attention. In ICML , 2020. 1, 2, 3

Shufan Li, Harkanwar Singh, and Aditya Grover. Mamba-nd: Selective state space modeling for multi-dimensional data. arXiv preprint arXiv:2402.05892 , 2024. 3, 8, 9, 16

Yanghao Li, Chao-Yuan Wu, Haoqi Fan, Karttikeya Mangalam, Bo Xiong, Jitendra Malik, and Christoph Feichtenhofer. Mvitv2: Improved multiscale vision transformers for classification and detection. In CVPR , 2022. 8

Opher Lieber, Barak Lenz, Hofit Bata, Gal Cohen, Jhonathan Osin, Itay Dalmedigos, Erez Safahi, Shaked Meirom, Yonatan Belinkov, Shai Shalev-Shwartz, et al. Jamba: A hybrid transformer-mamba language model. arXiv preprint arXiv:2403.19887 , 2024. 1

Tsung-Yi Lin, Michael Maire, Serge Belongie, James Hays, Pietro Perona, Deva Ramanan, Piotr Dollár, and C Lawrence Zitnick. Microsoft coco: Common objects in context. In ECCV , 2014. 7, 15

Yue Liu, Yunjie Tian, Yuzhong Zhao, Hongtian Yu, Lingxi Xie, Yaowei Wang, Qixiang Ye, and Yunfan Liu. Vmamba: Visual state space model. arXiv preprint arXiv:2401.10166 , 2024. 1, 3, 8, 9, 10, 16

Ze Liu, Yutong Lin, Yue Cao, Han Hu, Yixuan Wei, Zheng Zhang, Stephen Lin, and Baining Guo. Swin transformer: Hierarchical vision transformer using shifted windows. In ICCV , 2021. 2, 7, 8, 9, 10, 15

Zhuang Liu, Hanzi Mao, Chao-Yuan Wu, Christoph Feichtenhofer, Trevor Darrell, and Saining Xie. A convnet for the 2020s. In CVPR , 2022. 8, 10

Ilya Loshchilov and Frank Hutter. Decoupled weight decay regularization. In ICLR , 2018. 15

Jiachen Lu, Jinghan Yao, Junge Zhang, Xiatian Zhu, Hang Xu, Weiguo Gao, Chunjing Xu, Tao Xiang, and Li Zhang. Soft: Softmax-free transformer with linear complexity. In NeurIPS , 2021. 15

Zanlin Ni, Yulin Wang, Jiangwei Yu, Haojun Jiang, Yue Cao, and Gao Huang. Deep incubation: Training large models by divide-and-conquering. In ICCV , 2023. 2

Zanlin Ni, Yulin Wang, Renping Zhou, Yizeng Han, Jiayi Guo, Zhiyuan Liu, Yuan Yao, and Gao Huang. Enat: Rethinking spatial-temporal interactions in token-based image synthesis. In NeurIPS , 2024. 2

Xiaohuan Pei, Tao Huang, and Chang Xu. Efficientvmamba: Atrous selective scan for light weight visual mamba. arXiv preprint arXiv:2403.09977 , 2024. 3, 8, 10

Zhen Qin, Weixuan Sun, Hui Deng, Dongxu Li, Yunshen Wei, Baohong Lv, Junjie Yan, Lingpeng Kong, and Yiran Zhong. cosformer: Rethinking softmax in attention. In ICLR , 2022. 1, 3, 7

Zhuoran Shen, Mingyuan Zhang, Haiyu Zhao, Shuai Yi, and Hongsheng Li. Efficient attention: Attention with linear complexities. In WACV , 2021. 15

Jianlin Su, Murtadha Ahmed, Yu Lu, Shengfeng Pan, Wen Bo, and Yunfeng Liu. Roformer: Enhanced transformer with rotary position embedding. Neurocomputing , 2024. 6, 8

Ashish Vaswani, Noam Shazeer, Niki Parmar, Jakob Uszkoreit, Llion Jones, Aidan N Gomez, Łukasz Kaiser, and Illia Polosukhin. Attention is all you need. In NeurIPS , 2017. 1, 2, 3, 6, 7, 8

Wenhai Wang, Enze Xie, Xiang Li, Deng-Ping Fan, Kaitao Song, Ding Liang, Tong Lu, Ping Luo, and Ling Shao. Pyramid vision transformer: A versatile backbone for dense prediction without convolutions. In ICCV , 2021. 2

Wenhai Wang, Enze Xie, Xiang Li, Deng-Ping Fan, Kaitao Song, Ding Liang, Tong Lu, Ping Luo, and Ling Shao. Pvt v2: Improved baselines with pyramid vision transformer. Computational Visual Media , 2022. 8, 10

Zhuofan Xia, Xuran Pan, Shiji Song, Li Erran Li, and Gao Huang. Vision transformer with deformable attention. In CVPR , 2022. 2

Tete Xiao, Yingcheng Liu, Bolei Zhou, Yuning Jiang, and Jian Sun. Unified perceptual parsing for scene understanding. In ECCV , 2018. 9, 15

Yunyang Xiong, Zhanpeng Zeng, Rudrasis Chakraborty, Mingxing Tan, Glenn Fung, Yin Li, and Vikas Singh. Nyströmformer: A nyström-based algorithm for approximating self-attention. In AAAI , 2021. 3

Jing Nathan Yan, Jiatao Gu, and Alexander M Rush. Diffusion models without attention. In CVPR , 2024. 3

Chenhongyi Yang, Zehui Chen, Miguel Espinosa, Linus Ericsson, Zhenyu Wang, Jiaming Liu, and Elliot J Crowley. Plainmamba: Improving non-hierarchical mamba in visual recognition. arXiv preprint arXiv:2403.17695 , 2024. 3, 8, 10

Jianwei Yang, Chunyuan Li, Pengchuan Zhang, Xiyang Dai, Bin Xiao, Lu Yuan, and Jianfeng Gao. Focal self-attention for local-global interactions in vision transformers. In NeurIPS , 2021. 8, 10

Weihao Yu and Xinchao Wang. Mambaout: Do we really need mamba for vision? arXiv preprint arXiv:2405.07992 , 2024. 3, 8, 9, 10

Sangdoo Yun, Dongyoon Han, Seong Joon Oh, Sanghyuk Chun, Junsuk Choe, and Youngjoon Yoo. Cutmix: Regularization strategy to train strong classifiers with localizable features. In ICCV , 2019. 15

Hongyi Zhang, Moustapha Cisse, Yann N. Dauphin, and David Lopez-Paz. mixup: Beyond empirical risk minimization. In ICLR , 2018. 15

Zhun Zhong, Liang Zheng, Guoliang Kang, Shaozi Li, and Yi Yang. Random erasing data augmentation. In AAAI , 2020. 15

Bolei Zhou, Hang Zhao, Xavier Puig, Tete Xiao, Sanja Fidler, Adela Barriuso, and Antonio Torralba. Semantic understanding of scenes through the ade20k dataset. IJCV , 2019. 7, 15

Lei Zhu, Xinjiang Wang, Zhanghan Ke, Wayne Zhang, and Rynson WH Lau. Biformer: Vision transformer with bi-level routing attention. In CVPR , 2023. 2

Lianghui Zhu, Bencheng Liao, Qian Zhang, Xinlong Wang, Wenyu Liu, and Xinggang Wang. Vision mamba: Efficient visual representation learning with bidirectional state space model. arXiv preprint arXiv:2401.09417 , 2024. 1, 8, 16

Appendix

A Datasets and Experiment Details

ImageNet classification. The ImageNet-1K dataset comprises 1.28 million training images and 50,000 validation images, encompassing 1,000 classes. For a fair comparison, we train our models under the same settings as Swin Transformer [32]. Specifically, we utilize AdamW [34] optimizer to train all our models from scratch for 300 epochs. We apply a cosine learning rate decay schedule with a linear warm-up of 20 epochs and a weight decay of 0.05. The total batch size is 4096 and initial learning rate is set to 4 × 10 -3 . Augmentation and regularization strategies includes RandAugment [6], Mixup [53], CutMix [52], and random erasing [54]. In the training of MILA models, MESA [11] is employed to prevent overfitting.

COCO object detection. COCO [30] dataset is a widely adopted benchmark for object detection and instance segmentation with 118K training and 5K validation images. We follow the standard 1x and 3x Mask R-CNN [21] training setting in Swin Transformer [32] to conduct our experiments. The pretrained MILA models are employed as backbones.

ADE20K semantic segmentation. ADE20K [55] dataset contains 25K images, 20K for training, 2K for validation, and 3K for testing, with 150 semantic categories. UPerNet [46] is used as the segmentation framework and the same training setting as Swin Transformer [32] is adopted. We report both single-scale and multi-scale testing results.

B Additional Experimental Results

Additional comparison with advanced linear attention designs. The results are shown in Tab. 6. We empirically find that MILA outperforms various advanced linear attention designs without bells and whistles.

Ablation on the impact of MESA. Like in the early stages of studies on visual Transformer, currently vision Mamba research does not have a well-established and universally accepted training protocol. The conventional training setting for vision Transformer may not be optimal for vision Mamba and our Mamba-Inspired Linear Attention. Therefore, in the training of MILA models, we additionally employ the overfitting prevention strategy MESA [11] to fully demonstrate its potential. In Tab. 7, we provide the results without MESA. We can observe that: (1) MESA provides a modest accuracy gain of 0.1-0.3. (2) Without MESA, MILA models still significantly surpass various SOTA vision Mamba models.

C Model Architectures

We illustrate the architecture of our MILA model in Fig. 7 and summarize the detailed structure in Tab. 8. We adopt the common 4-stage framework to build MILA model by stacking our MILA blocks at each stage.

D Limitations

In this paper, we explore the similarities and disparities between Mamba and linear attention Transformer, providing comprehensive analyses to demystify the key factors behind Mamba's success.

×/u1D43F

1

Stage 1:

/u1D43B

4

× /u1D44A

4

×/u1D436

1

Stem

×/u1D43F

2

Stage 2:

/u1D43B

8

× /u1D44A

8

×/u1D436

2

×/u1D43F

3

×/u1D43F

4

Stage 4:

/u1D43B

32

× /u1D44A

32

×/u1D436

4

MLLA

Block

MLLA

Block

MLLA

Block

MLLA

Block

Stage 3:

/u1D43B

16

× W

16

×/u1D436

3

Specifically, we begin with the formulas and rephrase 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. Moreover, we meticulously analyze the pros and cons of each design and prove that the forget gate and block design are the core contributors to Mamba's success. Based on our findings, we propose our Mamba-Inspired Linear Attention (MILA) model, which surpasses various vision Mamba models across multiple tasks, while maintaining parallel computation and high inference speed. However, there may be other small differences between the implementation details of Mamba and linear attention Transformer, and this paper is not exhaustive.

NeurIPS Paper Checklist

1. Claims

Question: Do the main claims made in the abstract and introduction accurately reflect the paper's contributions and scope?

Answer: [Yes]

Justification: The main claims made in the abstract and introduction accurately reflect the paper's contributions and scope.

Guidelines:

The answer NA means that the abstract and introduction do not include the claims made in the paper.

The abstract and/or introduction should clearly state the claims made, including the contributions made in the paper and important assumptions and limitations. A No or NA answer to this question will not be perceived well by the reviewers.

The claims made should match theoretical and experimental results, and reflect how much the results can be expected to generalize to other settings.

It is fine to include aspirational goals as motivation as long as it is clear that these goals are not attained by the paper.

2. Limitations

Question: Does the paper discuss the limitations of the work performed by the authors?

Answer: [Yes]

Justification: We discuss the limitations of the work in appendix D.

Guidelines:

The answer NA means that the paper has no limitation while the answer No means that the paper has limitations, but those are not discussed in the paper.

The authors are encouraged to create a separate "Limitations" section in their paper.

The paper should point out any strong assumptions and how robust the results are to violations of these assumptions (e.g., independence assumptions, noiseless settings, model well-specification, asymptotic approximations only holding locally). The authors should reflect on how these assumptions might be violated in practice and what the implications would be.

The authors should reflect on the scope of the claims made, e.g., if the approach was only tested on a few datasets or with a few runs. In general, empirical results often depend on implicit assumptions, which should be articulated.

The authors should reflect on the factors that influence the performance of the approach. For example, a facial recognition algorithm may perform poorly when image resolution is low or images are taken in low lighting. Or a speech-to-text system might not be used reliably to provide closed captions for online lectures because it fails to handle technical jargon.

The authors should discuss the computational efficiency of the proposed algorithms and how they scale with dataset size.

If applicable, the authors should discuss possible limitations of their approach to address problems of privacy and fairness.

While the authors might fear that complete honesty about limitations might be used by reviewers as grounds for rejection, a worse outcome might be that reviewers discover limitations that aren't acknowledged in the paper. The authors should use their best judgment and recognize that individual actions in favor of transparency play an important role in developing norms that preserve the integrity of the community. Reviewers will be specifically instructed to not penalize honesty concerning limitations.

3. Theory Assumptions and Proofs

Question: For each theoretical result, does the paper provide the full set of assumptions and a complete (and correct) proof?

Answer: [Yes]

Justification: The paper provides a full set of assumptions and a complete, correct proof for the theoretical results in Sec. 3 and Sec. 4.

Guidelines:

The answer NA means that the paper does not include theoretical results.

All the theorems, formulas, and proofs in the paper should be numbered and crossreferenced.

All assumptions should be clearly stated or referenced in the statement of any theorems.

The proofs can either appear in the main paper or the supplemental material, but if they appear in the supplemental material, the authors are encouraged to provide a short proof sketch to provide intuition.

Inversely, any informal proof provided in the core of the paper should be complemented by formal proofs provided in appendix or supplemental material.

Theorems and Lemmas that the proof relies upon should be properly referenced.

4. Experimental Result Reproducibility

Question: Does the paper fully disclose all the information needed to reproduce the main experimental results of the paper to the extent that it affects the main claims and/or conclusions of the paper (regardless of whether the code and data are provided or not)?

Answer: [Yes]

Justification: The paper fully discloses all the information needed to reproduce the main experimental results of the paper in appendix A.

Guidelines:

The answer NA means that the paper does not include experiments.

If the paper includes experiments, a No answer to this question will not be perceived well by the reviewers: Making the paper reproducible is important, regardless of whether the code and data are provided or not.

If the contribution is a dataset and/or model, the authors should describe the steps taken to make their results reproducible or verifiable.

Depending on the contribution, reproducibility can be accomplished in various ways. For example, if the contribution is a novel architecture, describing the architecture fully might suffice, or if the contribution is a specific model and empirical evaluation, it may be necessary to either make it possible for others to replicate the model with the same dataset, or provide access to the model. In general. releasing code and data is often one good way to accomplish this, but reproducibility can also be provided via detailed instructions for how to replicate the results, access to a hosted model (e.g., in the case of a large language model), releasing of a model checkpoint, or other means that are appropriate to the research performed.

While NeurIPS does not require releasing code, the conference does require all submissions to provide some reasonable avenue for reproducibility, which may depend on the nature of the contribution. For example

(a) If the contribution is primarily a new algorithm, the paper should make it clear how to reproduce that algorithm.

(b) If the contribution is primarily a new model architecture, the paper should describe the architecture clearly and fully.

(c) If the contribution is a new model (e.g., a large language model), then there should either be a way to access this model for reproducing the results or a way to reproduce the model (e.g., with an open-source dataset or instructions for how to construct the dataset).

(d) We recognize that reproducibility may be tricky in some cases, in which case authors are welcome to describe the particular way they provide for reproducibility. In the case of closed-source models, it may be that access to the model is limited in some way (e.g., to registered users), but it should be possible for other researchers to have some path to reproducing or verifying the results.

5. Open access to data and code

Question: Does the paper provide open access to the data and code, with sufficient instructions to faithfully reproduce the main experimental results, as described in supplemental material?

Answer: [Yes]

Justification: The code is available at https://github.com/LeapLabTHU/MLLA.

Guidelines:

The answer NA means that paper does not include experiments requiring code.

Please see the NeurIPS code and data submission guidelines ( https://nips.cc/ public/guides/CodeSubmissionPolicy ) for more details.

While we encourage the release of code and data, we understand that this might not be possible, so 'No' is an acceptable answer. Papers cannot be rejected simply for not including code, unless this is central to the contribution (e.g., for a new open-source benchmark).

The instructions should contain the exact command and environment needed to run to reproduce the results. See the NeurIPS code and data submission guidelines ( https: //nips.cc/public/guides/CodeSubmissionPolicy ) for more details.

The authors should provide instructions on data access and preparation, including how to access the raw data, preprocessed data, intermediate data, and generated data, etc.

The authors should provide scripts to reproduce all experimental results for the new proposed method and baselines. If only a subset of experiments are reproducible, they should state which ones are omitted from the script and why.

At submission time, to preserve anonymity, the authors should release anonymized versions (if applicable).

Providing as much information as possible in supplemental material (appended to the paper) is recommended, but including URLs to data and code is permitted.

6. Experimental Setting/Details

Question: Does the paper specify all the training and test details (e.g., data splits, hyperparameters, how they were chosen, type of optimizer, etc.) necessary to understand the results?

Answer: [Yes]

Justification: The paper specifies all the training and test details in Sec. 5 and appendix A. Guidelines:

The answer NA means that the paper does not include experiments.

The experimental setting should be presented in the core of the paper to a level of detail that is necessary to appreciate the results and make sense of them.

The full details can be provided either with the code, in appendix, or as supplemental material.

7. Experiment Statistical Significance

Question: Does the paper report error bars suitably and correctly defined or other appropriate information about the statistical significance of the experiments?

Answer: [No]

Justification: Error bars are not reported because it would be too computationally expensive.

Guidelines:

The answer NA means that the paper does not include experiments.

The authors should answer "Yes" if the results are accompanied by error bars, confidence intervals, or statistical significance tests, at least for the experiments that support the main claims of the paper.

The factors of variability that the error bars are capturing should be clearly stated (for example, train/test split, initialization, random drawing of some parameter, or overall run with given experimental conditions).

The method for calculating the error bars should be explained (closed form formula, call to a library function, bootstrap, etc.)

The assumptions made should be given (e.g., Normally distributed errors).

It should be clear whether the error bar is the standard deviation or the standard error of the mean.

It is OK to report 1-sigma error bars, but one should state it. The authors should preferably report a 2-sigma error bar than state that they have a 96% CI, if the hypothesis of Normality of errors is not verified.

For asymmetric distributions, the authors should be careful not to show in tables or figures symmetric error bars that would yield results that are out of range (e.g. negative error rates).

If error bars are reported in tables or plots, The authors should explain in the text how they were calculated and reference the corresponding figures or tables in the text.

8. Experiments Compute Resources

Question: For each experiment, does the paper provide sufficient information on the computer resources (type of compute workers, memory, time of execution) needed to reproduce the experiments?

Answer: [Yes]

Justification: We provide information on the computer resources in appendix A.

Guidelines:

The answer NA means that the paper does not include experiments.

The paper should indicate the type of compute workers CPU or GPU, internal cluster, or cloud provider, including relevant memory and storage.

The paper should provide the amount of compute required for each of the individual experimental runs as well as estimate the total compute.

The paper should disclose whether the full research project required more compute than the experiments reported in the paper (e.g., preliminary or failed experiments that didn't make it into the paper).

9. Code Of Ethics

Question: Does the research conducted in the paper conform, in every respect, with the NeurIPS Code of Ethics https://neurips.cc/public/EthicsGuidelines ?

Answer: [Yes]

Justification: The research conducted in the paper conform with the NeurIPS Code of Ethics, in every respect.

Guidelines:

The answer NA means that the authors have not reviewed the NeurIPS Code of Ethics.

If the authors answer No, they should explain the special circumstances that require a deviation from the Code of Ethics.

The authors should make sure to preserve anonymity (e.g., if there is a special consideration due to laws or regulations in their jurisdiction).

10. Broader Impacts

Question: Does the paper discuss both potential positive societal impacts and negative societal impacts of the work performed?

Answer: [NA]

Justification: This work focuses on general model architecture and has no direct societal impact.

Guidelines:

The answer NA means that there is no societal impact of the work performed.

If the authors answer NA or No, they should explain why their work has no societal impact or why the paper does not address societal impact.

Examples of negative societal impacts include potential malicious or unintended uses (e.g., disinformation, generating fake profiles, surveillance), fairness considerations (e.g., deployment of technologies that could make decisions that unfairly impact specific groups), privacy considerations, and security considerations.

The conference expects that many papers will be foundational research and not tied to particular applications, let alone deployments. However, if there is a direct path to any negative applications, the authors should point it out. For example, it is legitimate to point out that an improvement in the quality of generative models could be used to generate deepfakes for disinformation. On the other hand, it is not needed to point out that a generic algorithm for optimizing neural networks could enable people to train models that generate Deepfakes faster.

The authors should consider possible harms that could arise when the technology is being used as intended and functioning correctly, harms that could arise when the technology is being used as intended but gives incorrect results, and harms following from (intentional or unintentional) misuse of the technology.

If there are negative societal impacts, the authors could also discuss possible mitigation strategies (e.g., gated release of models, providing defenses in addition to attacks, mechanisms for monitoring misuse, mechanisms to monitor how a system learns from feedback over time, improving the efficiency and accessibility of ML).

11. Safeguards

Question: Does the paper describe safeguards that have been put in place for responsible release of data or models that have a high risk for misuse (e.g., pretrained language models, image generators, or scraped datasets)?

Answer: [NA]

Justification: The paper poses no such risks as it is a foundational research focusing on general model structure.

Guidelines:

The answer NA means that the paper poses no such risks.

Released models that have a high risk for misuse or dual-use should be released with necessary safeguards to allow for controlled use of the model, for example by requiring that users adhere to usage guidelines or restrictions to access the model or implementing safety filters.

Datasets that have been scraped from the Internet could pose safety risks. The authors should describe how they avoided releasing unsafe images.

We recognize that providing effective safeguards is challenging, and many papers do not require this, but we encourage authors to take this into account and make a best faith effort.

12. Licenses for existing assets

Question: Are the creators or original owners of assets (e.g., code, data, models), used in the paper, properly credited and are the license and terms of use explicitly mentioned and properly respected?

Answer: [Yes]

Justification: We use all assets properly according to their licenses, and give credits to the creators in appendix A.

Guidelines:

The answer NA means that the paper does not use existing assets.

The authors should cite the original paper that produced the code package or dataset.

The authors should state which version of the asset is used and, if possible, include a URL.

The name of the license (e.g., CC-BY 4.0) should be included for each asset.

For scraped data from a particular source (e.g., website), the copyright and terms of service of that source should be provided.

If assets are released, the license, copyright information, and terms of use in the package should be provided. For popular datasets, paperswithcode.com/datasets has curated licenses for some datasets. Their licensing guide can help determine the license of a dataset.

For existing datasets that are re-packaged, both the original license and the license of the derived asset (if it has changed) should be provided.

If this information is not available online, the authors are encouraged to reach out to the asset's creators.

13. New Assets

Question: Are new assets introduced in the paper well documented and is the documentation provided alongside the assets?

Answer: [NA]

Justification: The paper does not release new assets.

Guidelines:

The answer NA means that the paper does not release new assets.

Researchers should communicate the details of the dataset/code/model as part of their submissions via structured templates. This includes details about training, license, limitations, etc.

The paper should discuss whether and how consent was obtained from people whose asset is used.

At submission time, remember to anonymize your assets (if applicable). You can either create an anonymized URL or include an anonymized zip file.

14. Crowdsourcing and Research with Human Subjects

Question: For crowdsourcing experiments and research with human subjects, does the paper include the full text of instructions given to participants and screenshots, if applicable, as well as details about compensation (if any)?

Answer: [NA]

Justification: The paper does not involve crowdsourcing nor research with human subjects. Guidelines:

The answer NA means that the paper does not involve crowdsourcing nor research with human subjects.

Including this information in the supplemental material is fine, but if the main contribution of the paper involves human subjects, then as much detail as possible should be included in the main paper.

According to the NeurIPS Code of Ethics, workers involved in data collection, curation, or other labor should be paid at least the minimum wage in the country of the data collector.

15. Institutional Review Board (IRB) Approvals or Equivalent for Research with Human Subjects

Question: Does the paper describe potential risks incurred by study participants, whether such risks were disclosed to the subjects, and whether Institutional Review Board (IRB) approvals (or an equivalent approval/review based on the requirements of your country or institution) were obtained?

Answer: [NA]

Justification: The paper does not involve crowdsourcing nor research with human subjects. Guidelines:

The answer NA means that the paper does not involve crowdsourcing nor research with human subjects.

Depending on the country in which research is conducted, IRB approval (or equivalent) may be required for any human subjects research. If you obtained IRB approval, you should clearly state this in the paper.

We recognize that the procedures for this may vary significantly between institutions and locations, and we expect authors to adhere to the NeurIPS Code of Ethics and the guidelines for their institution.

For initial submissions, do not include any information that would break anonymity (if applicable), such as the institution conducting the review.

Peer reviews:
{"IS_META_REVIEW": false, "comments": "SUMMARY:\nThis paper presents a thorough analysis of the key factors contributing to the success of the S6 module in Mamba model, and introduces a new linear attention vision network, MLLA, inspired by the S6’s design. Extensive experimental results show outstanding performance, validating the effectiveness of the proposed model.\n\nSTRENGTHS:\nThe motivation and analysis underlying this work are fascinating and perceptive, offering a profound examination of the mathematical relationships between Mamba and Linear Attention. \n\nA thorough investigation of the performance contributions of each component from S6 is conducted, with corresponding refinements made to linear attention, ultimately leading to the development of MLLA. \n\nThe proposed MLLA serves as a generic vision backbone network, which outperforms recent Mamba-based models, demonstrating its superior capabilities\n\nWEAKNESSES:\nI appreciate the paper's insightful analyses, but several key concerns regarding methodology and experiments need to be addressed. If the authors fully resolve these issues, I would be willing to reconsider my evaluation.\n\n**Possible inaccurate analysis of single-head attention**\n\nThe analysis of single-head attention appears to be inaccurate and unclear. Generally, multi-head attention in Transformer generates H dynamic matrices during attention computation, where H represents the number of heads. However, the paper seems to interpret S6 as a single-head module without providing sufficient evidence. The authors should explain this point from the perspective of the number of attention matrices generated. Moreover, according to Reference 1, S6 can actually produce multiple dynamic matrices instead of just one.\n\n**Unfair comparison on ImageNet-1K dataset**\n\nThe paper uses MESA as its optimizer, improving accuracy compared to AdamW. In contrast, the methods in Table 3 do not use MESA and may also be prone to overfitting. For fairness, authors should ensure that training strategies are consistent with competitors. Moreover, the authors should not hide this apparent difference in the appendix.\n\n\n**Questionable motivation for using Swin as the baseline**\n\nThe motivation for using Swin as a baseline is questionable. One important aspect of linear attention is its ability to efficiently establish global dependencies, so it is unclear why window-based linear attention is used. Additionally, the specific configuration of the baseline model, such as channels and depth, is not provided.\n\n**Unclear setting of d_state in SSM block design**\n\nIn the block design, it is unclear what value d_state of SSM is set to.\n\n\n**Insufficient experiments on downstream tasks**\n\n(1) Semantic segmentation should include tiny, small, and base models. (2) Mask R-CNN 3x should include the base model. (3) The performance comparison of MLLA-T and VMamba-T on object detection is lacking.\n\n**Unfair comparison in Table 6**\n\nThe comparison in Table 6 is unfair. The authors aim to compare the performance of different linear attention methods, but different block settings have a significant impact. The authors should use the same architecture, replacing only token mixer module.\n\n**Typo**\n\nIn line 294, 'SMM' should be 'SSM'.\n\nQUESTIONS:\nPlease see the main weaknesses.\n\nLIMITATIONS:\nPlease see the main weaknesses.", "TITLE": "Official Review", "RECOMMENDATION": 7, "REVIEWER_CONFIDENCE": 5, "SOUNDNESS_CORRECTNESS": 3, "DATE": "2024-07-08"}

comments: SUMMARY:
The paper takes a deep dive into the workings of Mamba in vision related tasks and compares it to Linear Attention. They conclude that Mamba is a special form of Linear Attention and describe the role that certain parts in the architecture and give them a name that better represent their actual use. They come up with input and forget gate that control the flow of information while shortcuts are closely related to the residual connections. The authors take those learnings and apply them to linear attention  and show that those concepts do improve the linear attention mechanism up to the point where it beats mamba.

STRENGTHS:
The authors draw clear connections between Linear Attention and Mamba which is showcased in terms of raw similarity (eq. 11 and 12). Furthermore, they underline this by showing the input gate values on two example images which helps general understanding. They demonstrate the usefulness of the explained modules in Mamba apply them to Linear Attention and show that they do improve performance.

In total a sound paper. The overall gist can be followed very nicely.

WEAKNESSES:
No apparent weaknesses

QUESTIONS:
- Why did you choose to use Swin Transformer?
- The forget gate creates local bias and position information but also decays the previous hidden state if I understood correctly. When replaced by RoPE or similar the performance increases as shown in Table2. Does this mean that the local bias and the decay can hinder performance?

LIMITATIONS:
The authors mention the limitations of their work, especially that is it no exhaustive.
TITLE: Official Review
SOUNDNESS_CORRECTNESS: 4
DATE: 2024-07-11

comments: SUMMARY:
This paper explores the similarities and differences between the Mamba and linear attention Transformer models. It redefines Mamba as a variant of linear attention Transformer with six key distinctions. The paper also studies each design's impact, identifying the forget gate and block design as key to Mamba's success. Based on these findings, the paper introduces a Mamba-like linear Attention (MLLA) model, which outperforms other vision Mamba models on various tasks while maintaining fast computation and inference speed.

STRENGTHS:
* The paper is well-written and well-motivated from the perspective of linear attention.

* The findings are interesting to me.

WEAKNESSES:
* Several works using Mamba for image synthesis should be discussed [1][2][3]. In Line 68, I wonder whether the exploration in this paper is orthogonal to previous explorations on Mamba. For example, Zigma considers layerwise scanpaths with 8 directions. Can the proposed method still yield some improvements on that result?

* Another consideration is that the authors should discuss something with this paper: https://arxiv.org/abs/2406.06484. Check Table 4; it provides a much more general framework that includes most of the linear attention models.

* My third concern is whether the exploration in this work can extend to other linear attention-based models, such as RWKV and xLSTM.

QUESTIONS:
I have some concerns (see weaknesses) about this paper. I am inclined to raise my score if my concerns are fully resolved.

**Reference:**  

[1],Diffusion Models Without Attention.CVPR24. 

[2],ZIGMA: A DiT-style Zigzag Mamba Diffusion Model,ECCV24. 

[3],Scalable Diffusion Models with State Space Backbone,Arxiv.

LIMITATIONS:
Yes, they are addressed and discussed.
TITLE: Official Review
SOUNDNESS_CORRECTNESS: 3
DATE: 2024-07-12

{"IS_META_REVIEW": false, "comments": "SUMMARY:\nThis paper primarily discusses the similarities and differences between the Mamba model and the Linear Attention Transformer, and conducts an in-depth analysis of the key factors contributing to Mamba's success in visual tasks. The paper elaborates on six major design differences of Mamba compared to the Linear Attention Transformer: input gate, forget gate, shortcut connection, attention-free normalization, single-head attention, and modified block design. For each of these designs, the author meticulously analyzes their advantages and disadvantages, and evaluates their applicability in visual tasks.\n\nThrough experimental research, the paper emphasizes that the forget gate and block design are the core contributors to Mamba's success. Based on these findings, the author proposes a model called Mamba-Like Linear Attention (MLLA), which integrates the advantages of the forget gate and block design into the linear attention framework. Experimental results show that MLLA outperforms various visual Mamba models in image classification and high-resolution dense prediction tasks, while maintaining parallel computing capabilities and fast inference speed.\n\nSTRENGTHS:\n1. The paper provides a new perspective for understanding Mamba's success by thoroughly analyzing the similarities and differences between the Mamba model and the Linear Attention Transformer. By rephrasing formulas, the paper considers Mamba as a variant of the Linear Attention Transformer and clearly points out Mamba's six design features, including input gate, forget gate, shortcut connection, attention-free normalization, single-head attention, and modified block design.\n\n2. Each design aspect is meticulously analyzed, and its advantages and disadvantages in visual tasks are evaluated. Experimental results verify that the forget gate and block design significantly contribute to Mamba's performance improvement, while other designs either have minimal marginal contributions or may potentially harm model performance.\n\n3.  The Mamba-Like Linear Attention (MLLA) model is proposed, combining the advantages of the forget gate and block design in linear attention. The MLLA model outperforms existing Mamba models in image classification and high-resolution dense prediction tasks while maintaining computational parallelization and high-speed inference capabilities.\n\nWEAKNESSES:\nThere are some minor issues:\n\n1. In the final MLLA model, there is no SSM but a forget gate. The forget gate was originally proposed in RNN and LSTM. Thus calling it a Mamba-like model seems to be improper.\n\n2. Previous \"Demystify\" papers are not cited in the paper, e.g., [a, b, c]. The final architecture MLLA follows the macro structure of Swin and [a,b,c] all show that the macro structure is very important but the local blocks are not so important. The paper should build a connection with the previous \"Demystify\" papers and tell us what are the most effective parts?\n\n[a] On the Connection between Local Attention and Dynamic Depth-wise Convolution, ICLR 2022\n[b] What Makes for Hierarchical Vision Transformer? DOI: 10.1109/TPAMI.2023.3282019\n[c] Demystify Transformers & Convolutions in Modern Image Deep Networks, arXiv:2211.05781\n\nQUESTIONS:\n1. How many GPUs are used to perform this research, including the training cost and ablation experiments cost?\n2. Why Fig. 1 is placed on page 2 but cited on page 4?\n3. What are the results of Mamba + Swin?\n\nLIMITATIONS:\nNope.", "TITLE": "Official Review", "RECOMMENDATION": 7, "REVIEWER_CONFIDENCE": 5, "SOUNDNESS_CORRECTNESS": 3, "DATE": "2024-07-13"}