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_split_store_paged_ragged
def rope_split_store_paged_ragged[dtype: DType, freq_dtype: DType, q_out_dtype: DType = dtype, target: StringSlice[ImmStaticOrigin] = StringSlice("cpu"), interleaved: Bool = True](qkv: TileTensor[dtype, Storage=qkv.Storage, address_space=qkv.address_space, linear_idx_type=qkv.linear_idx_type], input_row_offsets: TileTensor[DType.uint32, Storage=input_row_offsets.Storage, address_space=input_row_offsets.address_space, linear_idx_type=input_row_offsets.linear_idx_type], freqs_cis: TileTensor[freq_dtype, Storage=freqs_cis.Storage, address_space=freqs_cis.address_space, linear_idx_type=freqs_cis.linear_idx_type], kv_collection: PagedKVCacheCollection[scale_dtype_=kv_collection.scale_dtype_, quantization_granularity_=kv_collection.quantization_granularity_], layer_idx: UInt32, q_output: TileTensor[q_out_dtype, Storage=q_output.Storage, address_space=q_output.address_space, linear_idx_type=q_output.linear_idx_type], ctx: DeviceContext)
Rope+split+store with paged KV cache collection.
Parameters:
- βdtype (
DType): Element type of the QKV input buffer. - βfreq_dtype (
DType): Element type of thefreqs_cisRoPE frequency table. - βq_out_dtype (
DType): Element type of the roped Q output buffer (defaults todtype). - βtarget (
StringSlice[ImmStaticOrigin]): Compile target backend, for example"gpu"or"cpu"(defaults to"cpu"). - βinterleaved (
Bool): Whether RoPE uses the interleaved real/imag layout (defaults toTrue).
Args:
- βqkv (
TileTensor[dtype, Storage=qkv.Storage, address_space=qkv.address_space, linear_idx_type=qkv.linear_idx_type]): Flat matmul output [total_seq_len, q_dim + k_dim + v_dim]. - βinput_row_offsets (
TileTensor[DType.uint32, Storage=input_row_offsets.Storage, address_space=input_row_offsets.address_space, linear_idx_type=input_row_offsets.linear_idx_type]): [batch_size + 1] ragged offsets. - βfreqs_cis (
TileTensor[freq_dtype, Storage=freqs_cis.Storage, address_space=freqs_cis.address_space, linear_idx_type=freqs_cis.linear_idx_type]): [max_seq_len, head_dim] interleaved rope frequencies. - βkv_collection (
PagedKVCacheCollection[scale_dtype_=kv_collection.scale_dtype_, quantization_granularity_=kv_collection.quantization_granularity_]): Paged KV cache collection to store K and V into. - βlayer_idx (
UInt32): Index of the layer whose K/V caches inkv_collectionto store into. - βq_output (
TileTensor[q_out_dtype, Storage=q_output.Storage, address_space=q_output.address_space, linear_idx_type=q_output.linear_idx_type]): Output buffer for roped Q [total_seq_len, q_dim]. - βctx (
DeviceContext): DeviceContext for GPU.
Was this page helpful?
Thank you! We'll create more content like this.
Thank you for helping us improve!