In the standard Vision Transformer (ViT) recipe, spatial information is injected via absolute positional encodings—fixed or learnable vectors added to patch embeddings. While effective for fixed-resolution tasks, this approach creates a "resolution trap." When a model trained on $224 \times 224$ images is asked to process a $1024 \times 1024$ image, the positional coordinates become out-of-distribution, and naive interpolation often leads to a significant drop in performance.
A growing body of research suggests that the solution lies in moving away from rigid pixel-based coordinates toward encodings that are aware of scale, physical dimensions, and relative geometry.
The Failure of Absolute Interpolation
The most common way to handle varying resolutions is to interpolate the positional embedding grid to match the new input size. However, Daniel Bolya and Judy Hoffman identified a fundamental flaw in this practice, particularly for models using window-based attention. In Window Attention is Bugged: How not to Interpolate Position Embeddings, they demonstrate that interpolating absolute embeddings shifts the local coordinate system within each window, breaking the spatial alignment the model relies on.
Their solution, Absolute Win, decomposes position information into two parts: a tiled window-level component that stays constant regardless of resolution, and a global-level component that is interpolated. This ensures that the local "view" within an attention window remains consistent, even as the global context expands.
Grounding Space in Physical Dimensions
In domains like Earth Observation, "scale" isn't just a pixel count—it's a physical reality. A $10 \times 10$ pixel patch might represent 10 meters or 100 meters depending on the satellite sensor. Colorado J. Reed and colleagues addressed this in Scale-MAE by incorporating Ground Sample Distance (GSD) directly into the positional encodings.
By scaling the frequency of sinusoidal encodings based on the physical distance each pixel represents, the model learns to interpret visual features relative to their real-world size. This allows a single model to maintain a consistent understanding of objects (like buildings or ships) across sensors with vastly different spatial resolutions. This concept is pushed to its logical conclusion in AnySat, which defines input patches by physical meters rather than pixel counts, treating resolution as a sampling density variation rather than a structural change.
From Absolute Coordinates to Relative Geometry
Another powerful strategy for scale invariance is the shift from absolute to relative positional embeddings. In tasks like stereo matching and optical flow, the absolute position of a pixel is less important than its distance from its neighbors. Philippe Weinzaepfel demonstrates in CroCo v2 that using Rotary Positional Embeddings (RoPE) allows models to generalize to unseen resolutions and aspect ratios by focusing on the relative rotation of feature vectors in a latent space.
Similarly, the Win-Win training strategy by Jérôme Revaud and Thomas Lucas leverages relative embeddings to train high-resolution ViTs using only small random windows. Because the model learns spatial relationships based on the distance between patches rather than a fixed grid, it can seamlessly process full-resolution images at inference time without the artifacts typically introduced by tiling or resizing.
Content-Aware and Isotropic Encodings
Beyond simple geometry, some researchers argue that positional signals should be tied to the image content itself. In StyTr$^2$: Unbiased Image Style Transfer with Transformers, Yingying Deng and Fan Tang introduce Content-Aware Positional Encoding (CAPE). Instead of a fixed grid, CAPE learns representations based on the semantic features of the input, ensuring that spatial relationships remain consistent even when the image is heavily stylized or resized.
To further eliminate directional biases that plague standard Cartesian grids, Chengxi Min and Yao Zhao proposed Compass-RoPE in Compass-RoPE: Isotropic Rotary Position Embeddings for Vision Transformers. By switching to polar coordinates and using Fourier mixing, they create isotropic embeddings that allow models to handle images much larger than those seen during training without losing spatial coherence.
Why It Works: The Intuition of Invariance
The common thread across these works is the move toward spatial inductive bias. Standard transformers are permutation-invariant; they have no inherent sense of "up" or "left" without positional encodings. By making these encodings scale-aware, we are teaching the model that:
- Local structure is scale-invariant: A corner is a corner, whether it's 5 pixels wide or 50.
- Global context is relative: The relationship between the "sky" and the "ground" depends on their relative orientation, not their absolute pixel indices.
- Physical scale is a feature: Knowing the real-world size of a patch helps resolve ambiguities in texture and object identity.
By grounding spatial information in these invariant properties, researchers are building vision models that are no longer tethered to the specific resolutions of their training sets.