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
consumer_main_loop
def consumer_main_loop[accum_type: DType, c_type: DType, a_type: DType, b_type: DType, sfa_dtype: DType, sfb_dtype: DType, 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, a_swizzle: TensorMapSwizzle, b_swizzle: TensorMapSwizzle, transpose_b: Bool, pipeline_stages: Int, scaling_kind: UMMAKind, num_group_pipeline_stages: Int, /, *, block_tile_shape: IndexList[Int(3)], mma_shape: IndexList[Int(3)], SFA_NUM_COLS: Int, SFB_NUM_COLS: Int, cta_group: Int = Int(1), cluster_shape: IndexList[Int(3)] = Index[Int, Int, Int](Int(1), Int(1), Int(1)), k_group_size: Int = Int(1)](tmem_addr: UInt32, sfa_tmem: UInt32, sfb_tmem: UInt32, 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], sfb_smem_tiles: SMemTileArrayWithLayout[sfb_dtype], load_mma_pipeline: ProducerConsumerPipeline[pipeline_stages], sfb_pipeline: ProducerConsumerPipeline[num_group_pipeline_stages], sfb_ready_mbars: Pointer[SharedMemBarrier, address_space=AddressSpace.SHARED, _safe=False], mut sfb_ready_state: PipelineState[num_group_pipeline_stages], mma_op: MmaOpSM100_BlockScaled_SS[c_type, a_type, b_type, sfa_dtype, sfb_dtype, scaling_kind, block_tile_shape, mma_shape, accum_type=accum_type, cta_group=cta_group, cluster_shape=cluster_shape, a_swizzle=a_swizzle, b_swizzle=b_swizzle, transpose_b=transpose_b, enable_small_sfb=True], elect_one_warp: Bool, iter_idx: UInt32, k_start: UInt32, work_tile_coord: Tuple[Int, Int])
TileTensor overload of consumer_main_loop for block-scaled MMA (small BN).
Accepts SMemTileArray2D for A/B tiles and SMemTileArrayWithLayout for scale factor tiles, calling the TileTensor MMA overload.
Parameters:
- βaccum_type (
DType): Element dtype of the MMA accumulator. - βc_type (
DType): Element dtype of the C output matrix. - β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. - βsfb_dtype (
DType): Element dtype of the B scale factors. - β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. - βa_swizzle (
TensorMapSwizzle): TMA swizzle mode for the A operand. - βb_swizzle (
TensorMapSwizzle): TMA swizzle mode for the B operand. - βtranspose_b (
Bool): Whether B is stored in K-major (transposed) layout. - βpipeline_stages (
Int): Number of producer/consumer stages in the A/B/SFA load and MMA pipeline. - βscaling_kind (
UMMAKind): Block-scaled MMA kind (for example MXFP8 or NVFP4). - βnum_group_pipeline_stages (
Int): Number of producer/consumer stages in the SFB load pipeline, counted in K-group units. - β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. - βSFA_NUM_COLS (
Int): Number of TMEM columns occupied per pipeline stage by the A scale factors. - βSFB_NUM_COLS (
Int): Number of TMEM columns occupied per pipeline stage by the B scale factors. - βcta_group (
Int): Number of CTAs cooperating per MMA group (defaults to 1). - βcluster_shape (
IndexList[Int(3)]): Cluster dimensions in (M, N, K) thread blocks (defaults to(1, 1, 1)). - βk_group_size (
Int): Number of K-tiles loaded per pipeline stage (defaults to 1).
Args:
- βtmem_addr (
UInt32): Base TMEM address of the accumulator tile. - βsfa_tmem (
UInt32): Base TMEM address of the A scale-factor tile. - βsfb_tmem (
UInt32): Base TMEM address of the B scale-factor tile. - β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. - βsfb_smem_tiles (
SMemTileArrayWithLayout[sfb_dtype]): SMEM tile array holding the B scale-factor tiles. - βload_mma_pipeline (
ProducerConsumerPipeline[pipeline_stages]): Producer/consumer pipeline synchronizing A/B/SFA loads with MMA consumption. - βsfb_pipeline (
ProducerConsumerPipeline[num_group_pipeline_stages]): Producer/consumer pipeline synchronizing SFB loads with MMA consumption; used on the 1CTA path. - βsfb_ready_mbars (
Pointer[SharedMemBarrier, address_space=AddressSpace.SHARED, _safe=False]): Cross-CTA SFB readiness mbarriers; consulted only whencta_group == 2. - βsfb_ready_state (
PipelineState[num_group_pipeline_stages]): Pipeline state tracking the currentsfb_ready_mbarsslot and phase. - βmma_op (
MmaOpSM100_BlockScaled_SS[c_type, a_type, b_type, sfa_dtype, sfb_dtype, scaling_kind, block_tile_shape, mma_shape, accum_type=accum_type, cta_group=cta_group, cluster_shape=cluster_shape, a_swizzle=a_swizzle, b_swizzle=b_swizzle, transpose_b=transpose_b, enable_small_sfb=True]): Block-scaled MMA operation object driving the UMMA instruction. - βelect_one_warp (
Bool): Whether this warp is elected to perform the MMA work. - βiter_idx (
UInt32): Current K-iteration index within the tile loop. - βk_start (
UInt32): K-iteration index of the first iteration, used to initialize the accumulator on the first MMA. - βwork_tile_coord (
Tuple[Int, Int]):(M, N)coordinates of the output tile being computed.
Was this page helpful?
Thank you! We'll create more content like this.
Thank you for helping us improve!