Serpent: Scalable and Efficient Image Restoration via Multi-scale Structured State Space Models

Mohammad Shahab Sepehri, Zalan Fabian, Mahdi Soltanolkotabi

TL;DR

Serpent is a novel image restoration architecture that leverages State Space Models (SSMs) to achieve a global receptive field with linear computational complexity. By combining Mamba-style selective scans with a hierarchical U-Net structure, it matches state-of-the-art restoration quality while requiring up to 150x less compute (FLOPS) and 5x less GPU memory than leading Transformer-based models.

What Problem Does This Paper Address?

Image restoration—tasks like deblurring, super-resolution, and inpainting—requires models to understand both local textures and global structures. Historically, researchers have relied on two main building blocks:

  1. Convolutional Neural Networks (CNNs): These are computationally efficient but "near-sighted," struggling to capture long-range dependencies because their kernels only look at small, local neighborhoods.
  2. Transformers: These excel at capturing global context through self-attention, but they suffer from quadratic complexity. As image resolution increases, the memory and compute requirements explode, making high-resolution restoration (e.g., 2K or 4K) prohibitively expensive or impossible on standard hardware.

The authors of Serpent aim to break this trade-off, seeking an architecture that offers the global reach of Transformers with the efficiency and linear scaling of CNNs.

Methods

Serpent introduces a hierarchical architecture built around Structured State Space Models (SSMs), specifically the selective scan mechanism (S6) popularized by the Mamba architecture.

Key components include:

  • Visual State Space (VSS) Blocks: Since SSMs are inherently 1D sequence models, Serpent uses VSS blocks to adapt them for 2D images. These blocks scan the image features in four different directions (top-left to bottom-right, and so on) to ensure spatial relationships are captured across the entire 2D plane.
  • Multi-scale U-Net Structure: Inspired by traditional signal processing, the model uses a U-Net-like hierarchy. It partitions the image into patches, embeds them, and then progressively downsamples them into a "bottleneck" before upsampling back to the original resolution.
  • S-Blocks: These are the core processing units containing stacks of VSS blocks. To maximize efficiency, the authors allocate more blocks at lower spatial scales where the sequences are shorter and compute is cheaper.
Figure 2: The VSS block [13] scans the image along four different unrolled direction using state space models (SS2D). Linear layers are used to create feature embeddings, for gating and to produce the final output.
Figure 3: Overview of our Serpent. Serpent has a U-Net architecture and use S-blocks at each layer. The S-block D is consist of n VSS block in sequence.

Datasets

The models were trained and evaluated on the FFHQ (Flickr-Faces-HQ) dataset, which contains 70,000 high-quality human face images. The authors tested Serpent on two specific restoration tasks:

  1. Gaussian Deblurring: Recovering clean images from versions corrupted by a large blur kernel and additive noise.
  2. 8× Super-resolution: Upscaling low-resolution images by a factor of eight.

Key Insights and Ideas

  • Linear Scaling is the "Killer App": The most significant insight is that SSMs allow for linear scaling relative to the number of pixels. This allows Serpent to process 2048×2048 resolution images where state-of-the-art models like SwinIR or Restormer would run out of memory (OOM).
  • Content-Dependent Processing: Unlike standard convolutions, which apply the same filter to every part of an image, the selective scan mechanism in Serpent is input-dependent. This allows the model to "focus" on relevant information and ignore noise more effectively.
  • Efficiency through Hierarchy: By combining SSMs with a multi-scale U-Net approach, the model can extract a compact representation of the image at the bottleneck, significantly reducing the total number of operations needed for high-quality reconstruction.

Key Results

Serpent demonstrates dramatic efficiency gains without sacrificing reconstruction quality:

  • Compute Efficiency: At 512× resolution, the "Serpent-B" variant achieves a 150x reduction in FLOPS compared to SwinIR while maintaining comparable PSNR and SSIM scores.
  • Memory Savings: Serpent utilizes up to 5x less GPU memory during training than Restormer. As shown in Figure 1, Serpent's memory usage scales gracefully, matching the behavior of fully convolutional networks.
  • Speed: The model is capable of processing 35x more images per second than SwinIR during inference and trains significantly faster (e.g., 5x faster than SwinIR).
  • High-Res Capability: Serpent is one of the few models capable of 2048× resolution reconstruction on a single H100 GPU without needing specialized tricks like patch-by-patch processing.
Figure 1: Efficiency of Serpent: Serpent out-scales state-of-the-art reconstruction techniques in terms of FLOPS, especially at high image resolutions (left). Our technique matches the performance of state-of-the-art methods while utilizing 5× less GPU memory during training, matching the scaling of fully convolutional architectures (right). We plot results with batch size 1 on a single H100 GPU with 80 GB memory. Missing data points indicate that the given model is out of memory with the specific input resolution.

Limitations and Future Work

  • Software Optimization: The authors note that SSMs currently lack the highly optimized, low-level GPU kernel support that convolutions and attention mechanisms have enjoyed for years. Improved hardware/software support for selective scans could unlock even greater speedups.
  • Dataset Bias: As a supervised learning method, Serpent is subject to the biases present in its training data (FFHQ). The authors emphasize the need for training on diverse, fair datasets to avoid negative societal impacts.
  • Generalization: While the results on faces are impressive, further work is needed to validate the architecture across a wider variety of natural image categories and diverse restoration artifacts.

Summary updated

BibTeX
@misc{sepehri2024serpent,
  author = {Mohammad Shahab Sepehri and Zalan Fabian and Mahdi Soltanolkotabi},
  title = {{Serpent: Scalable and Efficient Image Restoration via Multi-scale Structured State Space Models}},
  year = {2024},
  eprint = {2403.17902},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2403.17902},
}
Figure