LaMamba-Diff: Linear-Time High-Fidelity Diffusion Models Based on Local Attention and Mamba

Yunxiang Fu, Chaoqi Chen, Yizhou YuarXiv 2024 · DOI

Abstract

Diffusion models have traditionally relied on Transformer architectures, which face a quadratic computational bottleneck as input resolution increases. We present LaMamba-Diff, a novel backbone that integrates the global modeling efficiency of State Space Models (Mamba) with the fine-grained precision of local self-attention. By employing a hierarchical U-Net structure and $1 \times 1$ patch sizes, LaMamba-Diff achieves state-of-the-art image generation quality while significantly reducing computational overhead compared to the Diffusion Transformer (DiT).

Introduction

State-of-the-art diffusion models, such as Stable Diffusion 3 and Sora, primarily utilize the Transformer architecture. While Transformers excel at capturing global dependencies via self-attention, they suffer from a quadratic computational bottleneck ($O(L^2)$), where costs scale with the square of the input length. This limitation makes high-resolution generation and the use of fine-grained image patches computationally prohibitive.

Recently, the Mamba State Space Model (SSM) has emerged as a linear-time ($O(L)$) alternative. However, Mamba's global compression often sacrifices local, fine-grained details necessary for high-fidelity image synthesis. LaMamba-Diff addresses this by combining Mamba’s global modeling with local self-attention within a hierarchical U-Net framework.

High-fidelity image samples generated by LaMamba-Diff on ImageNet.

Methodology

The core of the architecture is the Local Attentional Mamba (LaMamba) block, which integrates three key components:

  1. Visual State Space Model (VSSM): A 2D-tailored Mamba variant that uses multi-directional spatial scans to capture global context efficiently.
  2. Local Attention Module: Computes pairwise interactions within small, fixed-size windows (e.g., $8 \times 8$). This maintains linear complexity relative to the total pixel count while preserving local textures.
  3. Feed-Forward Network (FFN): A standard layer for feature processing.

These blocks are arranged in a hierarchical U-Net structure. Unlike the flat, isotropic design of the Diffusion Transformer (DiT), this multi-scale approach enables the model to process information more efficiently. This efficiency allows for the use of $1 \times 1$ patches, ensuring that every latent pixel is treated as an individual token, thereby avoiding the blurring artifacts common in larger patch sizes.

Experimental Results

LaMamba-Diff was evaluated on ImageNet at $256 \times 256$ and $512 \times 512$ resolutions. The model demonstrates superior performance and efficiency compared to established baselines.

Comparison of FID vs. Number of Parameters and GFLOPs (bubble size) on ImageNet 256x256. LaMamba-Diff (purple) consistently outperforms DiT (grey).

Performance and Efficiency

On ImageNet $256 \times 256$, the LaMamba-Diff-XL model achieved a Fréchet Inception Distance (FID) of 2.04, surpassing DiT-XL/2's score of 2.27. Remarkably, it achieved this with 57.6% fewer GFLOPs and 19 million fewer parameters. At $512 \times 512$ resolution, the model achieved an FID of 3.01, utilizing 61.6% fewer GFLOPs than its DiT counterpart.

Scalability

The architecture exhibits strong scaling properties. As resolution increases to $1024 \times 1024$, LaMamba-Diff requires only approximately 27% of the GFLOPs needed by DiT, highlighting its potential for ultra-high-resolution synthesis.

Conclusion

LaMamba-Diff successfully bridges the gap between the efficiency of linear-time state-space models and the precision of local attention. By leveraging a hierarchical U-Net design and $1 \times 1$ patching, it sets a new standard for efficient, high-fidelity diffusion backbones. Future work includes extending this architecture to video generation, where linear scaling is critical for handling massive temporal token sequences.

Summary updated

BibTeX
@misc{fu2024lamamba,
  author = {Yunxiang Fu and Chaoqi Chen and Yizhou Yu},
  title = {{LaMamba-Diff: Linear-Time High-Fidelity Diffusion Models Based on Local Attention and Mamba}},
  year = {2024},
  eprint = {2408.02615},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2408.02615},
}
Figure