IMPORTANT: To view this page as Markdown, append `.md` to the URL (e.g. /max/get-started.md). For the complete documentation index, see llms.txt.
Skip to main content
For the complete documentation index, see llms.txt. Markdown versions of all pages are available by appending .md to any URL (e.g. /max/get-started.md).

Mojo function

rope_q_proj

def rope_q_proj[dtype: DType, freq_dtype: DType, rank: Int, width: SIMDLength, output_dtype: DType, //, *, interleaved: Bool, has_nope_prefix: Bool = False, rope_dim: Int = Int(0), alignment: Int = Int((get_alignof SIMD[dtype, width], _current_target()))](q_proj: TileTensor[dtype, Storage=q_proj.Storage, address_space=q_proj.address_space, linear_idx_type=q_proj.linear_idx_type], output: TileTensor[output_dtype, Storage=output.Storage, address_space=output.address_space, linear_idx_type=output.linear_idx_type], idx: IndexList[rank], freq_val: SIMD[freq_dtype, width], head_size: Int)

Applies RoPE to a query projection tile and stores the result.

Loads the query projection values at the given coordinate, applies the rotary position embedding via rope_value, and writes the transformed result to the output tile. Supports both interleaved and split (real and imaginary stored separately) layouts, and optionally leaves a nope prefix region unrotated.

Parameters:

  • ​dtype (DType): Element type of the q_proj tile tensor (inferred).
  • ​freq_dtype (DType): Element type of the freq_val frequency coefficients (inferred).
  • ​rank (Int): Rank of the index list and tile tensors (inferred).
  • ​width (SIMDLength): Number of elements per SIMD vector (inferred).
  • ​output_dtype (DType): Element type of the output tile tensor (inferred).
  • ​interleaved (Bool): Whether the RoPE weights use interleaved real and imaginary layout.
  • ​has_nope_prefix (Bool): Whether a leading prefix of the head dimension is left unrotated (defaults to False).
  • ​rope_dim (Int): Number of trailing head dimensions that undergo RoPE when has_nope_prefix is set (defaults to 0).
  • ​alignment (Int): Memory alignment in bytes for tile loads and stores (defaults to the natural alignment of SIMD[dtype, width]).

Args:

Was this page helpful?