xT: Nested Tokenization for Larger Context in Large Images

Ritwik Gupta, Shufan Li, Tyler Zhu, Jitendra Malik, Trevor Darrell, Karttikeya Mangalam

Abstract

Modern computer vision models are often constrained by a "resolution tax," where the quadratic memory complexity of standard Transformers forces a trade-off between local detail and global context. This paper introduces xT, a framework that utilizes nested tokenization to process massive, high-resolution images (up to 29,000 x 29,000 pixels) end-to-end. By decoupling local feature extraction from global context integration using long-sequence encoders like Mamba and Transformer-XL, xT achieves state-of-the-art performance on large-scale imagery benchmarks while maintaining manageable memory requirements.

Introduction

As imaging technology advances, sensors in fields such as satellite imagery, pathology, and professional photography regularly produce images exceeding 8K resolution. However, most vision backbones remain optimized for small inputs, typically $224 \times 224$ or $384 \times 384$ pixels. To process larger images, researchers traditionally resort to two suboptimal strategies:

  1. Downsampling: Reducing the image size, which eliminates high-frequency details essential for identifying small objects.
  2. Cropping/Windowing: Partitioning the image into independent tiles, which discards the global spatial relationships necessary for understanding the scene as a whole.

The fundamental bottleneck is the quadratic scaling of self-attention in standard Transformers. Processing a 29k-pixel image directly is computationally infeasible on modern hardware. xT addresses this by introducing a hierarchical approach to tokenization and context modeling.

The xT Framework

xT is a streaming, two-stage architecture designed to bridge the gap between local precision and global awareness.

1. Nested Tokenization

Unlike standard models that apply a single layer of patchification, xT employs a nested strategy. A large input image is first subdivided into large regions. Each region is then further subdivided into standard patches. This hierarchy allows the model to organize information at multiple scales from the outset.

2. Independent Region Encoding

In the first stage, a vision backbone (such as Swin or Hiera) processes each region independently. Because these regions are processed without cross-region attention at this stage, they can be handled in batches or streamed sequentially. This significantly reduces the peak VRAM requirement, as the model only needs to hold the activations for a subset of regions at any given time. This stage focuses on extracting high-fidelity local features.

3. Context-Aware Encoding

To recover the global context lost during independent region encoding, xT utilizes a Context Encoder. The authors adapt long-sequence models from Natural Language Processing (NLP), such as Mamba, Transformer-XL, or HyperAttention. These architectures are designed to handle sequences of thousands of tokens with linear or near-linear complexity. By treating the aggregated features of each region as tokens in a sequence, the Context Encoder "stitches" the global scene together, allowing information to flow across the entire image.

4. Task-Specific Heads

The contextualized representations are finally passed to standard decoders for specific tasks, including classification, object detection, or semantic segmentation.

Experimental Evaluation

The researchers evaluated xT on datasets where large-scale spatial context is critical:

  • iNaturalist 2018 (Reptilia): A fine-grained classification task requiring both minute detail and overall body structure.
  • xView3-SAR: A maritime dataset featuring satellite images averaging 29,400 x 24,400 pixels. This dataset tests the model's ability to detect small ships in vast oceanic contexts.
  • Cityscapes: Used to evaluate the model's ability to segment large objects that span across multiple processing windows.

Key Insights

The Power of Long-Sequence NLP Models

A core innovation of xT is the application of NLP architectures to vision. Mamba and Transformer-XL, originally built for long-form text, prove highly effective at bridging the spatial gap between distant regions in a gigapixel image. This cross-pollination allows vision models to overcome the limitations of standard self-attention.

Efficiency and Scalability

xT demonstrates near-constant memory growth relative to image size. By streaming regions through the encoder, the primary bottleneck shifts from GPU memory capacity to processing time. This allows xT to scale to images 4x to 16x larger than what a standard Swin Transformer can accommodate on an 80GB A100 GPU.

Resolution vs. Parameters

A significant finding is that increasing resolution is often more impactful than increasing parameter count. The authors observed that smaller models processing high-resolution images via xT frequently outperform much larger models processing downsampled versions of the same data.

Results

  • Accuracy: xT achieved up to an 8.6% improvement in top-1 accuracy on iNaturalist compared to baseline vision transformers.
  • Segmentation: On the massive xView3-SAR images, xT saw an 11.6 point increase in F1 score. This was particularly evident in "close-to-shore" scenarios, where the model used global context (the coastline) to correctly identify ships and avoid false positives.
  • Pareto Frontier: Accuracy-parameter frontier plots indicate that xT provides a superior trade-off, reaching higher performance levels with fewer parameters than traditional scaling methods.

Limitations and Future Work

While xT offers a breakthrough in memory efficiency, the two-stage streaming process can result in lower throughput compared to simpler, non-nested models. Additionally, integrating specialized CUDA kernels (like those used in Mamba) with various vision backbones currently requires significant engineering effort. Future research may explore deeper nesting levels or dynamic "foveated" vision, where the model selectively allocates more computation to high-interest regions of a large image.

Conclusion

xT represents a significant step toward processing the high-resolution reality of modern visual data. By combining the local feature extraction of vision backbones with the long-range dependency modeling of NLP architectures, xT enables the end-to-end processing of gigapixel images that were previously impossible to fit into GPU memory.

Summary updated

BibTeX
@inproceedings{gupta2024xt,
  author = {Ritwik Gupta and Shufan Li and Tyler Zhu and Jitendra Malik and Trevor Darrell and Karttikeya Mangalam},
  title = {{xT: Nested Tokenization for Larger Context in Large Images}},
  booktitle = {International Conference on Machine Learning},
  year = {2024},
  url = {https://openreview.net/forum?id=wDDprThYeT},
}
Figure