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
mha_sm100_depth512_dispatch
def mha_sm100_depth512_dispatch[q_type: DType, KVType: MHAOperand, MaskType: MHAMask, output_type: DType, MaxPromptLenType: OptionallyStaticInt, PartitionType: MHAPartitionScheme, //, config: MHAConfig[config.dtype], group: Int, ragged: Bool, _is_cache_length_accurate: Bool](output: DeviceBuffer[output_type], q_arg: Pointer[Scalar[q_type], _safe=False], k: KVType, v: KVType, num_rows_q: Int, mask: MaskType, valid_length: Pointer[UInt32, _safe=False], max_prompt_len_arg: MaxPromptLenType, max_cache_valid_length_arg: Int, scale: Float32, kv_input_row_offsets: OptionalReg[TileTensor[DType.uint32, Layout[*?, *?], ImmutAnyOrigin]], batch_size_arg: Int, partition: PartitionType, ctx: DeviceContext)
Dispatches the pair-CTA SM100 depth=256/512 MHA prefill kernel.
Builds the Depth512SM100Config, constructs TMA tile descriptors for the
Q, K, V, and output operands, creates a TransientScheduler with
pair_cta=True, and enqueues the SM100MHADepth512 kernel with
cluster_dim=(2, 1, 1) so both CTAs in a cluster derive the same tile
index from block_idx.x >> 1. Only prefill is supported; decoding is
rejected at compile time.
Parameters:
- βq_type (
DType): The query tensor element type (inferred). - βKVType (
MHAOperand): The paged KV cache operand type providing the tile factory and page size (inferred). - βMaskType (
MHAMask): The attention mask type applied to the scores (inferred). - βoutput_type (
DType): The output buffer element type (inferred). - βMaxPromptLenType (
OptionallyStaticInt): The maximum prompt length as a static or runtime value (inferred). - βPartitionType (
MHAPartitionScheme): The KV cache partition scheme (inferred). - βconfig (
MHAConfig[config.dtype]): The MHA configuration with head count, depth, and swizzle mode used to build theDepth512SM100Config. - βgroup (
Int): Number of query heads per KV head for grouped-query attention. - βragged (
Bool): Whether the batch uses ragged sequence lengths with a non-nullvalid_lengthpointer. - β_is_cache_length_accurate (
Bool): Whether the per-batch cache length values are exact.
Args:
- βoutput (
DeviceBuffer[output_type]): Device buffer that receives the attention output. - βq_arg (
Pointer[Scalar[q_type], _safe=False]): Pointer to the query tensor data. - βk (
KVType): Key operand providing the paged KV cache tile factory. - βv (
KVType): Value operand providing the paged KV cache tile factory. - βnum_rows_q (
Int): Number of query rows to process. - βmask (
MaskType): Causal or padding mask applied to the attention scores. - βvalid_length (
Pointer[UInt32, _safe=False]): Per-batch pointer to valid cache lengths (used whenraggedis true). - βmax_prompt_len_arg (
MaxPromptLenType): Maximum prompt length, static or runtime. - βmax_cache_valid_length_arg (
Int): Maximum valid cache length across the batch. - βscale (
Float32): Scaling factor applied to the QK dot product. - βkv_input_row_offsets (
OptionalReg[TileTensor[DType.uint32, Layout[*?, *?], ImmutAnyOrigin]]): Optional ragged row-offset tensor for KV input rows. - βbatch_size_arg (
Int): Number of sequences in the batch. - βpartition (
PartitionType): Partition scheme for the KV cache. - βctx (
DeviceContext): Device context used to create TMA descriptors and enqueue the kernel.
Was this page helpful?
Thank you! We'll create more content like this.
Thank you for helping us improve!