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_sm100_prefill_sparse

def mla_sm100_prefill_sparse[output_type: DType, q_type: DType, cache_t: KVCacheT, //, num_q_heads: Int, qk_depth: Int, v_depth: Int, indices_stride: Int](output: TileTensor[output_type, Storage=output.Storage, linear_idx_type=output.linear_idx_type], q: TileTensor[q_type, Storage=q.Storage, linear_idx_type=q.linear_idx_type], kv_cache: cache_t, indices: TileTensor[DType.uint32, Storage=indices.Storage, linear_idx_type=indices.linear_idx_type], topk_lengths: TileTensor[DType.uint32, Storage=topk_lengths.Storage, linear_idx_type=topk_lengths.linear_idx_type], attn_sink_ptr: Optional[Pointer[Float32, ImmutAnyOrigin, _safe=False]], scale: Float32, ctx: DeviceContext)

Sparse MLA prefill (DSv3.2 absorbed shape, BF16, SM100).

Thin wrapper around mla_prefill_sparse that builds the MLASparseConfig from the passed dimensions so callers don't have to reach into the kernel's config type. The kernel targets the DSv3.2 absorbed/latent shape and comptime-asserts qk_depth==576, num_q_heads is 128 or 64, and num_kv_heads==1, plus equal output/query bit-width. v_depth is assumed to be 512 (= kv_lora_rank) by that shape but is not asserted.

Parameters:

  • ​output_type (DType): Output element type (must be the same width as q_type; the kernel asserts this).
  • ​q_type (DType): Query element type (BF16 in the supported DSv3.2 shape).
  • ​cache_t (KVCacheT): KV cache type (typically a paged MLA cache obtained from kv_collection.get_key_cache(layer_idx)).
  • ​num_q_heads (Int): Number of query heads (asserted to be 128 or 64).
  • ​qk_depth (Int): Per-head Q/K depth (must be 576 = kv_lora_rank(512) + qk_rope_head_dim(64)).
  • ​v_depth (Int): Per-head V depth (512 = kv_lora_rank for the DSv3.2 absorbed shape; not asserted).
  • ​indices_stride (Int): Per-query indices buffer stride (= the indexer's index_topk). Also used as the runtime indices_stride to the kernel.

Args:

Was this page helpful?