REOrdering Patches Improves Vision Models

Declan Kutscher, David M. Chan, Yutong Bai, Trevor Darrell, Ritwik Gupta

Introduction

In computer vision, the standard approach to processing images with transformers involves partitioning the image into a grid of patches and flattening them into a 1D sequence. Traditionally, this flattening follows a "raster scan" or row-major order. While the original Vision Transformer (ViT) is permutation-equivariant—meaning it treats patches as a "bag of words" regardless of sequence—modern "long-sequence" architectures like Mamba, Longformer, and Transformer-XL break this symmetry. These models process information linearly or within local windows, making the specific order of patches a critical, yet often overlooked, hyperparameter.

The Challenge of 1D Flattening

The arbitrary choice of row-major ordering can hinder the performance of models that rely on recurrence or local context. To address this, the authors introduce REOrder, a framework designed to discover optimal patch sequences using reinforcement learning.

Various 1D scanning patterns used to flatten 2D images into sequences.

The REOrder Framework

REOrder employs a two-stage optimization process:

  1. Information-Theoretic Initialization: The search begins by evaluating fixed orderings (e.g., Hilbert, Spiral, Diagonal) based on their "compressibility" using LZMA. Lower local redundancy often provides a superior starting point for learning.
  2. Learning the Permutation Policy: The problem is framed as "learning to rank." Using a Plackett-Luce model to represent the probability distribution over permutations, the authors apply the REINFORCE algorithm to maximize classification accuracy. Given the astronomical search space ($196!$ for a standard grid), this RL approach efficiently explores the search space.

Experimental Results

The framework was tested on ImageNet-1K and the Functional Map of the World (FMoW) satellite dataset.

Performance delta from row-major ordering across different architectures on ImageNet-1K and FMoW.

Key Findings

  • Significant Accuracy Boosts: On ImageNet-1K, REOrder improved Mamba's top-1 accuracy by 3.01% over the standard row-major scan. The gains were even more pronounced on satellite imagery (FMoW), reaching a 13.35% improvement.
  • Architecture-Specific Preferences: Different models exhibit distinct "reading" styles. Mamba performs best when salient patches are "front-loaded" early in the sequence to establish a strong internal state. Conversely, Transformer-XL and Longformer prefer "back-loading" important information to leverage accumulated context.
  • ViT Invariance: As expected, the standard ViT showed negligible performance changes across different orderings, confirming that the "order problem" is specific to modern, efficient architectures that lack full self-attention.

Conclusion and Future Directions

The REOrder framework demonstrates that the 1D structure of visual inputs is a vital component of model design for long-sequence architectures. Future work aims to develop Dynamic Image Policies, where the model adaptively determines the optimal reading order for each individual image rather than applying a fixed global ordering for the entire dataset. This could further unlock the potential of high-resolution "gigapixel" AI processing.

Summary updated

BibTeX
@inproceedings{kutscher2025reordering,
  author = {Declan Kutscher and David M. Chan and Yutong Bai and Trevor Darrell and Ritwik Gupta},
  title = {{REOrdering Patches Improves Vision Models}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2025},
  url = {https://openreview.net/forum?id=g56WiaXKGF},
}
Figure