Skip to main content

Module rope

Module rope 

Source
Expand description

Rotary (RoPE) application: the mechanical pairwise rotation the abelian pathway factors into B/C. Rotary (RoPE) application helpers for the abelian rotation pathway.

Purely mechanical: given per-pair cumulative angles, rotate the paired channels of B/C. See the module header for why these angles are a state transition, not a positional encoding.

Functions§

apply_rope
Apply a rotary embedding (RoPE) to x along its last dimension.
apply_rope_partial
Apply RoPE to only the rotation-active entries of the last dimension; the remainder passes through unchanged. Falls back to apply_rope when rope_dim == state_rank (full RoPE). rope_dim must be positive — a block that rotates nothing is RotationKind::Real1D, which never reaches here.
wrap_angle
Reduce angles modulo into [−π, π], leaving the autodiff graph intact.