The Generalized Spatial Propagation Network (GSPN) introduces a novel linear attention mechanism tailored for computer vision. By treating images as 2D structures rather than flattened 1D sequences, GSPN achieves state-of-the-art performance in image classification and generation. Most notably, it offers massive efficiency gains, accelerating high-resolution image generation (16K) by over 84× compared to standard Transformers.
The Challenge of High-Resolution Vision
While Transformers have dominated computer vision, they face two significant hurdles:
- Quadratic Complexity: The computational cost of standard self-attention grows quadratically ($O(N^2)$) with the number of pixels, making high-resolution processing prohibitively expensive.
- Loss of Spatial Coherence: Efficient alternatives like Linear Attention or State-Space Models (e.g., Mamba) often flatten 2D images into 1D sequences. This structure-agnostic approach ignores the natural spatial relationships inherent in visual data.
Previous attempts at 2D linear propagation struggled with stability—signals would often vanish or explode—and were difficult to scale as foundational building blocks for deep networks.
The GSPN Framework: Stable 2D Linear Propagation
GSPN reimagines attention as a parallelized 2D line-scan process. Instead of a raster scan of $N$ elements, GSPN performs parallel scans across rows and columns, reducing the effective sequence length to $\sqrt{N}$ for square images.
Key Technical Innovations
- Stability-Context Condition: By ensuring propagation matrices are "row-stochastic" (non-negative and summing to one), the authors guarantee stable, long-range context propagation without numerical instability.
- Learnable Directional Merger: GSPN uses a data-driven linear layer to adaptively weight information from different scanning directions (e.g., top-down, left-right), replacing manual pooling methods.
- Hybrid Architecture: The model employs "Local GSPN" in early layers for fine-grained details and "Global GSPN" in later layers for high-level semantic understanding.
- Implicit Spatial Encoding: The scanning process inherently encodes spatial relationships, allowing GSPN to function effectively without explicit positional embeddings.
Experimental Results
The model was evaluated on standard benchmarks including ImageNet-1K for classification and ImageNet 256×256 for class-conditional generation.
Performance and Efficiency
- Classification: GSPN-Tiny achieved 83.0% Top-1 accuracy on ImageNet, outperforming Swin-T (81.3%) and ConvNeXt-T (82.1%) within similar computational budgets.
- Generation: In class-conditional generation, GSPN-L/2 surpassed the state-of-the-art Diffusion Transformer (DiT) while utilizing only 65.6% of the parameters.
- Extreme Speedups: When integrated into a Stable Diffusion (SD-XL) backbone for 16K resolution generation, GSPN was over 84× faster than standard softmax attention.
- Sublinear Scaling: As resolution increases, GSPN’s inference time grows much more slowly than Transformers, enabling 16K generation on a single A100 GPU where standard models would typically exceed memory limits.
Discussion and Future Work
GSPN demonstrates that "linear is better for vision" when the architecture respects the 2D nature of images. By operating on lines rather than tokens, it achieves sub-quadratic scaling that is essential for the next generation of high-resolution visual models.
Currently, the customized CUDA kernels have room for further optimization to fully utilize GPU shared memory. Future work will explore GSPN for video tasks, where 3D spatial-temporal coherence is critical, and further refine the parallel time complexity of the line-scan process.
Summary updated