TL;DR
Vision Transformers usually borrow their sense of space from 1D language models—like trying to navigate a 3D sculpture using only a ruler. This paper introduces Parabolic Positional Encoding (PaPE), a vision-first positional encoding built from geometric first principles using simple, learnable parabolas. Not only does it work across images, videos, point clouds, and event cameras, it allows models trained on tiny $224 \times 224$ images to effortlessly analyze $1024 \times 1024$ images without breaking a sweat—or needing FlashAttention workarounds.
What Problem Does This Paper Address?
By default, the Transformer's attention mechanism is "permutation invariant"—if you scramble the patches of an image, it sees the exact same bag of tokens. To fix this, we inject positional encodings.
Historically, computer vision has retrofitted positional encodings originally designed for 1D text sequences (like sinusoidal embeddings, RoPE, or ALiBi) into 2D or 3D grids. While clever, these adaptations miss the full picture of how visual space actually works. Unlike text, which marches strictly left-to-right, visual worlds are multi-dimensional, directional (diagonal, up, down), translation-invariant (a cat is a cat anywhere in the frame), and require balancing tight local details with sweeping global context.
Furthermore, traditional attention biases that do capture spatial distances often require computing the massive, full pairwise attention matrix, disqualifying them from fast, memory-saving hardware kernels like FlashAttention. The authors ask: What if we designed a positional encoding specifically for vision from the ground up, without sacrificing modern hardware efficiency?
Methods
The authors distill five desirable principles for vision: translation invariance, distance decay (closer things matter more), directionality, context awareness (adapting spatial focus based on what the token is), and optionally rotation invariance.
Enter PaPE. Instead of rotating vectors with sine waves like RoPE, PaPE reshapes the attention score between two tokens into a sum of $m$ downward-opening parabolas: $y = ax^2 + bx + c$.
Here is how the high-school algebra maps onto visual intuition:
- $c$ (Semantics): The standard query-key dot product $\langle q_i, k_j \rangle$.
- $x$ (Relative Position): The projected spatial offset $\Delta r_{ij}$ between two tokens, ensuring translation invariance.
- $ax^2$ (Distance Decay): Because $a_i$ is forced to be negative, attention naturally rolls off as distance increases—creating a smooth parabolic hill.
- $bx$ (Directionality): A linear dot product that shifts the peak of the parabola, allowing an attention head to "look" in a specific direction (e.g., bottom-right).
- Context Awareness: Both $a_i$ and $b_i$ are predicted dynamically from the query token's own features. If a token needs global context, it can drive $a_i \to 0$ and $b_i \to 0$, flattening the parabola completely!
The authors also introduce PaPE-RI, a rotation-invariant version achieved by zeroing out the directional $b$ term and constraining the spatial projection.
The Magic Trick for Speed: Normally, computing $\Delta r_{ij}^2$ requires knowing every pair of positions simultaneously, breaking FlashAttention. By algebraically expanding the square $(r_j - r_i)^2 = r_j^2 - 2r_i r_j + r_i^2$, the authors factorize PaPE into independent query and key vector concatenations. It only adds $p^2 + 2p + 2$ extra dimensions per head (just 10 numbers for 2D images!), making it 100% plug-and-play with FlashAttention.
Datasets
No new benchmarks were introduced; instead, the authors tested generality across 8 existing datasets spanning 4 modalities:
- Images: ImageNet-1K (classification) and MS-COCO (2D object detection), plus OOD variants ImageNetV2, ImageNet-Renditions, and ObjectNet.
- Spatio-temporal (Video & Event Cameras): UCF101 (video action recognition), DvsGesture (sparse event-stream action recognition), and GEN1 (automotive event-camera object detection).
- 3D Point Clouds: ScanNet (indoor semantic segmentation) and ModelNet40 (3D object classification).
- Multimodal: nuScenes (combining 2D cameras + 3D LiDAR for autonomous driving).
Key Insights and Ideas
- Attention cleanly decomposes: PaPE naturally splits attention into three interpretable maps: distance, direction, and semantics. You can literally visualize an attention head choosing to look "nearby and to the bottom-right" when querying a dog's eye.
- Context + Decay = Extrapolation Superpowers: Ablations reveal that forcing the $a$ coefficient to be negative (concave distance decay) combined with dynamic token-dependent predictions is what allows models to scale seamlessly to massive, unseen image resolutions.
- When not to be translation invariant: PaPE trailed sinusoidal encodings on only one dataset: ScanNet. Why? Indoor rooms have real-world scale—floors are at $z=0$, tables sit ~1 meter high. Purely relative encodings throw away absolute coordinates, losing a massive semantic clue!
- Strict rotation invariance can hurt: Surprisingly, PaPE-RI underperformed standard PaPE even on 3D point clouds, suggesting that trading away directional flexibility costs more than strict rotational symmetry buys—except in complex multimodal setups like nuScenes, where PaPE-RI took first place.
Key Results
- Zero-Shot Resolution Extrapolation: Trained on ImageNet-1K at $224^2$ and tested straight up to $1024^2$ (~20x more pixels) without fine-tuning or interpolation, PaPE hits 74.9% accuracy—crushing the next-best baseline (LookHere at 64.4%) by 10.5 percentage points, while standard RoPE drops to 42.3% and sinusoidal collapses to 9.3%.
- Broad Generality: Across the 8-dataset gauntlet, PaPE achieves the highest overall average score (66.3 vs. RoPE's 65.3), matching the top baseline on 5 datasets and beating everything on 2.
- Fast-Moving Spatio-Temporal Gains: PaPE shines brightest when things move fast, jumping to 49.5% on UCF101 video recognition compared to RoPE's 43.9%, and beating RoPE by 1.2 mAP on GEN1 event streams.
Limitations and Future Work
PaPE's main drawback is a moderate compute and memory overhead driven by the learned projections ($W_a, W_b, W_p$) and the number of parabolas ($m=50$). However, ablations show that dropping $W_p$ or lowering $m$ to 8 trims nearly all the fat with negligible accuracy loss. Looking ahead, the authors aim to write custom fused GPU kernels for PaPE and explore using its lightweight spatial parameters for parameter-efficient fine-tuning (PEFT).
Summary updated