Skip to content

Commit 1b7b9e7

Browse files
committed
[Sm90] Add simple wrapper to make tiled_mma
1 parent d898157 commit 1b7b9e7

1 file changed

Lines changed: 33 additions & 1 deletion

File tree

quack/sm90_utils.py

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Copyright (c) 2025, Tri Dao.
22

3-
from typing import Type, Union, Optional
3+
from typing import Literal, Type, Union, Optional
44

55
import cutlass
66
import cutlass.cute as cute
@@ -42,6 +42,38 @@ def make_smem_layout(
4242
make_smem_layout_epi = make_smem_layout
4343

4444

45+
def make_tiled_mma(
46+
a_dtype: Type[Numeric],
47+
a_major: Literal["K", "MN"],
48+
b_major: Literal["K", "MN"],
49+
tiler_n: int,
50+
source: Literal["SS", "RS"] = "SS",
51+
atom_layout_mnk: tuple = (1, 1, 1),
52+
swap_AB: bool = False,
53+
b_dtype: Optional[Type[Numeric]] = None,
54+
acc_dtype: Type[Numeric] = Float32,
55+
) -> cute.TiledMma:
56+
"""`b_dtype` defaults to `a_dtype`; pass it for mixed-precision MMAs (e.g. fp8).
57+
`acc_dtype` defaults to Float32."""
58+
if b_dtype is None:
59+
b_dtype = a_dtype
60+
mode = {"K": warpgroup.OperandMajorMode.K, "MN": warpgroup.OperandMajorMode.MN}
61+
a_mode, b_mode = mode[a_major], mode[b_major]
62+
if swap_AB:
63+
a_mode, b_mode = b_mode, a_mode
64+
a_source = warpgroup.OperandSource.RMEM if source == "RS" else warpgroup.OperandSource.SMEM
65+
return sm90_utils_og.make_trivial_tiled_mma(
66+
a_dtype,
67+
b_dtype,
68+
a_mode,
69+
b_mode,
70+
acc_dtype,
71+
atom_layout_mnk=atom_layout_mnk,
72+
tiler_mn=(64, tiler_n),
73+
a_source=a_source,
74+
)
75+
76+
4577
@dsl_user_op
4678
def partition_for_epilogue(
4779
cT: cute.Tensor,

0 commit comments

Comments
 (0)