S4ND: Modeling Images and Videos as Multidimensional Signals with State Spaces

Eric Nguyen, Karan Goel, Albert Gu, Gordon W. Downs, Preey Shah, Tri Dao, Stephen Baccus, Christopher RéNeurIPS 2022

Visual data such as images and videos are inherently continuous, multidimensional signals. Yet, most modern vision models—like Convolutional Neural Networks (CNNs) and Vision Transformers (ViTs)—treat them as discrete grids of pixels. This discrete perspective introduces significant limitations: CNNs typically suffer from restricted, local receptive fields, while ViTs struggle with the quadratic computational complexity of self-attention as image resolution increases. Furthermore, both architectures are usually "locked" into the specific resolution they were trained on, suffering severe performance drops when tested on different resolutions.

While 1D State Space Models (SSMs) like S4 have achieved incredible success in modeling long-range dependencies in continuous 1D signals (such as audio), they have not been efficiently adapted for multidimensional visual data. S4ND bridges this gap, extending the power of SSMs to 2D images and 3D videos by treating them as continuous signals.

The S4ND Architecture

S4ND is a novel deep learning layer designed as a modular, drop-in replacement for Conv2D or self-attention layers in existing architectures like ConvNeXt or ViT. It generalizes the 1D SSM into a multidimensional framework through several key innovations:

  • From ODE to PDE: Standard SSMs are governed by a 1D Ordinary Differential Equation (ODE). S4ND extends this to a Partial Differential Equation (PDE), applying an independent SSM along each continuous dimension (e.g., height, width, and time).
  • Factorized Kernels: To prevent the number of parameters from exploding exponentially with added dimensions, S4ND factors the multidimensional convolutional kernel into a tensor product of 1D kernels. This allows the model to leverage the highly efficient 1D S4 layer as a core building block.
  • Global Receptive Fields: Unlike standard CNNs that rely on small $3 \times 3$ or $7 \times 7$ filters, S4ND learns continuous convolutional kernels that span the entire input resolution. This grants every layer a global receptive field, capturing long-range spatial and temporal dependencies without the heavy computational cost of global self-attention.
Overview of the S4ND architecture, illustrating the generation of a continuous multidimensional kernel and the S4 bandlimiting process to prevent aliasing.

Overcoming Aliasing with S4 Bandlimiting

A critical challenge when transferring models across spatial resolutions is aliasing—the distortion that occurs when a high-resolution signal is sampled too sparsely. The authors discovered that while 1D SSMs transfer well between frequencies in audio, spatial data is much more prone to this phenomenon. To solve this, S4ND introduces a bandlimiting modification. By masking out high-frequency coefficients in the SSM's basis functions, S4ND effectively prevents aliasing, enabling stable and robust performance across varying resolutions.

Key Results and Zero-Shot Resolution Transfer

Because S4ND treats an image as a continuous signal $u(t^{(1)}, t^{(2)})$, the model becomes inherently resolution-invariant. The "sampling rate" can be adjusted at test time simply by changing the step size ($\Delta$) of the SSM. Evaluated across standard benchmarks, S4ND demonstrates highly competitive performance:

  • Image and Video Classification: On ImageNet-1k, S4ND-ViT outperformed the standard ViT-B baseline by 1.5% (80.4% vs 78.9%), while S4ND-ConvNeXt matched the highly optimized ConvNeXt-T. For video activity recognition on HMDB-51, S4ND improved upon an inflated 3D ConvNeXt baseline by 4 points (62.1% vs 58.1%).
  • Zero-Shot Resolution Transfer: In a dramatic demonstration on CIFAR-10, S4ND was trained on tiny $8 \times 8$ images and tested zero-shot on $32 \times 32$ images. It outperformed a standard Conv2D baseline by a massive 40% margin (73.7% vs 33.1% accuracy).
  • Training Efficiency: By leveraging "progressive resizing" (training on low-resolution inputs and finishing on high-resolution ones), S4ND trained 22% faster than a high-resolution baseline while maintaining within ~1% of the final accuracy.

Limitations and Future Directions

While S4ND is theoretically efficient, its current 2D implementation is approximately $2\times$ slower than standard Conv2D. This is largely due to the overhead of Fast Fourier Transform (FFT) operations and the lack of highly optimized CUDA kernels—a stark contrast to the years of hardware optimization behind standard convolutions. Additionally, the model currently requires reading from and writing to GPU memory for several intermediate FFT steps, though fusing these operations into a single kernel could significantly boost speed.

Ultimately, S4ND represents a major stepping stone toward vision models that are truly agnostic to sampling rates. By successfully modeling images and videos as continuous multidimensional signals, S4ND opens new doors for fields reliant on irregular or multi-resolution data, such as medical imaging and climate modeling.

Summary updated

BibTeX
@inproceedings{nguyen2022s,
  author = {Eric Nguyen and Karan Goel and Albert Gu and Gordon W. Downs and Preey Shah and Tri Dao and Stephen Baccus and Christopher Ré},
  title = {{S4ND: Modeling Images and Videos as Multidimensional Signals with State Spaces}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2022},
  url = {https://openreview.net/forum?id=de-91q_pCfC},
}
Figure