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

depth512_softmax

def depth512_softmax[MaskType: MHAMask, qkv_dtype: DType, output_type: DType, config: Depth512SM100Config[qkv_dtype], page_size: Int](smem: Depth512AttentionSMem[config], tmem_addr: UInt32, seq_id: UInt32, score_row: UInt32, num_keys: UInt32, mask: MaskType, scale: Float32, ragged_tma_store: RaggedTMA3DTile[output_type, TensorMapSwizzle.SWIZZLE_NONE, BM=config.BM, BN=config.ov_depth, middle_dim=ragged_tma_store.middle_dim, group=config.group if config.fuse_gqa else Int(1), tma_blocks_per_op=ragged_tma_store.tma_blocks_per_op], num_output_rows: Int32, out_head_idx: UInt32, out_row_idx: UInt32)

Runs the online softmax warp group for pair-CTA SM100 attention.

Loads Q@K' scores (S) from TMEM in pipelined batches, applies the causal mask, computes a running row max and exponentiated probabilities P, writes P to SMEM for the P@V SS MMA, accumulates the row sum, and finally scales the O accumulator by the inverse row sum and TMA-stores the result to global memory. For split_o (d512) configs, cross-thread partial max and sum values are combined via correction SMEM; for d256 each thread owns a unique M row and no exchange is needed.

Parameters:

  • ​MaskType (MHAMask): Compile-time mask type for causal/attention masking.
  • ​qkv_dtype (DType): DType of the Q/K/V inputs; specializes the config.
  • ​output_type (DType): DType of the output store to global memory.
  • ​config (Depth512SM100Config[qkv_dtype]): Depth512 SM100 kernel config struct (tile sizes, split_o).
  • ​page_size (Int): KV cache page size in tokens, used for paged-attention masking.

Args:

Was this page helpful?