Last updated: 2026-06-12

Inference Runtime

Rope

All API Sections

T-CPU RoPE (Rotary Positional Embedding) implementation.

Applies in-place rotary embeddings to query or key head data.

2 exports shown

struct

Params

#
pub const Params = struct

Inputs for one in-place RoPE pass over a Q or K tensor.

Parameters

data
Mutable head-major buffer; head `h` lives at `data[h * stride ..][0..rope_dim]`.
stride
Distance in floats between successive heads in `data`.
rope_dim
Number of contiguous dimensions per head touched by RoPE (must be even).
n_heads
Number of heads to rotate.
position
Absolute token position used to compute the rotation angle.
inv_freq
Inverse frequencies of length `rope_dim / 2`; missing entries default to zero (no rotation).

src/zinc_rt/isa/cpu_zig/rope.zig:13

function

run

#
pub fn run(params: Params) !void

Apply rotary positional embeddings in place to every head in `params.data`.

For each head and each frequency pair `(a, b) = (data[i], data[i + rope_dim/2])`, rotates by `theta = position * inv_freq[i]`: writes `(a*cos - b*sin, a*sin + b*cos)`. Uses the half-rotation layout (NeoX-style), matching the Vulkan kernels.

Parameters

params
Buffer, stride, rope dim, head count, position, and `inv_freq` table; see `Params`.

Returns

`error.EmptyInput` when `data` is zero-length, otherwise void.

src/zinc_rt/isa/cpu_zig/rope.zig:28