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
load_AB
def load_AB[a_type: DType, b_type: DType, c_type: DType, sfa_dtype: DType, sfb_dtype: DType, a_tile_rank: Int, a_tile_shape: IndexList[a_tile_rank], a_desc_shape: IndexList[a_tile_rank], b_tile_rank: Int, b_tile_shape: IndexList[b_tile_rank], b_desc_shape: IndexList[b_tile_rank], sfa_tile_rank: Int, sfa_tile_shape: IndexList[sfa_tile_rank], sfa_desc_shape: IndexList[sfa_tile_rank], sfb_tile_rank: Int, sfb_tile_shape: IndexList[sfb_tile_rank], sfb_desc_shape: IndexList[sfb_tile_rank], num_pipeline_stages: Int, group_scale_offsets_layout: Layout, transpose_b: Bool, /, *, a_smem_layout: Layout, b_smem_layout: Layout, sfa_smem_layout: Layout, sfb_smem_layout: Layout, config: BlockScaledMatmulConfig[a_type, b_type, c_type, sfa_dtype, sfb_dtype, transpose_b], block_tile_shape: IndexList[Int(3)], mma_shape: IndexList[Int(3)], num_sf_k_tiles: Int, cta_group: Int = Int(1), k_group_size: Int = Int(1)](a_tma_op: TMATensorTile[a_type, a_tile_rank, a_tile_shape, a_desc_shape], b_tma_op: TMATensorTile[b_type, b_tile_rank, b_tile_shape, b_desc_shape], sfa_tma_op: TMATensorTile[sfa_dtype, sfa_tile_rank, sfa_tile_shape, sfa_desc_shape], sfb_tma_op: TMATensorTile[sfb_dtype, sfb_tile_rank, sfb_tile_shape, sfb_desc_shape], a_smem_base: Pointer[Scalar[a_type], address_space=AddressSpace.SHARED, _safe=False], b_smem_base: Pointer[Scalar[b_type], address_space=AddressSpace.SHARED, _safe=False], sfa_smem_base: Pointer[Scalar[sfa_dtype], address_space=AddressSpace.SHARED, _safe=False], sfb_smem_base: Pointer[Scalar[sfb_dtype], address_space=AddressSpace.SHARED, _safe=False], load_mma_pipeline: ProducerConsumerPipeline[num_pipeline_stages], peer_cta_coord: Tuple[Int, Int, Int], work_tile_coord: Tuple[Int, Int], a_multicast_mask: UInt16, b_multicast_mask: UInt16, iter_idx: UInt32, elect_one_cta: Bool, scheduler: TileScheduler[static_MN=scheduler.static_MN, tile_shape=scheduler.tile_shape, cluster=scheduler.cluster, cta_group=scheduler.cta_group, swizzle=scheduler.swizzle, swapAB=scheduler.swapAB], expert_id: Int32, group_scale_offsets: LayoutTensor[DType.uint32, group_scale_offsets_layout, MutAnyOrigin])
Issues multicast TMA loads for A, B, and their scale factors into shared memory.
Waits for the consumer (MMA) to release the current pipeline stage buffer, then launches asynchronous multicast TMA copies of the A and B tiles along with their corresponding block scale factors into shared memory for one pipeline stage, accounting for expert offsets and group scale offsets.
Parameters:
- βa_type (
DType): The data type of input tensor A. - βb_type (
DType): The data type of input tensor B. - βc_type (
DType): The data type of the output tensor C. - βsfa_dtype (
DType): The data type of the A scale factors. - βsfb_dtype (
DType): The data type of the B scale factors. - βa_tile_rank (
Int): The rank of the A TMA tile. - βa_tile_shape (
IndexList[a_tile_rank]): The shape of the A TMA tile. - βa_desc_shape (
IndexList[a_tile_rank]): The descriptor shape of the A TMA tile. - βb_tile_rank (
Int): The rank of the B TMA tile. - βb_tile_shape (
IndexList[b_tile_rank]): The shape of the B TMA tile. - βb_desc_shape (
IndexList[b_tile_rank]): The descriptor shape of the B TMA tile. - βsfa_tile_rank (
Int): The rank of the A scale factor TMA tile. - βsfa_tile_shape (
IndexList[sfa_tile_rank]): The shape of the A scale factor TMA tile. - βsfa_desc_shape (
IndexList[sfa_tile_rank]): The descriptor shape of the A scale factor TMA tile. - βsfb_tile_rank (
Int): The rank of the B scale factor TMA tile. - βsfb_tile_shape (
IndexList[sfb_tile_rank]): The shape of the B scale factor TMA tile. - βsfb_desc_shape (
IndexList[sfb_tile_rank]): The descriptor shape of the B scale factor TMA tile. - βnum_pipeline_stages (
Int): The number of load/MMA pipeline stages. - βgroup_scale_offsets_layout (
Layout): The layout of the group scale offsets tensor. - βtranspose_b (
Bool): Whether B is stored transposed (K-major). - βa_smem_layout (
Layout): The shared memory layout for A. - βb_smem_layout (
Layout): The shared memory layout for B. - βsfa_smem_layout (
Layout): The shared memory layout for A scale factors. - βsfb_smem_layout (
Layout): The shared memory layout for B scale factors. - βconfig (
BlockScaledMatmulConfig[a_type, b_type, c_type, sfa_dtype, sfb_dtype, transpose_b]): The block-scaled matmul configuration. - βblock_tile_shape (
IndexList[Int(3)]): The (BM, BN, BK) block tile shape. - βmma_shape (
IndexList[Int(3)]): The (MMA_M, MMA_N, MMA_K) MMA shape. - βnum_sf_k_tiles (
Int): The number of scale factor tiles along K. - βcta_group (
Int): The number of CTAs cooperating per output tile (1 or 2). - βk_group_size (
Int): The number of K iterations loaded per pipeline stage.
Args:
- βa_tma_op (
TMATensorTile[a_type, a_tile_rank, a_tile_shape, a_desc_shape]): The TMA tensor tile descriptor for A. - βb_tma_op (
TMATensorTile[b_type, b_tile_rank, b_tile_shape, b_desc_shape]): The TMA tensor tile descriptor for B. - βsfa_tma_op (
TMATensorTile[sfa_dtype, sfa_tile_rank, sfa_tile_shape, sfa_desc_shape]): The TMA tensor tile descriptor for A scale factors. - βsfb_tma_op (
TMATensorTile[sfb_dtype, sfb_tile_rank, sfb_tile_shape, sfb_desc_shape]): The TMA tensor tile descriptor for B scale factors. - βa_smem_base (
Pointer[Scalar[a_type], address_space=AddressSpace.SHARED, _safe=False]): Base pointer to the A shared memory buffer. - βb_smem_base (
Pointer[Scalar[b_type], address_space=AddressSpace.SHARED, _safe=False]): Base pointer to the B shared memory buffer. - βsfa_smem_base (
Pointer[Scalar[sfa_dtype], address_space=AddressSpace.SHARED, _safe=False]): Base pointer to the A scale factor shared memory buffer. - βsfb_smem_base (
Pointer[Scalar[sfb_dtype], address_space=AddressSpace.SHARED, _safe=False]): Base pointer to the B scale factor shared memory buffer. - βload_mma_pipeline (
ProducerConsumerPipeline[num_pipeline_stages]): The producer/consumer pipeline for TMA loads. - βpeer_cta_coord (
Tuple[Int, Int, Int]): The (peer_id, m_coord, n_coord) of the peer CTA. - βwork_tile_coord (
Tuple[Int, Int]): The (m, n) coordinate of the work tile. - βa_multicast_mask (
UInt16): The multicast mask for A TMA loads. - βb_multicast_mask (
UInt16): The multicast mask for B TMA loads. - βiter_idx (
UInt32): The K iteration index for this load. - βelect_one_cta (
Bool): Whether this CTA is the elected leader CTA. - βscheduler (
TileScheduler[static_MN=scheduler.static_MN, tile_shape=scheduler.tile_shape, cluster=scheduler.cluster, cta_group=scheduler.cta_group, swizzle=scheduler.swizzle, swapAB=scheduler.swapAB]): The tile scheduler tracking group and expert state. - βexpert_id (
Int32): The expert ID for the current work tile. - βgroup_scale_offsets (
LayoutTensor[DType.uint32, group_scale_offsets_layout, MutAnyOrigin]): The per-group scale factor offsets tensor.
Was this page helpful?
Thank you! We'll create more content like this.
Thank you for helping us improve!