Multi-Dimensional Rotary Embeddings for Spatio-Temporal Transformers

42 concepts35 papers1 proposal

Transformers are fundamentally permutation-invariant. When processing sequential data like text, they rely on positional encodings to understand order. However, when we extend transformers to multi-dimensional visual data—such as videos, point clouds, or medical volumes—we typically flatten these multi-dimensional tensors into a one-dimensional sequence of tokens.

Without an explicit way to preserve spatial and temporal geometry, a standard self-attention layer cannot distinguish between a pixel at the top-left of the first frame and one at the bottom-right of the final frame. As Yuqing Wang et al. demonstrate in End-to-End Video Instance Segmentation With Transformers, omitting structural coordinates causes a severe degradation in a model's ability to relate pixels across frames. To maintain structural layout and chronological order, models require explicit spatio-temporal positional embeddings, a necessity highlighted by Tianyu He et al. in Dense Interaction Learning for Video-based Person Re-identification and Fengchuang Xing et al. in StarVQA: Space-Time Attention for Video Quality Assessment.

The Limits of Absolute Coordinates

Early approaches to this problem adapted absolute positional encodings to higher dimensions. For example, Fei Xie et al. in PredFormer: Transformers Are Effective Spatial-Temporal Predictive Learners utilize absolute sinusoidal encodings for both spatial coordinates and temporal indices, providing a fixed coordinate system that prevents overfitting on smaller datasets. Similarly, A. J. Piergiovanni et al. in Rethinking Video ViTs: Sparse Video Tubes for Joint Image and Video Learning use fixed sinusoidal functions to encode the specific spatial offsets and temporal strides of irregularly sampled 3D video tubes.

While absolute encodings anchor tokens to a rigid grid, they struggle when a model encounters sequences longer or at higher resolutions than those seen during training. They lack the capacity for zero-shot extrapolation because the model has never learned to interpret coordinates outside its training boundaries.

Extending Rotary Embeddings to Higher Dimensions

To achieve flexibility in resolution and duration, researchers turned to Rotary Position Embeddings (RoPE). In its original 1D formulation for language, RoPE represents positional information by rotating pairs of features in the complex plane. The key mathematical property of RoPE is that the inner product of two rotated vectors depends only on the relative distance between their positions, rather than their absolute locations.

Video and 3D data, however, possess multiple independent axes: height ($H$), width ($W$), and time ($T$). As Xilin Wei et al. observe in VideoRoPE: What Makes for Good Video Rotary Position Embedding?, naive extensions that flatten these dimensions or fail to decouple space and time prevent the model from accurately aligning sequential tokens over long sequences.

Multi-dimensional RoPE solves this by partitioning the embedding channels. For a 3D tensor, the total channel capacity of a token is split into three distinct segments allocated to height, width, and temporal coordinates:

$$\mathbf{x} = [\mathbf{x}_h, \mathbf{x}_w, \mathbf{x}_t]$$

Each segment undergoes an independent 1D rotation based on its respective coordinate. When the dot product between a query and a key is computed in the self-attention layer, the individual rotations mathematically combine. The resulting attention weight naturally captures the relative spatial distance ($\Delta h, \Delta w$) and relative temporal distance ($\Delta t$) between tokens.

As Zhaoqing Wang et al. show in LaVin-DiT: Large Vision Diffusion Transformer, this multi-dimensional rotation preserves the structural integrity of visual data without the information loss associated with flattening. It allows models to track event progression across video sequences more effectively, a core capability evaluated by Ziyao Shangguan et al. in TOMATO: Assessing Visual Temporal Reasoning Capabilities in Multimodal Foundation Models.

The Frequency Domain Pitfall: Channel Interleaving

A major challenge in designing multi-dimensional RoPE is how frequencies are distributed across the partitioned channels. In standard RoPE, lower channel indices correspond to higher frequencies (which capture fine-grained, local relationships), while higher channel indices correspond to lower frequencies (which capture long-range context).

If we naively block-partition the channels—assigning the first third to time, the second to height, and the last to width—the temporal dimension completely dominates the high-frequency spectrum. Consequently, the spatial dimensions are relegated to low frequencies, causing the model to lose fine spatial details and produce blurry images.

To resolve this, Hangjie Yuan et al. in Lumos-1: On Autoregressive Video Generation with Discrete Diffusion from a Unified Model Perspective introduced Multimodal RoPE (MM-RoPE) with interleaved channels. Instead of contiguous blocks, the channels for time, height, and width are interleaved across the entire frequency spectrum. This ensures that spatial dimensions retain high-frequency representation, preserving visual sharpness alongside motion consistency.

Zero-Shot Extrapolation and Resolution Flexibility

Because multi-dimensional RoPE relies on bounded relative rotations rather than absolute position lookups, it grants transformers a powerful property: the ability to generalize to unseen dimensions without retraining.

Hu Yu et al. demonstrate in VideoMAR: Autoregressive Video Generation with Continuous Tokens that 3D RoPE facilitates zero-shot extrapolation to video lengths and resolutions far beyond the training distribution. Similarly, Le Zhuo et al. in Lumina-Next : Making Lumina-T2X Stronger and Faster with Next-DiT and Shoufa Chen in Goku: Flow Based Video Generative Foundation Models leverage this coordinate flexibility to process varying aspect ratios and resolutions seamlessly without specialized boundary tokens.

In video restoration, Jianyi Wang et al. use 3D RoPE in SeedVR: Seeding Infinity in Diffusion Transformer Towards Generic Video Restoration to handle edge windows that deviate from standard training dimensions, preventing resolution-related biases. Ruibin Li in Many-for-Many: Unify the Training of Multiple Video and Image Generation and Manipulation Tasks exploits this to train a single model across highly diverse content formats, while Xiang Zhang et al. in Transtreaming: Adaptive Delay-aware Transformer for Real-time Streaming Perception extend embeddings into a relative temporal space to handle varying time intervals between streaming video frames.

Unifying Modalities in a Shared Coordinate Space

The utility of multi-dimensional coordinate embeddings extends beyond standard video frames into multimodal synchronization and complex geometric spaces. When dealing with interleaved text, audio, and video, four-dimensional positional encodings can track global sequence position, temporal frame order, and spatial coordinates simultaneously.

Rowan Zellers et al. in MERLOT RESERVE: Neural Script Knowledge through Vision and Language and Sound and Xuan Ju et al. in EditVerse: Unifying Image and Video Editing and Generation with In-Context Learning use 4D RoPE to preserve structural relationships when multimodal data is flattened. This synchronization is critical for long-form generation; You Xie et al. in X-Streamer: Unified Human World Modeling with Audiovisual Interaction use 3D RoPE to lock semantic, acoustic, and visual elements to the same temporal clock.

For interactive tasks, Ye Liu et al. in UniPixel: Unified Object Referring and Segmentation for Pixel-Level Visual Reasoning combine 2D and 1D Fourier embeddings to map visual prompts (points, boxes) and temporal positions into a unified coordinate system.

Unified Spatio-Temporal Coordinate Space (3D/4D)
┌────────────────────────────────────────────────────────┐
│  Spatial (H, W) ──► 2D Fourier / RoPE Rotations        │
│  Temporal (T)   ──► 1D Fourier / RoPE Rotations        │
├────────────────────────────────────────────────────────┤
│  Aligned Applications:                                 │
│  - Point Clouds (Fan et al.)                           │
│  - Medical 3D+T (Zhang et al.)                         │
│  - Character Animation (Ding et al.)                   │
│  - Embodied Robotics (J. Zhang)                        │
└────────────────────────────────────────────────────────┘

This geometric mapping extends to physical and medical domains:

By moving from rigid, absolute grids to multi-dimensional relative rotations, transformers can natively process the complex geometries of the physical world, maintaining structural fidelity across space, time, and modalities.

Key Foundational Work

End-to-End Video Instance Segmentation With Transformers (2021) — contributed 2 concept elements to this direction.
Few-Shot Transformation of Common Actions Into Time and Space (2021) — contributed 2 concept elements to this direction.
Dense Interaction Learning for Video-based Person Re-identification (2021) — contributed 2 concept elements to this direction.
History & citationVersion 1 · 2026-10-04

Current · Permanent link

View frozen version 1

Cite this direction

Latest version (a living page):

@misc{lacuna_spatio_temporal_positional_encoding_a759bd7b,
  title = {spatio-temporal positional encoding},
  author = {{Lacuna}},
  howpublished = {Lacuna research direction},
  year = {2026},
  url = {https://lacuna.tiptreesystems.com/direction/spatio-temporal-positional-encoding/rdr_a759bd7bb30f4fa4b94b9628c6dbeccf},
  note = {Latest version of a living research direction; cite a version for a fixed text. Accessed 2026-11-26},
}

This exact version (version 1, frozen text):

@misc{lacuna_spatio_temporal_positional_encoding_a759bd7b_v1,
  title = {spatio-temporal positional encoding},
  author = {{Lacuna}},
  howpublished = {Lacuna research direction},
  year = {2026},
  url = {https://lacuna.tiptreesystems.com/direction/spatio-temporal-positional-encoding/rdr_a759bd7bb30f4fa4b94b9628c6dbeccf/v/1},
  note = {Version 1, frozen 2026-10-04. Accessed 2026-11-26},
}
About

These directions overlap with this one through shared papers.

See something wrong? Report a mistake