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
QRegisterBufferRDNA
struct QRegisterBufferRDNA[dtype: DType, mma_shape: IndexList[Int(3)], k_group_size: Int, WM: Int, WN: Int, BN: Int, BK: Int, depth: Int]
Q register buffer: loads each warp's (WM, depth) Q sub-tile into BK-strip MMA fragments at construction.
Parametersβ
- βdtype (
DType): Element type of the Q tensor and register fragments. - βmma_shape (
IndexList[Int(3)]):(M, N, K)shape of a single MMA instruction as anIndexList[3]. - βk_group_size (
Int): Grouping factor for the MMA K dimension. - βWM (
Int): M (query) tile height owned by each warp, in elements. - βWN (
Int): N tile width owned by each warp, in elements. - βBN (
Int): Total N (key) tile width across all warps, in elements. - βBK (
Int): K strip width loaded per pipeline stage, in elements. - βdepth (
Int): Total head depth of the Q matrix in DRAM, in elements.
Fieldsβ
- βreg_tile (
QRegisterBufferRDNA[dtype, mma_shape, k_group_size, WM, WN, BN, BK, depth].RegisterTileType):
Implemented traitsβ
comptime membersβ
mma_dtypeβ
comptime mma_dtype = dtype
MMA_Kβ
comptime MMA_K = mma_shape[Int(2)]
MMA_Mβ
comptime MMA_M = mma_shape[Int(0)]
mma_tile_layoutβ
comptime mma_tile_layout = row_major[ceildiv(WM, mma_shape[Int(0)]), Int(16)]()
MMATileTypeβ
comptime MMATileType = TileTensor[dtype, Layout[*?, *?], MutAnyOrigin, address_space=AddressSpace.LOCAL]
num_k_tilesβ
comptime num_k_tiles = ceildiv(BK, Int((mul mma_shape[Int(2)], k_group_size)))
num_mmasβ
comptime num_mmas = ceildiv(WM, mma_shape[Int(0)])
num_tilesβ
comptime num_tiles = (depth // BK)
rdna_frag_sizeβ
comptime rdna_frag_size = RDNA_AB_FRAG_SIZE
reg_dtypeβ
comptime reg_dtype = dtype
reg_tile_layoutβ
comptime reg_tile_layout = row_major[(Int((mul ceildiv(BK, Int((mul mma_shape[Int(2)], k_group_size))), ceildiv(WM, mma_shape[Int(0)]))) * QRegisterBufferRDNA[dtype, mma_shape, k_group_size, WM, WN, BN, BK, depth].num_tiles), Int(16)]()
RegisterTileTypeβ
comptime RegisterTileType = TileTensor[dtype, Layout[*?, *?], MutAnyOrigin, address_space=AddressSpace.LOCAL]
simd_widthβ
comptime simd_width = simd_width_of[dtype]()
Methodsβ
__init__β
def __init__[q_layout: TensorLayout](out self, tensor: TileTensor[dtype, q_layout, ImmutAnyOrigin], valid_rows: Int)
Load each warp's Q sub-tile from DRAM into register MMA fragments.
Parameters:
- βq_layout (
TensorLayout):TensorLayoutof the Q tensor in DRAM (inferred).
Args:
- βtensor (
TileTensor[dtype, q_layout, ImmutAnyOrigin]): DRAM Q tile inq_layout. - βvalid_rows (
Int): Q row bound for OOB clamping, equal to the group size for decode or the clamped sequence tile size for prefill.
get_dtypeβ
get_mma_tileβ
def get_mma_tile[tile_idx: Int, k_idx: Int](self) -> Self.MMATileType
MMA fragment for the tile_idx-th depth tile, k_idx-th K strip within it.
Parameters:
- βtile_idx (
Int): Index of the depth tile along the depth axis. - βk_idx (
Int): Index of the K strip within the depth tile.
Returns:
Self.MMATileType
get_reg_tileβ
def get_reg_tile[stage: Int = Int(0)](self) -> Self.RegisterTileType
Returns:
Self.RegisterTileType
zeroβ
def zero(self)
Was this page helpful?
Thank you! We'll create more content like this.
Thank you for helping us improve!