Source-linked AI summary

MambaOut: Do We Really Need Mamba for Vision?

Weihao Yu, Xinchao Wang

arXiv:2405.07992v3cs.CVcs.AIcs.LG

TL;DR

The paper asks whether Mamba is necessary for vision given its RNN-like SSM mechanism and the underwhelming performance of visual Mamba models. It analyzes task characteristics, evaluates SSM-free MambaOut models, and finds that MambaOut surpasses visual Mamba models on ImageNet classification but not on detection and segmentation.

  • Problem

    Visual Mamba models often underperform convolutional and attention-based models, raising whether Mamba is necessary across visual recognition tasks.

  • Method

    The paper analyzes Mamba’s long-sequence and autoregressive characteristics and constructs MambaOut by stacking Gated CNN blocks without SSM.

  • Results

    MambaOut surpasses visual Mamba models on ImageNet classification but falls short of state-of-the-art visual Mamba models on detection and segmentation.

  • Takeaways & Limitations

    Mamba appears unnecessary for ImageNet classification, while its potential remains worth exploring for long-sequence detection and segmentation tasks.

  • Takeaways & Limitations

    SSM’s causal token mixing restricts each hidden state to preceding and current timesteps, limiting access to the full image context.

Abstract

from arXiv · show

Mamba, an architecture with RNN-like token mixer of state space model (SSM), was recently introduced to address the quadratic complexity of the attention mechanism and subsequently applied to vision tasks. Nevertheless, the performance of Mamba for vision is often underwhelming when compared with convolutional and attention-based models. In this paper, we delve into the essence of Mamba, and conceptually conclude that Mamba is ideally suited for tasks with long-sequence and autoregressive characteristics. For vision tasks, as image classification does not align with either characteristic, we hypothesize that Mamba is not necessary for this task; Detection and segmentation tasks are also not autoregressive, yet they adhere to the long-sequence characteristic, so we believe it is still worthwhile to explore Mamba's potential for these tasks. To empirically verify our hypotheses, we construct a series of models named MambaOut through stacking Mamba blocks while removing their core token mixer, SSM. Experimental results strongly support our hypotheses. Specifically, our MambaOut model surpasses all visual Mamba models on ImageNet image classification, indicating that Mamba is indeed unnecessary for this task. As for detection and segmentation, MambaOut cannot match the performance of state-of-the-art visual Mamba models, demonstrating the potential of Mamba for long-sequence visual tasks. The code is available at https://github.com/yuweihao/MambaOut

1 Introduction

The paper argues that Mamba is best suited to long-sequence, autoregressive tasks, making it unnecessary for image classification but potentially useful for detection and segmentation. MambaOut experiments support this task-dependent view.

  • Motivation and hypotheses: Mamba is conceptually suited to tasks combining long sequences and autoregressive processing because its SSM uses an RNN-like mechanism.The paper characterizes causal token mixing as restricting each token to preceding and current tokens.
  • Motivation and hypotheses: Image classification matches neither characteristic, whereas detection and segmentation match the long-sequence characteristic but are not autoregressive.The paper therefore proposes different expectations for SSM across these visual tasks.
  • MambaOut validation: MambaOut removes SSM by stacking Gated CNN blocks, isolating whether Mamba’s core token mixer is necessary.Its distinction from Mamba blocks is the absence of SSM.
  • MambaOut validation: MambaOut surpasses visual Mamba models on ImageNet classification but trails state-of-the-art visual Mamba models on detection and segmentation.These opposing results support the hypotheses that SSM is unnecessary for classification yet potentially beneficial for long-sequence visual tasks.

2 Related work

The related work traces efforts to address Transformer attention’s quadratic sequence-length cost and to adapt RNN-like SSMs, including Mamba, to visual recognition. This paper instead studies whether Mamba is necessary for vision.

  • Efficient token mixing: Transformer attention has quadratic complexity in sequence length, motivating token mixers with linear complexity and other efficiency strategies.Examples include dynamic convolution, low-rank approaches, kernelization, limited token-mixing ranges, and history-memory compression.
  • Visual Mamba models: Prior visual Mamba models apply SSMs in isotropic, hierarchical, locally biased, and plain vision architectures.The cited examples include Vision Mamba, VMamba, LocalMamba, and PlainMamba.
  • This paper’s focus: Rather than designing another visual Mamba architecture, this work investigates whether Mamba is necessary in visual recognition contexts.The stated goal is to provide insight for future visual Mamba research.

3 Conceptual discussion

Mamba’s recurrent SSM is designed for long sequences and causal token mixing, trading attention’s lossless memory for constant-cost recurrent updates. Visual tasks differ: ImageNet classification has neither characteristic, while COCO detection and ADE20K segmentation involve long sequences, motivating task-specific hypotheses about Mamba’s necessity.

  • Memory mechanisms: RNN-like SSMs compress history into fixed-size hidden states, keeping memory-integration complexity constant but making memory inherently lossy.Causal attention instead stores all previous keys and values, preserving information while increasing integration cost as sequences lengthen.
  • Mamba’s task characteristics: Mamba is ideally suited to tasks involving long sequences and causal token mixing.Its recurrent SSM inherently operates causally and is intended to process long sequences efficiently.
  • Visual-task characteristics: ImageNet classification uses 196 tokens, far below the long-sequence thresholds τsmall = 2304 and τbase = 4608.With 224 × 224 images and 16 × 16 patches, classification does not qualify as a long-sequence task.
  • Visual-task characteristics: COCO detection and ADE20K segmentation use approximately 4K tokens, exceeding τsmall and approximately matching τbase, so both qualify as long-sequence tasks.These tasks satisfy the long-sequence characteristic even though visual recognition generally permits access to the complete image.
  • Token-mixing modes: Fully-visible mixing suits visual understanding because each token can access the entire image, whereas recurrent SSMs impose causal access to preceding and current tokens.Applying causal restrictions to ViT causes a performance drop on ImageNet, indicating that causal mixing is unnecessary for this understanding task.
  • Hypotheses: The paper therefore hypothesizes that SSM is unnecessary for ImageNet classification but remains worth exploring for detection and segmentation.The hypotheses follow from classification meeting neither Mamba characteristic while detection and segmentation meet the long-sequence characteristic.

4 Experimental verification

The experiments compare MambaOut, which removes SSM from the Mamba-derived block, with visual Mamba and other vision models across classification, detection, and segmentation. MambaOut leads on ImageNet classification but trails state-of-the-art visual Mamba models on detection and segmentation.

  • Model construction: MambaOut removes SSM from the Mamba block by using a Gated CNN token mixer, enabling direct evaluation of SSM’s necessity.The models stack Gated CNN blocks, whose primary architectural difference from Mamba is the absence of SSM.
  • Experimental setup: MambaOut models are evaluated against visual Mamba, convolutional, and attention-based models on ImageNet, COCO, and ADE20K.The experiments use ImageNet classification, Mask R-CNN for COCO detection and instance segmentation, and UperNet for ADE20K semantic segmentation.
  • Image classification on ImageNet: 84.1% top-1 accuracy is achieved by MambaOut-Small, 0.4% above LocalVMamba-S while requiring only 79% of its MACs.MambaOut consistently outperforms visual Mamba models across model sizes on ImageNet despite not incorporating SSM.
  • Image classification on ImageNet: More than 1% accuracy separates CAFormer-M36 from comparable visual Mamba models on ImageNet.CAFormer-M36 uses separable convolutions and vanilla attention, and the reported gap indicates visual Mamba models also trail strong convolution-attention alternatives.
  • Object detection and instance segmentation on COCO: 1.4 APb and 1.1 APm are the deficits of MambaOut-Tiny against VMamba-T with Mask R-CNN on COCO.MambaOut can surpass some visual Mamba models but does not match state-of-the-art visual Mamba models for detection and instance segmentation.
  • Semantic segmentation on ADE20K: 0.5 mIoU separates LocalVMamba-T from MambaOut-Tiny in both single-scale and multi-scale ADE20K evaluations.The semantic segmentation trend mirrors COCO: MambaOut beats some visual Mamba models but not the strongest ones.

5 Conclusion

The paper concludes that Mamba is best suited to long-sequence and autoregressive tasks, making it unnecessary for ImageNet classification but worth further exploration for detection and segmentation. MambaOut empirically supports these claims, outperforming visual Mamba models on ImageNet while trailing state-of-the-art visual Mamba models on detection and segmentation.

  • Mamba is ideally suited for tasks with long-sequence and autoregressive characteristics.
  • Mamba is unnecessary for ImageNet image classification because the task meets neither characteristic.
  • MambaOut surpasses all visual Mamba models on ImageNet image classification.
  • Detection and segmentation tasks merit further Mamba exploration because they align with at least the long-sequence characteristic.
  • MambaOut exhibits a notable performance gap compared with state-of-the-art visual Mamba models on detection and segmentation.
  • Computational resource limitations restricted this paper to verifying the Mamba concept for visual tasks.

A More details of MambaOut models

This section documents the MambaOut model configurations and ImageNet training hyper-parameters. Table 4 organizes model settings across four stages, while Table 5 lists classification hyper-parameters.

  • Table 4 presents MambaOut configurations as tuples corresponding to the models’ four stages.
  • Table 5 lists the hyper-parameters used to train MambaOut on ImageNet image classification.
Loading 2405.07992v3…