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
gemm_mma_cpasync_kernel
def gemm_mma_cpasync_kernel[c_type: DType, a_type: DType, b_type: DType, c_layout: TensorLayout, a_layout: TensorLayout, b_layout: TensorLayout, *, tile_m: Int = Int(16), tile_n: Int = Int(8), tile_k: Int = Int(128), stage_cnt: Int = Int(2), accum_type: DType = DType.float32, elementwise_lambda_fn: Optional[def[dtype: DType, width: SIMDLength, *, alignment: Int = Int(1)](IndexList[Int(2)], SIMD[dtype, width]) capturing thin -> None] = None, pdl_level: PDLLevel = PDLLevel(), swapAB: Bool = False](output: TileTensor[c_type, c_layout, MutAnyOrigin], act: TileTensor[a_type, a_layout, ImmutAnyOrigin], weight: TileTensor[b_type, b_layout, ImmutAnyOrigin], gemm_m: Int, gemm_k: Int, gemm_n: Int, batch_size: Int)
SM100 (B200) warp-specialized GEMM kernel using cp.async and m16n8k16 MMA instructions.
Implements a multi-stage software-pipelining loop: producer warps (0-3) prefetch activation and weight tiles from global memory into shared memory via cp.async, and consumer warps (4+) issue m16n8k16 MMA operations and write results to the output. Requires B200 (sm_100x) hardware.
Parameters:
- βc_type (
DType): Output element type. - βa_type (
DType): Activation (A) element type. - βb_type (
DType): Weight (B) element type. - βc_layout (
TensorLayout): TensorLayout for the output. - βa_layout (
TensorLayout): TensorLayout for activations. - βb_layout (
TensorLayout): TensorLayout for weights. - βtile_m (
Int): Tile size along M; must be 16 for m16n8k16 MMA. - βtile_n (
Int): Tile size along N per warp. - βtile_k (
Int): Tile size along K; determines shared memory allocation. - βstage_cnt (
Int): Number of pipeline stages. - βaccum_type (
DType): Accumulator precision; must be float32. - βelementwise_lambda_fn (
Optional[def[dtype: DType, width: SIMDLength, *, alignment: Int = Int(1)](IndexList[Int(2)], SIMD[dtype, width]) capturing thin -> None]): Optional epilogue applied to each output element. - βpdl_level (
PDLLevel): Programmatic dependent launch level. - βswapAB (
Bool): When True, swaps the A and B operand roles.
Args:
- βoutput (
TileTensor[c_type, c_layout, MutAnyOrigin]): Rank-3 output TileTensor of shape (batch, gemm_m, gemm_n). - βact (
TileTensor[a_type, a_layout, ImmutAnyOrigin]): Rank-3 activation TileTensor of shape (batch, gemm_m, gemm_k). - βweight (
TileTensor[b_type, b_layout, ImmutAnyOrigin]): Rank-3 weight TileTensor of shape (batch, gemm_n, gemm_k). - βgemm_m (
Int): M dimension of the GEMM. - βgemm_k (
Int): K (reduction) dimension of the GEMM. - βgemm_n (
Int): N dimension of the GEMM. - βbatch_size (
Int): Number of independent GEMM problems in the batch.
Was this page helpful?
Thank you! We'll create more content like this.
Thank you for helping us improve!