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

load_AB

def load_AB[a_type: DType, b_type: DType, a_scales_type: 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], a_scales_tile_rank: Int, a_scales_tile_shape: IndexList[a_scales_tile_rank], a_scales_desc_shape: IndexList[a_scales_tile_rank], num_pipeline_stages: Int, expert_ids_layout: Layout, /, *, a_smem_layout: Layout, b_smem_layout: Layout, a_scales_smem_layout: Layout, block_tile_shape: IndexList[Int(3)], mma_shape: IndexList[Int(3)], cta_group: 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], a_scales_tma_op: TMATensorTile[a_scales_type, a_scales_tile_rank, a_scales_tile_shape, a_scales_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], a_scales_smem_base: Pointer[Scalar[a_scales_type], 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: Int, 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_ids: LayoutTensor[DType.int32, expert_ids_layout, ImmutAnyOrigin])

Issues multicast TMA loads for A, B, and A scales into the producer stage of the load-MMA pipeline.

Waits for the consumer (MMA) to release the buffer, then launches async multicast TMA copies of A, B, and the matching A scales strip into the current pipeline stage's SMEM and signals completion through the stage's mbarrier.

Parameters:

  • ​a_type (DType): Element dtype of the A activation operand (inferred).
  • ​b_type (DType): Element dtype of the B weight operand (inferred).
  • ​a_scales_type (DType): Element dtype of the A per-block scales (inferred).
  • ​a_tile_rank (Int): Rank of the A TMA tile descriptor (inferred).
  • ​a_tile_shape (IndexList[a_tile_rank]): Shape of each A TMA tile copy (inferred).
  • ​a_desc_shape (IndexList[a_tile_rank]): Descriptor shape of the A TMA tensor (inferred).
  • ​b_tile_rank (Int): Rank of the B TMA tile descriptor (inferred).
  • ​b_tile_shape (IndexList[b_tile_rank]): Shape of each B TMA tile copy (inferred).
  • ​b_desc_shape (IndexList[b_tile_rank]): Descriptor shape of the B TMA tensor (inferred).
  • ​a_scales_tile_rank (Int): Rank of the A scales TMA tile descriptor (inferred).
  • ​a_scales_tile_shape (IndexList[a_scales_tile_rank]): Shape of each A scales TMA tile copy (inferred).
  • ​a_scales_desc_shape (IndexList[a_scales_tile_rank]): Descriptor shape of the A scales TMA tensor (inferred).
  • ​num_pipeline_stages (Int): Number of load-MMA pipeline buffer stages (inferred).
  • ​expert_ids_layout (Layout): Layout of the expert-IDs mapping tensor (inferred).
  • ​a_smem_layout (Layout): SMEM layout for the A tile buffer.
  • ​b_smem_layout (Layout): SMEM layout for the B tile buffer.
  • ​a_scales_smem_layout (Layout): SMEM layout for the A scales strip.
  • ​block_tile_shape (IndexList[Int(3)]): Block tile shape as (BM, BN, BK).
  • ​mma_shape (IndexList[Int(3)]): MMA instruction shape as (MMA_M, MMA_N, MMA_K).
  • ​cta_group (Int): CTA group size, 1 or 2 (defaults to 1).

Args: