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 struct
MatmulConfig
struct MatmulConfig[a_type: DType, b_type: DType, c_type: DType, transpose_b: Bool = True]
Static configuration for SM90 (Hopper) GPU warp-specialized matmul.
Encapsulates all compile-time parameters that define a matmul kernel
variant: tile shapes, MMA instruction shape, cluster dimensions, pipeline
depth, consumer warp group count, and scheduling options. Used by the
dispatch layer to select and instantiate HopperMatmulSM90Kernel.
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. - βtranspose_b (
Bool): WhetherBis stored transposed (K-major layout) (defaults toTrue).
Fieldsβ
- βblock_tile_shape (
IndexList[Int(3)]): - βmma_shape (
IndexList[Int(3)]): - βcluster_shape (
IndexList[Int(3)]): - βnum_pipeline_stages (
Int): - βnum_k_partitions (
Int): - βnum_consumer (
Int): - βpartitioned_multicast (
Bool): - βk_group_size (
Int):
Implemented traitsβ
AnyType,
Copyable,
Equatable,
Hashable,
ImplicitlyCopyable,
ImplicitlyDeletable,
Movable,
RegisterPassable,
TrivialRegisterPassable,
Writable
Methodsβ
__init__β
def __init__(block_tile_shape: IndexList[Int(3)], mma_shape: IndexList[Int(3)], cluster_shape: IndexList[Int(3)], num_pipeline_stages: Int, num_k_partitions: Int, num_consumer: Int, partitioned_multicast: Bool, pdl_level: PDLLevel, k_group_size: Int) -> Self
Initialize MatmulConfig with explicit values for all fields.
Args:
- βblock_tile_shape (
IndexList[Int(3)]): The(BM, BN, BK)tile shape per CTA in the M, N, and K dimensions. - βmma_shape (
IndexList[Int(3)]): The(m, n, k)shape of a single MMA instruction. - βcluster_shape (
IndexList[Int(3)]): The thread block cluster dimensions in(M, N, K). - βnum_pipeline_stages (
Int): Number of pipeline stages for double-buffering loads. - β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.
def __init__(m: Int, n: Int, k: Int, num_k_partitions: Int = Int(1), partitioned_multicast: Bool = False, pdl_level: PDLLevel = PDLLevel.OFF, k_groups: Optional[Int] = None, consumer_groups: Optional[Int] = None, swapAB: Bool = False) -> Self
Initialize MatmulConfig by computing optimal values from M, N, K.
Args:
- βm (
Int): The M dimension of the matmul. - βn (
Int): The N dimension of the matmul. - βk (
Int): The K dimension of the matmul. - βnum_k_partitions (
Int): Number of K partitions. - βpartitioned_multicast (
Bool): Whether to use partitioned multicast. - βpdl_level (
PDLLevel): PDL level for grid controls. - βk_groups (
Optional[Int]): How many pipeline (loads and stores) are grouped together. - βconsumer_groups (
Optional[Int]): The number of consumer groups. - βswapAB (
Bool): Whether to swap A and B.
__eq__β
adjust_kgroup_sizeβ
static def adjust_kgroup_size(mma_m: Int, mma_n: Int, K: Int, BK: Int, num_pipeline_stages: Int) -> Int
Returns:
pdl_levelβ
to_base_configβ
def to_base_config(self) -> MatmulConfig[a_type, b_type, c_type, transpose_b]
Convert to base MatmulConfig from utils_gpu.
Returns:
write_toβ
def write_to(self, mut writer: T)
write_repr_toβ
def write_repr_to(self, mut writer: T)
__hash__β
def __hash__[H: Hasher](self, mut hasher: H)
Updates hasher with the underlying bytes.
Parameters:
- βH (
Hasher): The hasher type.
Args:
- βhasher (
H): The hasher instance.
Was this page helpful?
Thank you! We'll create more content like this.
Thank you for helping us improve!