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_SFA
def load_AB_SFA[a_type: DType, b_type: DType, sfa_dtype: DType, sfa_tma_dtype: DType, a_rank: Int, a_tile_shape: IndexList[a_rank], a_desc_shape: IndexList[a_rank], b_rank: Int, b_tile_shape: IndexList[b_rank], b_desc_shape: IndexList[b_rank], sfa_rank: Int, sfa_tile_shape: IndexList[sfa_rank], sfa_desc_shape: IndexList[sfa_rank], a_dim0: Int, a_dim1: Int, a_num_tiles: Int, a_swizzle_bytes: Int, b_dim0: Int, b_dim1: Int, b_num_tiles: Int, b_swizzle_bytes: Int, num_pipeline_stages: Int, /, *, 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_rank, a_tile_shape, a_desc_shape], b_tma_op: TMATensorTile[b_type, b_rank, b_tile_shape, b_desc_shape], sfa_tma_op: TMATensorTile[sfa_tma_dtype, sfa_rank, sfa_tile_shape, sfa_desc_shape], a_smem_tiles: SMemTileArray2D[a_type, a_dim0, a_dim1, a_num_tiles, a_swizzle_bytes], b_smem_tiles: SMemTileArray2D[b_type, b_dim0, b_dim1, b_num_tiles, b_swizzle_bytes], sfa_smem_tiles: SMemTileArrayWithLayout[sfa_dtype], load_mma_pipeline: ProducerConsumerPipeline[num_pipeline_stages], peer_cta_coord: Tuple[Int, Int, Int], work_tile_coord: Tuple[Int, Int, Int], a_multicast_mask: UInt16, b_multicast_mask: UInt16, iter_idx: UInt32, elect_one_cta: Bool)
Issues multicast TMA loads for one K-group of A, B, and SFA into SMEM.
Waits for the MMA consumer to release the pipeline slot, programs the producer mbarrier with the expected byte count, and fires 3D multicast loads for A and B plus a 4D uint16 load for SFA into the stage's SMEM tiles. SFB is not loaded here; it uses the cp.async path.
Parameters:
- βa_type (
DType): Element dtype of the A operand matrix. - βb_type (
DType): Element dtype of the B operand matrix. - βsfa_dtype (
DType): Element dtype of the A scale factors. - βsfa_tma_dtype (
DType): Element dtype used for the SFA TMA descriptor; may differ fromsfa_dtype(for exampleuint16for 4D TMA). - βa_rank (
Int): Tensor rank of the A operand TMA descriptor. - βa_tile_shape (
IndexList[a_rank]): Per-tile shape of the A TMA load. - βa_desc_shape (
IndexList[a_rank]): Full descriptor shape of the A TMA load. - βb_rank (
Int): Tensor rank of the B operand TMA descriptor. - βb_tile_shape (
IndexList[b_rank]): Per-tile shape of the B TMA load. - βb_desc_shape (
IndexList[b_rank]): Full descriptor shape of the B TMA load. - βsfa_rank (
Int): Tensor rank of the SFA TMA descriptor. - βsfa_tile_shape (
IndexList[sfa_rank]): Per-tile shape of the SFA TMA load. - βsfa_desc_shape (
IndexList[sfa_rank]): Full descriptor shape of the SFA TMA load. - βa_dim0 (
Int): Row count of each A SMEM tile. - βa_dim1 (
Int): Column count of each A SMEM tile. - βa_num_tiles (
Int): Total number of A SMEM tiles across all pipeline stages. - βa_swizzle_bytes (
Int): Swizzle stride in bytes for the A SMEM tiles. - βb_dim0 (
Int): Row count of each B SMEM tile. - βb_dim1 (
Int): Column count of each B SMEM tile. - βb_num_tiles (
Int): Total number of B SMEM tiles across all pipeline stages. - βb_swizzle_bytes (
Int): Swizzle stride in bytes for the B SMEM tiles. - βnum_pipeline_stages (
Int): Number of producer/consumer stages in the A/B/SFA load and MMA pipeline. - βblock_tile_shape (
IndexList[Int(3)]): Block tile shape as(BM, BN, BK)in elements. - βmma_shape (
IndexList[Int(3)]): MMA atom shape as(MMA_M, MMA_N, MMA_K)in elements. - βnum_sf_k_tiles (
Int): Number of scale-factor K-tiles loaded per K-group iteration. - βcta_group (
Int): Number of CTAs cooperating per MMA group (defaults to 1). - βk_group_size (
Int): Number of K-tiles loaded per pipeline stage (defaults to 1).
Args:
- βa_tma_op (
TMATensorTile[a_type, a_rank, a_tile_shape, a_desc_shape]): TMA tensor tile descriptor for loading A from global memory. - βb_tma_op (
TMATensorTile[b_type, b_rank, b_tile_shape, b_desc_shape]): TMA tensor tile descriptor for loading B from global memory. - βsfa_tma_op (
TMATensorTile[sfa_tma_dtype, sfa_rank, sfa_tile_shape, sfa_desc_shape]): TMA tensor tile descriptor for loading SFA (A scale factors) from global memory. - βa_smem_tiles (
SMemTileArray2D[a_type, a_dim0, a_dim1, a_num_tiles, a_swizzle_bytes]): SMEM tile array holding the A operand tiles. - βb_smem_tiles (
SMemTileArray2D[b_type, b_dim0, b_dim1, b_num_tiles, b_swizzle_bytes]): SMEM tile array holding the B operand tiles. - βsfa_smem_tiles (
SMemTileArrayWithLayout[sfa_dtype]): SMEM tile array holding the A scale-factor tiles. - βload_mma_pipeline (
ProducerConsumerPipeline[num_pipeline_stages]): Producer/consumer pipeline synchronizing A/B/SFA loads with MMA consumption. - βpeer_cta_coord (
Tuple[Int, Int, Int]):(v, m, n)coordinates of this CTA within the cluster, used to compute SMEM slice offsets for multicast distribution. - βwork_tile_coord (
Tuple[Int, Int, Int]):(M, N, batch)coordinates of the output tile being computed. - βa_multicast_mask (
UInt16): Multicast bitmask selecting which CTAs receive the A TMA load. - βb_multicast_mask (
UInt16): Multicast bitmask selecting which CTAs receive the B TMA load. - βiter_idx (
UInt32): Current K-iteration index within the tile loop, in units of individual K-tiles. - βelect_one_cta (
Bool): Whether this CTA is elected as the leader for mbarrier byte-count programming.
Was this page helpful?
Thank you! We'll create more content like this.
Thank you for helping us improve!