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
TileLoaderLDS
struct TileLoaderLDS[dtype_: DType, tile_rows_: Int, tile_cols_: Int, stride: Int, num_loading_warps: Int, swizzle: Optional[Swizzle] = Optional(), load_width: Int = simd_width_of[dtype_](), use_full_tile_width: Bool = False]
DRAMβLDS DMA expert for warp-group cooperative coord-indexed loads.
Sibling of SubTileLoaderLDS (single-sub-tile TileTensor-indexed).
This one coordinates a warp group (typically 8 warps) to cooperatively
fill a half-tile via coord-indexed iteration: load_tile(dst, m_offset, k_offset) steps through num_iterations BK-wide rows,
optionally applying a per-iteration byte-space swizzle for LDS
bank-conflict avoidance. Matmul's DRAMβLDS pattern (ping-pong, etc.).
Uses stdlib AMDBufferResource.load_to_lds directly β no alias scope
attached. Matmul's scheduling uses s_sched_group_barrier hints,
which don't qualify as the runtime fence required by the
SIInsertWaitcnts vmcnt-relaxation contract; attaching the scope
would miscompile (see the async_copies docstring on
load_to_lds). For attention patterns that DO satisfy the contract
via explicit s_waitcnt vmcnt(0) + s_barrier fences, use
SubTileLoaderLDS instead.
Parametersβ
- βdtype_ (
DType): Element data type. Re-bound todtypeat body scope to match theTileLoadertrait alias. - βtile_rows_ (
Int): Height of each half-tile to load. Re-bound totile_rowsat body scope. - βtile_cols_ (
Int): Width (K dimension) of each half-tile. Re-bound totile_colsat body scope. - βstride (
Int): Row stride of the source GMEM tensor. - βnum_loading_warps (
Int): Warps cooperating on each load (typically 8). - βswizzle (
Optional[Swizzle]): Optional byte-space swizzle for LDS bank conflicts. - βload_width (
Int): Elements per load (SIMD width). - βuse_full_tile_width (
Bool): FP8 row-major mode.
Fieldsβ
- βbuffer (
AMDBufferResource): - βthread_row (
Int): - βthread_col (
Int): - βwarp_id (
Int): - βlane_id (
Int): - βm_anchor (
Int): - βk_anchor (
Int):
Implemented traitsβ
AnyType,
Copyable,
ImplicitlyCopyable,
ImplicitlyDeletable,
Movable,
RegisterPassable,
TileLoader,
TrivialRegisterPassable
comptime membersβ
dtypeβ
comptime dtype = dtype_
elements_per_warpβ
comptime elements_per_warp = (_resolve_warp_size() * load_width)
lane_load_bytesβ
comptime lane_load_bytes = (load_width * size_of[dtype_]())
loading_threadsβ
comptime loading_threads = (num_loading_warps * _resolve_warp_size())
num_iterationsβ
comptime num_iterations = ceildiv(tile_rows_, (Int((mul _resolve_warp_size(), num_loading_warps)) // (tile_cols_ // load_width)))
num_warp_colsβ
comptime num_warp_cols = (tile_cols_ // tile_cols_ if use_full_tile_width else Int(32))
num_warp_rowsβ
comptime num_warp_rows = (num_loading_warps // (tile_cols_ // tile_cols_ if use_full_tile_width else Int(32)))
row_bytesβ
comptime row_bytes = (tile_cols_ * size_of[dtype_]())
rows_per_iterationβ
comptime rows_per_iteration = (Int((mul _resolve_warp_size(), num_loading_warps)) // (tile_cols_ // load_width))
rows_per_warpβ
comptime rows_per_warp = (Int((mul _resolve_warp_size(), load_width)) // tile_cols_)
subtile_colsβ
comptime subtile_cols = TileLoaderLDS[dtype_, tile_rows_, tile_cols_, stride, num_loading_warps, swizzle, load_width, use_full_tile_width].tile_cols if use_full_tile_width else Int(32)
thread_rowsβ
comptime thread_rows = (_resolve_warp_size() // (tile_cols_ if use_full_tile_width else Int(32) // load_width))
threads_per_rowβ
comptime threads_per_row = (tile_cols_ if use_full_tile_width else Int(32) // load_width)
tile_colsβ
comptime tile_cols = tile_cols_
tile_rowsβ
comptime tile_rows = tile_rows_
total_warp_rowsβ
comptime total_warp_rows = ceildiv(tile_rows_, (Int((mul _resolve_warp_size(), load_width)) // tile_cols_))
warp_subtile_bytesβ
comptime warp_subtile_bytes = (Int((mul (Int((mul _resolve_warp_size(), load_width)) // tile_cols_), tile_cols_)) * size_of[dtype_]())
Methodsβ
__init__β
def __init__(src: TileTensor[Self.dtype], warp_id: Int, lane_id: Int, *, m_anchor: Int = Int(0), k_anchor: Int = Int(0)) -> Self
Builds the loader.
Args:
- βsrc (
TileTensor[Self.dtype]): GMEM tile to source from. Pass the full A/B tensor and setm_anchor/k_anchorto the per-block origin, or pass a pre-sliced block tile with zero anchors (legacy behavior). The full-tensor form lets the SRD'snum_recordsbound the actual allocation rather than the block view β required for split-K kernels and for parity withTileLoaderLDSIm2col. - βwarp_id (
Int): Warp identifier within the loading warp group. - βlane_id (
Int): Lane identifier within the warp. - βm_anchor (
Int): M-coordinate (row dim) of the block origin in the loader's SRD coordinate system. Added tom_offsetat load time. Defaults to 0. - βk_anchor (
Int): K-coordinate (column dim) of the block origin. Added tok_offsetat load time. Defaults to 0.
load_tileβ
def load_tile(self, dst: TileTensor[Self.dtype, address_space=AddressSpace.SHARED], m_offset: Int, k_offset: Int)
Loads a half-tile from GMEM into SMEM dst via load_to_lds.
The effective GEMM-space coordinate is (m_anchor + m_offset, k_anchor + k_offset), so callers using the legacy
pre-sliced-block form (anchors=0) keep their address math
unchanged.
Args:
- βdst (
TileTensor[Self.dtype, address_space=AddressSpace.SHARED]): Destination TileTensor in SHARED (half-tile sized). - βm_offset (
Int): Row offset (M dim) within the block. - βk_offset (
Int): Column (K dim) offset within the block.
Was this page helpful?
Thank you! We'll create more content like this.
Thank you for helping us improve!