Manuscript Offprint

arXiv:2610.10154

HySPE: Positional Encoding via Symplectic Dual Shears

Zhongping Ji

Abstract

We introduce Hyperbolic Symplectic Positional Encoding (HySPE), grounding positional attention in non-compact symplectic transformations. While canonical Rotary Position Embedding (RoPE) parameterizes the compact, elliptic branch of Sp(2, R\mathbb{R}) via rotations, HySPE operationalizes its hyperbolic branch via a damped symmetric composition of dual shears, yielding a conformally symplectic contraction with two spectral decay rates per channel pair. To eliminate the exponential representation drift inherent to naive absolute factorizations, we diagonalize the operator in its invariant eigenbasis and introduce blockwise coordinate rebasing with adaptive centered execution. This guarantees length-independent numerical bounds while matching cached RoPE forward latency (7.21 ms on an RTX 4090). On TinyShakespeare, HySPE-UltraLong maintains an invariant perplexity of 4.810 up to 16× zero-shot extrapolation (L = 4096), whereas RoPE degrades to 131.198. Scaled to a 51M-parameter subword Transformer on WikiText-103 ( Ltrain=512L_{train} = 512), HySPE closely matches RoPE in-domain while robustly extrapolating to length 8192, reducing tail perplexity by 83.9% over RoPE. While these controlled experiments establish HySPE’s extrapolation robustness and numerical stability, evaluating its scaling behavior on large-scale foundation models remains an important direction for future investigation.

1 Introduction

Positional encodings dictate how self-attention mechanisms in Transformers [1] represent relative token displacements. Rotary Position Embedding (RoPE) [2] establishes relative-position dependence through pairwise orthogonal rotations of query and key projections. In two dimensions, these rotations correspond to the elliptic subgroup of the real symplectic group Sp(2,R)≅SL(2,R)\text{Sp}(2, \mathbb{R}) \cong \text{SL}(2, \mathbb{R}). While volume-preserving and isometric, elliptic orbits are bounded and non-dissipative; consequently, extending sequence length beyond the pretraining horizon exposes unobserved phase domains, precipitating phase aliasing and attention entropy collapse [3, 4].

In this work, we propose Hyperbolic Symplectic Positional Encoding (HySPE), exploring the complementary hyperbolic branch of Sp(2, R\mathbb{R}). Motivated by dissipative dynamical systems and hyperbolic geometric flows [5, 6], HySPE constructs relative position operators via symmetric dual shears. The composition of two transverse elementary shears generates a symmetric hyperbolic operator with reciprocal positive real eigenvalues. When modulated by an exponential decay envelope, the relative attention kernel becomes contractive and conformally symplectic, satisfying TΔ⊤JTΔ=e−2γΔJT_{\Delta}^{\top} J T_{\Delta} = e^{-2\gamma \Delta} J for the standard symplectic form JJ. This endows each channel pair with two distinct spectral attenuation rates, providing anisotropic distance filtering directly within the representation space.

Crucially, we uncover and resolve a fundamental tension between the continuum algebraic kernel and its finite-precision realization. Although the relative operator TΔT_{\Delta} is strictly bounded, expressing it via separated absolute query and key matrices forces the key operator to diverge exponentially as e(2χ+δ)ne^{(2\chi+\delta)n}, causing severe numerical overflow in float precision and corrupting KV-cache representation scales.

We overcome this representation divergence without modifying the mathematical kernel. By diagonalizing the dual-shear operator into its invariant eigenbasis, we factorize the bilinear interaction into decoupled decay modes and introduce spectral block rebasing. This local gauge transformation anchors intermediate scales to query-block origins, bounding maximum positive exponents to small constants regardless of sequence length. To eliminate kernel dispatch overhead, we design an adaptive centered blocking scheme that executes long-sequence attention in few kernel calls.

Across rigorous, multi-seed experiments on a byte-level Transformer trained on TinyShakespeare at length 256, HySPE achieves marked in-domain perplexity gains and zero-shot extrapolation up to 4096 tokens (16× extension) with zero quality degradation. Identical-checkpoint interventions verify that the stable spectral formulation completely recovers the predictive capacity lost to floating-point truncation in naive factorization. Furthermore, optimized HySPE forward latency reaches 7.21 ms at length 4096, matching cached RoPE (7.20 ms) on an RTX 4090. HySPE demonstrates that hyperbolic symplectic geometry provides an expressive, numerically robust alternative to canonical rotations for foundation sequence models.