---
title: Universal 3D Relative Positional Encoding
url: https://www.emergentmind.com/topics/universal-3d-relative-positional-encoding-rpe
type: topic
---

# Universal 3D Relative Positional Encoding

Universal 3D Relative Positional Encoding (RPE) denotes a class of transformer positional mechanisms in which attention is conditioned on relative geometry in three-dimensional, cross-view, or cross-dimensional settings rather than on absolute positions in a single sequence or a regular grid. In this literature, the shared objective is to preserve the relative-position property of rotary or bias-based encodings while extending it to geometries such as calibrated camera systems, irregular point sets, object-centric box frames, continuous $\mathbb R^3$ coordinates, and spherical manifolds. Representative formulations include URoPE for projective cross-view reasoning, FourierLearner-Transformers for learned translation-invariant masks, RelFlexformer for integrable 3D modulation with NU-FFT, LieRE for Lie-group rotational encodings, V-DETR for query-conditioned vertex-relative biasing, and PRoPE for camera-frustum-relative attention [2604.18747], [2302.01925], [2605.10706], [2406.10322], [2308.04409], [2507.10496].

## 1. Problem setting and the meaning of “universal”

The immediate motivation for universal 3D RPE is that standard positional encodings are typically tied to a single coordinate system. Absolute encodings such as sinusoidal or learned absolute positional embeddings, and relative mechanisms such as ALiBi or standard RoPE, assume either a 1D sequence or a regular 2D or 3D grid. That assumption fails in multiview and 2D–3D tasks. A pixel in one camera may be close in 3D to a pixel in another camera but distant on the two image grids; image tokens and 3D tokens may inhabit different spaces; and single-space attention biases do not encode camera intrinsics, extrinsics, rays, or projective geometry [2604.18747].

Across the literature, “universal” does not denote a single formula. In URoPE, universality means extending RoPE across geometric spaces by lifting key tokens along camera rays and projecting them into the query image plane before applying standard 2D RoPE. In FourierLearner-Transformers, universality means that any translation-invariant RPE depending on relative displacements $r_i-r_j$ in $d$ dimensions can be parameterized through a learned spectral representation and inserted into linear attention. In RelFlexformer, universality is defined in terms of arbitrary integrable modulation functions $f \in L^1(\mathbb R^3)$ over relative displacements on irregular 3D token sets. In LieRE, universality refers to a single Lie-group construction that maps positions in $\mathbb R^d$ to high-dimensional rotations via an exponential map. In V-DETR, the relative encoding is universal in a different sense: it is query-conditioned, translation-aware, rotation-aware, and scale-aware in a canonical box frame [2302.01925], [2605.10706], [2406.10322], [2308.04409].

A recurrent source of ambiguity is the meaning of “3D.” In camera-aware work, 3D refers to scene geometry and projective relations between views. In point-cloud and molecular modeling, it refers to continuous Euclidean coordinates. In spherical encoding, it refers to geographic angles on a sphere. In long-context language modeling, “3D-RPE” refers to a Bloch-sphere-inspired rotary construction with within-chunk and across-chunk angular variables rather than Euclidean scene geometry [2310.04454], [2406.09897].

## 2. URoPE and the projective formulation of cross-view relative position

URoPE is a universal extension of Rotary Position Embedding to cross-view or cross-dimensional geometric spaces. Its central construction is explicit projective mapping from a key/value token’s source space into the query token’s space, followed by standard 2D RoPE in that shared plane. The method assumes a pinhole camera model. Each camera $j$ has intrinsics $K_j \in \mathbb R^{3\times 3}$ and extrinsics $(R_j,t_j)$ with world-to-camera mapping
$$
X_j = R_j X_w + t_j.
$$
For a key token in source camera $k$ at pixel $p_k=(u_k,v_k)$, the ray direction in key-camera coordinates is
$$
r_k = \mathrm{normalize}\!\left(K_k^{-1}[u_k,v_k,1]^T\right).
$$
URoPE samples 3D points along that ray at predefined depth anchors $\{d_i\}$,
$$
X_{k,i} = d_i r_k,
$$
moves them into world coordinates and then into query-camera coordinates,
$$
X_{w,i} = R_k^{-1}(X_{k,i}-t_k), \qquad X_{q,i} = R_q X_{w,i} + t_q,
$$
and projects them into the query image plane,
$$
[\tilde u_{q,i},\tilde v_{q,i},w_{q,i}]^T \sim K_q X_{q,i}, \qquad
\hat p_{q,i} = \left(\frac{\tilde u_{q,i}}{w_{q,i}}, \frac{\tilde v_{q,i}}{w_{q,i}}\right).
$$
The projected point $\hat p_{q,i}$ is then used in place of the original key coordinate when applying 2D RoPE [2604.18747].

The RoPE component follows the standard 2D decomposition. For image coordinates $p=(x,y)$, the per-head channels are partitioned into $x$ and $y$ subspaces, and
$$
R_{2D}(p)=\mathrm{diag}\!\big(R_x(\theta_x(p.x)),R_y(\theta_y(p.y))\big).
$$
For a query pixel $p_q$ and a projected key pixel $\hat p_{q,h}(p_k)$ associated with head $h$ and depth anchor $d_h$,
$$
q_h^T R_{2D}(p_q)^T R_{2D}(\hat p_{q,h}(p_k))k_h
=
q_h^T R_{2D}(p_q-\hat p_{q,h}(p_k))k_h.
$$
This preserves the relative-position effect of RoPE, but now the relative quantity is projective and cross-view. Multi-head attention implements multi-depth reasoning by assigning different anchors to different heads or head-groups, so near- and far-field hypotheses along the epipolar line are covered without a learned per-layer depth estimator [2604.18747].

The depth-anchor design is deliberately simple. Uniform spacing in $[d_{\min},d_{\max}]$ works well and is robust to upper-bound choices; log-uniform or LID sampling yield similar performance; and a small number of anchors is typical. The reported guidance is that $D=4$ works well across tasks, $2$–$8$ is typically robust, $D=1$ degrades performance, and very many anchors offer diminishing returns [2604.18747].

## 3. Formal properties, computational profile, and implementation constraints

URoPE is explicitly intrinsics-aware because projected positions depend on $K_q$, $K_k$, and the extrinsics. It is parameter-free because depth anchors are fixed. It is also invariant to the global coordinate frame. Eliminating world coordinates yields the relative transform
$$
R_{qk}=R_qR_k^{-1}, \qquad
t_{qk}=t_q-R_qR_k^{-1}t_k,
$$
so that
$$
X_q = R_{qk}X_k + t_{qk}.
$$
Under a global $SE(3)$ change of the world frame, $R_k$, $R_q$, $t_k$, and $t_q$ change consistently, but $R_{qk}$ and $t_{qk}$ remain unchanged. Therefore
$$
\hat p_{q,h}=\Pi\!\big(K_q(R_{qk}X_k+t_{qk})\big)
$$
is unchanged, which establishes invariance to global rigid-frame reparameterization [2604.18747].

A further design constraint is compatibility with existing attention kernels. URoPE leaves the attention kernel unchanged and applies standard RoPE on rotated $Q$ and $K$, so it remains compatible with RoPE-optimized kernels, including FlashAttention. Its asymptotic attention complexity remains
$$
O(BHL^2C),
$$
the same as standard attention, while the additional cost of computing per-head projected positions is
$$
O(BLH)
$$
arithmetic. Batched multiview attention is handled by reshaping queries so that all queries in one kernel call share a single view and repeating keys and values along the batch dimension as needed [2604.18747].

The implementation notes are highly geometric. The pinhole model is assumed and distortion is not modeled. Extremely small $z$ values in query-camera coordinates require clipping or guards against numerical instability. Projected positions may fall outside the image plane; URoPE remains valid in that case because 2D RoPE still computes a relative angle, though clamping or coordinate normalization may stabilize angles. For stability across resolutions, the recommended practice is to scale $x$ by image width $W$ and $y$ by image height $H$ before mapping to RoPE angles, using $\bar x=x/W$ and $\bar y=y/H$. Head-wise anchor assignment is markedly better than channel-wise splitting, and learned per-layer depth prediction underperforms fixed anchors, especially in shallow layers [2604.18747].

The same formalism is used beyond view-to-view cross-attention. The paper states that URoPE can be integrated into 2D–3D fusion by measuring relative positions between 3D queries and lifted points in 3D or by projecting 3D queries into each image and applying 2D RoPE. It also applies across temporal sequences using per-frame intrinsics and extrinsics, and it degenerates to standard 2D RoPE when query and key belong to the same view [2604.18747].

## 4. Empirical performance of URoPE across geometric tasks

URoPE was evaluated as a plug-in positional encoding across novel view synthesis, 3D object detection, object tracking, and stereo depth estimation, covering 2D–2D, 2D–3D, and temporal scenarios. The reported pattern is consistent improvement over transformer baselines in all tasks considered [2604.18747].

In novel view synthesis integrated into LVSM, URoPE improved Objaverse to PSNR $25.09$, SSIM $0.900$, and LPIPS $0.165$, outperforming Plücker rays at $22.28/0.856/0.279$, 6D RoPE at $24.42/0.891/0.191$, P-RoPE at $24.88/0.896/0.176$, and RayRoPE at $24.96/0.897/0.175$. On RealEstate10k, it reached PSNR $26.02$, SSIM $0.827$, and LPIPS $0.080$, exceeding Plücker rays at $23.95/0.764/0.118$, 6D RoPE at $25.73/0.819/0.086$, P-RoPE at $25.28/0.806/0.092$, and RayRoPE at $24.94/0.799/0.097$. Under scaled training at approximately $50\times$ compute, URoPE still improved over Plücker rays, with PSNR $29.24$ versus $28.66$, SSIM $0.897$ versus $0.889$, and LPIPS $0.104$ versus $0.113$ [2604.18747].

In nuScenes 3D detection and tracking, PETR with URoPE achieved NDS $37.3$, mAP $32.2$, and AMOTA $0.255$, improving baseline PETR at $34.9$, $30.9$, and $0.222$. StreamPETR with URoPE reached NDS $50.6$, mAP $41.1$, and AMOTA $0.380$, improving the baseline at $47.6$, $37.5$, and $0.335$. The qualitative description reports better identification of small objects and improved temporal consistency [2604.18747].

In stereo depth estimation with UniMatch, URoPE yielded on RGBD an AbsRel of $0.103$, RMSE of $0.571$, and RMSE log of $0.181$; on Scenes11 an AbsRel of $0.049$, RMSE of $0.450$, and RMSE log of $0.104$; and on SUN3D an AbsRel of $0.112$, RMSE of $0.329$, and RMSE log of $0.148$. The associated ablations report that URoPE alone suffices, combining it with global Plücker rays gives little gain, local camera-ray direction gives only small improvements, and head-entropy analysis shows no multi-head collapse relative to P-RoPE [2604.18747].

These results are accompanied by practical ablation findings. Uniform and LID sampling are both strong, log-uniform is competitive, sensitivity to the upper depth bound is low provided near-field coverage is included, and $D=4$ is the empirical sweet spot. The paper also reports that fixed anchors are more stable than parametric depth prediction modules [2604.18747].

## 5. Comparative landscape of universal 3D RPE formulations

Universal 3D RPE is not a single architecture family. The following formulations instantiate different notions of relative geometry:

| Formulation | Core mechanism | Distinguishing scope |
|---|---|---|
| FourierLearner-Transformers [2302.01925] | Learned spectral representation of $f(r_i-r_j)$ with random Fourier features | Linear attention with translation-invariant RPE on continuous coordinates |
| V-DETR 3DV-RPE [2308.04409] | Query-conditioned additive bias from canonical offsets to box vertices | Locality-conforming 3D detection in an object-centric frame |
| RelFlexformer [2605.10706] | Integrable modulation $f:\mathbb R^3\to\mathbb R$ applied by NU-FFT | Subquadratic masked attention on irregular 3D token layouts |
| PRoPE [2507.10496] | Projective frustum transform $\tilde P_i\tilde P_j^{-1}$ in attention | Relative multiview conditioning with intrinsics and extrinsics |
| LieRE [2406.10322] | High-dimensional rotation $R(p)=\exp(Ap)$ | Modality-agnostic rotary encoding for positions in $\mathbb R^d$ |
| Spherical PE / 3D-RPE [2310.04454], [2406.09897] | Geographic $3\times 3$ rotations / Bloch-sphere chunk rotary | Spherical geotokens or long-context sequence modeling |

FourierLearner-Transformers formulate RPE as a translation-invariant mask $M_{ij}=f(r_i-r_j)$ and learn its Fourier transform $g(\xi)$. The mask is estimated by spectral random features and absorbed into linearized softmax attention via augmented query and key features. For 3D molecular modeling on OC20 IS2RE, FLT-12L improved Performer-12L from energy MAE $0.5454$ eV and EwT $4.90\%$ to MAE $0.5046$ eV and EwT $5.33\%$; FLT-10L reached MAE $0.5157$ eV and EwT $5.44\%$ [2302.01925].

V-DETR’s 3D Vertex Relative Position Encoding uses the predicted box of each decoder query to define a canonical frame. The key quantity is the vertex offset
$$
\Delta P_{i,m,j}=R_i^T(x_j-v_{i,m})\odot s_i^{-1},
$$
which is processed by per-vertex MLPs and summed into an additive attention bias, yielding
$$
\hat A = \mathrm{Softmax}(QK^T + R).
$$
This encoding is translation-invariant, rotation-aware, and scale-aware. On ScanNetV2, it improved 3DETR from $\mathrm{AP}_{25}/\mathrm{AP}_{50}=65.0\%/47.0\%$ to $77.8\%/66.0\%$, and on SUN RGB-D it reached up to $68.0\%/51.1\%$ [2308.04409].

RelFlexformer instead works at the level of arbitrary integrable modulation functions. With tokens at coordinates $r_i\in\mathbb R^3$ and $M_{ij}=f(r_i-r_j)$, it computes masked multiplication through a forward NU-FFT, multiplication by the spectral envelope $\hat f(\omega)$, and an adjoint NU-FFT. This yields $O(L\log L)$ time for the masked step without materializing the $L\times L$ mask. The paper reports improvements over Performer on ModelNet40, ScanObjectNN, ScanNet, ScanNet200, ScanNet++, nuScenes, S3DIS, NYU Depth v2, and SUN RGB-D, and notes that small spectral quadrature sizes such as $S=8$–$16$ are often sufficient [2605.10706].

PRoPE, introduced in the multiview camera-conditioning literature, represents each camera by
$$
\tilde P_i = \begin{bmatrix}K_i & 0 \\ 0 & 1\end{bmatrix}T_i
$$
and injects the pairwise transform $\tilde P_i\tilde P_j^{-1}$ into attention. This explicitly captures both intrinsics and extrinsics as a relative projective transform. On RealEstate10K with varying intrinsics, PRoPE achieved $21.42/0.247/0.678$ in PSNR/LPIPS/SSIM, compared with GTA at $15.77/0.512/0.641$, CaPE at $15.94/0.497/0.699$, Plücker at $19.89/0.327/0.608$, and Naive at $20.56/0.301/0.629$. In hybrid form, PRoPE+CamRay reached $21.78/0.211/0.692$ [2507.10496].

LieRE generalizes RoPE by replacing fixed block-diagonal $2\times 2$ rotations with $R_{\mathrm{LieRE}}=\exp(Ax)$, where $A:\mathbb R^d\to \mathrm{Skew}_m(\mathbb R)$ is learned. For 3D tasks, the construction uses positions $p=(x,y,z)$ and the generator $xA_x+yA_y+zA_z$. On UCF101, LieRE improved Absolute from $44.4$ and RoPE-Mixed from $48.6$ to $51.1$ accuracy; on RSNA it improved Absolute from $80.7$ and RoPE-Mixed from $81.9$ to $82.7$ [2406.10322].

Spherical Position Encoding and 3D-RPE illustrate a different branch of the literature. The former replaces 2D rotary blocks with repeated $3\times 3$ rotations $R_{\mathrm{sph}}(\phi,\theta)=R_z(\theta)R_x(\phi)$ built from longitude and latitude, targeting “geotokens” on the sphere; the paper is conceptual and reports no experiments. The latter introduces a Bloch-sphere-inspired construction for long-context language models in which the score depends on within-chunk offset $(m-n)$ and chunk-level phase difference $(\varphi_i-\varphi_j)$; it reports improvements over RoPE on LongBench, LEval, PG19, and Proof-Pile [2310.04454], [2406.09897].

## 6. Limitations, ambiguities, and open technical directions

Camera-aware universal 3D RPE methods inherit calibration requirements. URoPE requires calibrated intrinsics and extrinsics and is not directly applicable to uncalibrated settings without camera estimation. Its performance can degrade under depth-range mis-specification, extreme perspective changes, or very wide baselines, which may require more anchors or broader anchor ranges. Numerical issues arise for tiny $z$ values or points behind the camera, and large images or many anchors increase the per-head projection arithmetic even though the attention kernel itself remains standard [2604.18747].

PRoPE shares similar dependencies on camera quality. Calibration errors in $K$, $R$, and $t$ corrupt the projective transform; very small parallax reduces geometric signal; and the formulation assumes a pinhole model unless inputs are pre-undistorted or the distortion model is explicitly incorporated [2507.10496]. V-DETR exhibits a different failure mode: if the provisional box prediction is poor in early decoder layers, the resulting query-conditioned bias may misguide attention, although iterative refinement and auxiliary losses mitigate this [2308.04409].

Spectral and Fourier-based approaches trade geometric specificity for broader applicability. FLT depends on the choice of sampling distribution $p(\xi)$; poor choices increase variance and may require larger numbers of spectral features. Very sharp local masks are band-unlimited and must be approximated with finite bandwidth. RelFlexformer presumes translation-invariant masks and introduces quadrature and NU-FFT approximation error; extreme token sparsity or highly clustered distributions may require retuning the quadrature size $S$ or kernel widths [2302.01925], [2605.10706].

LieRE is universal over positions in $\mathbb R^d$, but the paper states that it does not directly encode $SE(3)$ poses. Spherical Position Encoding leaves scaling for distance proportionality unspecified and does not include altitude or empirical validation. The long-context 3D-RPE construction depends on chunk size and base schedules; too-small chunk size can overly restrict locality, while too-large chunk size reintroduces RoPE-like long-range decay in the within-chunk component [2406.10322], [2310.04454], [2406.09897].

Taken together, the literature indicates that “universal” is best understood as geometry-appropriate relative encoding rather than as a single canonical 3D recipe. Projective methods such as URoPE and PRoPE are matched to calibrated multiview vision; object-centric encodings such as 3DV-RPE are matched to detection; spectral and NU-FFT methods are matched to irregular continuous 3D token sets; and Lie-group or spherical rotary methods generalize the rotational principle underlying RoPE to broader positional domains.

Source: https://www.emergentmind.com/topics/universal-3d-relative-positional-encoding-rpe