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

mla_indexer_ragged_float8_paged

def mla_indexer_ragged_float8_paged[dtype: DType, KCollectionT: KVCollectionT, num_heads: Int, depth: Int, top_k: Int, mask_str: StringSlice[ImmStaticOrigin]](output_indices: TileTensor[DType.int32, Storage=output_indices.Storage, address_space=output_indices.address_space, linear_idx_type=output_indices.linear_idx_type], q: TileTensor[dtype, Storage=q.Storage, address_space=q.address_space, linear_idx_type=q.linear_idx_type], q_s: TileTensor[DType.float32, Storage=q_s.Storage, address_space=q_s.address_space, linear_idx_type=q_s.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], k_collection: KCollectionT, layer_idx: UInt32, ctx: DeviceContext)

Compute FP8 indexed attention scores using paged KV cache and return top-k indices.

This function:

  1. Computes FP8 matmul between q and cached k (with scales), aggregated across heads
  2. Applies the specified mask (causal, etc.)
  3. Computes top-k indices per token (scores are summed across all heads)

Parameters:

  • ​dtype (DType): Element type of the q query tensor, an FP8 dtype.
  • ​KCollectionT (KVCollectionT): Type of the KV collection holding cached K values and K scales.
  • ​num_heads (Int): Number of attention heads per token.
  • ​depth (Int): Per-head key dimension (head size) in elements.
  • ​top_k (Int): Requested number of top-scoring key indices to select per token.
  • ​mask_str (StringSlice[ImmStaticOrigin]): Name of the mask to apply, either MaskName.NULL or MaskName.CAUSAL.

Args:

Was this page helpful?