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
swapAB_smallM
def swapAB_smallM[a_type: DType, b_type: DType, c_type: DType, prioritize_compute_over_ctas: Bool = False, transpose_b: Bool = True](m: Int, n: Int, k: Int, cluster_shape: IndexList[Int(3)], num_k_partitions: Int, num_consumer: Int, partitioned_multicast: Bool, pdl_level: PDLLevel, k_group_size: Int = Int(0), num_pipeline_stages: Int = Int(0)) -> MatmulConfig[a_type, b_type, c_type, transpose_b]
Selects an SM90 MatmulConfig for small-M problems by swapping A and B roles.
When M is small compared to N, treating N as the leading dimension and swapping A/B improves SM utilization. Sweeps MMA-N values and picks the configuration that maximizes SM wave occupancy or compute ratio.
Parameters:
- βa_type (
DType): ElementDTypeof the A input matrix. - βb_type (
DType): ElementDTypeof the B input matrix. - βc_type (
DType): ElementDTypeof the output C matrix. - βprioritize_compute_over_ctas (
Bool): Whether to select MMA-N by minimizing wasted compute ratio rather than maximizing CTAs used (defaults toFalse). - βtranspose_b (
Bool): WhetherBis stored transposed (K-major layout) (defaults toTrue).
Args:
- βm (
Int): The M dimension of the matmul (mapped to N after the A/B swap). - βn (
Int): The N dimension of the matmul (mapped to M after the A/B swap). - βk (
Int): The K dimension (contraction axis) of the matmul. - βcluster_shape (
IndexList[Int(3)]): The thread block cluster dimensions in(M, N, K). - βnum_k_partitions (
Int): Number of partitions to split the K dimension into. - βnum_consumer (
Int): Number of consumer warp groups. - βpartitioned_multicast (
Bool): Whether to use partitioned TMA multicast. - βpdl_level (
PDLLevel): Programmatic dependent launch level for grid controls. - βk_group_size (
Int): Number of K iterations grouped per pipeline stage, or 0 to auto-compute (defaults to 0). - βnum_pipeline_stages (
Int): Number of pipeline stages for double-buffering loads, or 0 to maximize by default (defaults to 0).
Returns:
MatmulConfig[a_type, b_type, c_type, transpose_b]: A MatmulConfig with swapped AB dimensions tuned for small-M inputs.
Was this page helpful?
Thank you! We'll create more content like this.
Thank you for helping us improve!