ClikaRT::ops::mrope_rotary_embedding_qk_varlen
function
mrope_rotary_embedding_qk_varlen()
std::array<Tensor 2> mrope_rotary_embedding_qk_varlen(
Tensor q,
Tensor k,
Tensor position_ids,
ClikaRT::Span<const std::int64_t> mrope_sections,
std::optional<bool> interleaved_sections = std::nullopt,
std::optional<double> theta = std::nullopt,
std::optional<RopeScaling> scaling = std::nullopt,
std::optional<RotaryMode> mode = std::nullopt,
std::optional<int64_t> rotary_dim = std::nullopt,
std::optional<double> scale = std::nullopt
)
Multi-axis RoPE over a packed q/k pair: ONE per-token angle table serves both projections in a single call, the media-prefill pre-rotation shape. q/k are head-exposed [n_tokens, heads, head_dim] (a flat [n_tokens, heads·head_dim] projection reshapes to it as a free view; the rotation spans the TRAILING dim, so a flat row would rotate across head boundaries); position_ids is [n_axes, n_tokens] with n_axes == mrope_sections.size() (strip any trailing zero sections a checkpoint's metadata pads; the axis count follows the section list); rotary_dim bounds the rotated span (dims beyond it pass through) and defaults to the trailing dim. Rows whose per-axis positions are all EQUAL rotate exactly as the plain ops do; serve pure-text calls through rotary_embedding* (cheaper: no per-token table), and use this form for packs whose rows carry genuinely multi-axis positions, then attend with the rope inputs ABSENT so the attention op consumes (and appends) q/k exactly as given.
Returns: a 2-element array {q, k}.
Declared in ClikaRT/compute/ops.h, line 2166