TL;DR
MaskMamba marries state-space models (Mamba) with Transformers inside a non-autoregressive, masked image modeling framework. By redesigning bidirectional Mamba specifically for masked generation and cascading Mamba layers before Transformer layers, the model achieves better synthesis quality than pure Transformer or Mamba baselines while slashing high-resolution inference latency by over 54% compared to standard Transformers.
What Problem Does This Paper Address?
Modern generative vision models usually rely on one of two architectures:
- Autoregressive models / Diffusion models with Transformers (DiTs): They offer strong generative quality, but self-attention scales quadratically ($\mathcal{O}(L^2)$) with sequence length, making high-resolution generation memory-heavy and slow. Moreover, diffusion models typically need dozens to hundreds of iterative denoising steps.
- Pure Mamba / State-Space Models (SSMs): While Mamba offers linear computational complexity ($\mathcal{O}(L)$), most vision SSM efforts focus on diffusion backbones and preserve causal (unidirectional) design patterns inherited from language modeling.
The authors explore how to efficiently use Mamba within a non-autoregressive Masked Image Modeling (MIM) framework (like MaskGIT or MUSE), predicting visual tokens in just 20–25 parallel steps without blowing up compute at high resolutions.
Methods
MaskMamba tokenizes images into discrete codebook indices with a VQ-tokenizer, randomly masks a portion of tokens during training, and optimizes a cross-entropy loss to predict the masked tokens. The model introduces several architectural innovations:
- Bi-Mamba-v2 Layer:
- Standard Convolutions over Causal Convolutions: Since masked image modeling is inherently bidirectional, removing causal masking in the 1D convolution enables all tokens to attend bidirectionally across the sequence.
- Concatenation over Multiplication: Rather than gating via element-wise multiplication at the final stage of Bi-Mamba, the authors concatenate projected representations and apply a linear layer, saving compute and improving inference throughput by 17.77%.
- Symmetric SSM Branch: Features are scanned forward and backward (via sequence flipping), with an added convolutional block on the parallel branch to prevent feature loss.
- Hybrid Serial Stacking (
MMMM...SSSS): The authors tested parallel and interleaved structures, finding that placing Bi-Mamba-v2 in the first $N/2$ layers and standard Transformer self-attention in the last $N/2$ layers performs best. The SSM layers efficiently process spatial sequence features early on, while attention layers refine global cross-token representations at deeper stages. - In-Context Conditioning at the Sequence Center: Class labels or T5 text embeddings are prepended into the token stream. Crucially, inserting condition tokens in the middle of the sequence (rather than at the head or tail) minimizes the maximum attention distance to masked tokens, boosting guidance efficiency.
Datasets
- ImageNet-1K ($256 \times 256$): Used for class-conditional image generation benchmarks across Base (103M), Large (329M), and XL (741M) parameter scales.
- Conceptual Captions (CC3M): Used for text-to-image training and evaluation.
- MS-COCO (2014 Validation Set): Zero-shot text-to-image evaluation for models trained on CC3M.
- No new datasets or benchmarks were introduced.
Key Insights and Ideas
- Causal assumptions hold vision SSMs back: In masked generation, autoregressive masking artificially starves the model of bidirectional spatial context. Switching to standard convolutions immediately unlocks better token representations.
- Positioning conditioning tokens matters in SSMs: Because SSMs process inputs sequentially, placing conditioning tokens at the head or tail creates an information bottleneck for distant tokens. Inserting conditioning tokens into the middle yielded clear quantitative gains (FID dropped from 7.15 to 6.73).
- SSM first, Attention second: Pure SSMs struggle with fine global image composition compared to Transformers, but pure Transformers choke on sequence length. Front-loading Mamba to handle low-level sequence processing followed by deep Transformer attention provides the sweet spot for generative fidelity.
Key Results
- Class-Conditional Generation (ImageNet $256 \times 256$):
- MaskMamba-XL (741M): Achieved an FID-50k of 5.79 (IS: 139.30) in 25 decoding steps, outperforming a matched Transformer-XL (FID: 5.96, IS: 140.81) and earlier masked models like MaskGIT (FID: 6.18).
- MaskMamba-L (329M): Reached an FID of 6.61, beating both pure Bi-Mamba-L (FID: 12.29) and Transformer-L (FID: 7.08).
- Text-Conditional Generation (CC3M & MS-COCO):
- On CC3M validation, MaskMamba-XL improved FID to 18.11 (vs. 19.20 for Transformer-XL).
- On MS-COCO 30k zero-shot, MaskMamba-XL reached an FID of 25.93 (vs. 43.21 for Transformer-XL).
- Speed and Memory Scaling:
- At a resolution of $2048 \times 2048$, a single Bi-Mamba-v2 layer achieved a 54.44% speedup (1.5$\times$ faster) over a Transformer layer.
- At batch size 6, a standard Transformer layer ran out of memory (exceeding 63 GB), whereas Bi-Mamba-v2 consumed only 38 GB.
Limitations and Future Work
- Resolution crossover threshold: At sequence lengths corresponding to resolutions under $1024 \times 1024$, Bi-Mamba-v2 is slightly slower than pure Transformer layers due to kernel invocation overhead; its efficiency gains primarily materialize at higher resolutions.
- Text Dataset Quality: Visual quality on text-to-image tasks is bottlenecked by the smaller scale and noisy nature of CC3M text captions, showing visible artifacts on complex prompts.
- Future Directions: Expanding MaskMamba to massive web-scale image-text datasets (e.g., LAION), scaling beyond 1B parameters, and exploring native high-resolution image decoding without heavy downsampling tokenizers.
Summary updated