Expand description
Rotary Position Embedding (RoPE) kernel.
Matches rope-kernel-v1.yaml.
Rotate pairs of dimensions by position-dependent angles.
theta_k = base^(-2k/d), apply 2D rotation matrix per pair.
RoPE(x, m){2k} = x{2k} * cos(m * theta_k) - x_{2k+1} * sin(m * theta_k) RoPE(x, m){2k+1} = x{2k} * sin(m * theta_k) + x_{2k+1} * cos(m * theta_k)
Each function provides one of three backends:
fn rope_scalar(...)— Pure Rust scalar reference (ground truth)unsafe fn rope_avx2(...)— AVX2 SIMD implementationfn rope_ptx() -> &'static str— PTX assembly source string
Functions§
- rope_
avx2 ⚠ - AVX2 RoPE — delegates to scalar (no hardware
sin/cosin AVX2). - rope_
ptx - PTX assembly for the RoPE kernel (1 thread per dimension pair).
- rope_
scalar - Apply Rotary Position Embedding to input vector
x.