Skip to main content

//clika-runtime/io.clika.runtime/Ops/mropeRotaryEmbeddingQkVarlen

mropeRotaryEmbeddingQkVarlen

[common]
fun mropeRotaryEmbeddingQkVarlen(query: Tensor, key: Tensor, positionIds: Tensor, mropeSections: LongArray, interleavedSections: Boolean? = null, theta: Double? = null, scaling: RopeScaling? = null, mode: RotaryMode? = null, rotaryDim: Long? = null, scale: Double? = null): List<Tensor>

mropeRotaryEmbeddingQkVarlen(query: Tensor, key: Tensor, positionIds: Tensor, mropeSections: LongArray, interleavedSections: Boolean? = null, theta: Double? = null, scaling: RopeScaling? = null, mode: RotaryMode? = null, rotaryDim: Long? = null, scale: Double? = null): the mrope_rotary_embedding_qk_varlen operator. 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. query/key 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.