Mojo trait
MHAOperand
This serves as the trait to support arguments to our MHA kernel.
Implemented traits
AnyType
,
UnknownDestructibility
Aliases
__del__is_trivial
alias __del__is_trivial
A flag (often compiler generated) to indicate whether the implementation of __del__
is trivial.
The implementation of __del__
is considered to be trivial if:
- The struct has a compiler-generated trivial destructor and all its fields
have a trivial
__del__
method.
In practice, it means that the __del__
can be considered as no-op.
dtype
alias dtype
Required methods
block_paged_ptr
block_paged_ptr[tile_size: Int](self: _Self, batch_idx: UInt32, start_tok_idx: UInt32, head_idx: UInt32, head_dim_idx: UInt32 = 0) -> UnsafePointer[Scalar[_Self.dtype]]
Returns:
cache_length
cache_length(self: _Self, batch_idx: Int) -> Int
Returns the length of the cache for a given batch index.
Returns:
max_context_length
max_context_length(self: _Self) -> UInt32
Returns the maximum cache length in a given batch index.
Returns:
row_idx
row_idx(self: _Self, batch_idx: UInt32, start_tok_idx: UInt32) -> UInt32
Returns the row idx when viewing the memory as a matrix.
Returns:
col_idx
col_idx(self: _Self, head_idx: UInt32) -> UInt32
Returns the col idx when viewing the memory as a matrix.
Returns:
create_tma_tile
create_tma_tile[tile_m: Int, tile_n: Int, swizzle_mode: TensorMapSwizzle, *, is_k_major: Bool](self: _Self, ctx: DeviceContext) -> TMATensorTile[_Self.dtype, tile_layout_k_major[_Self.dtype, tile_m, tile_n, swizzle_mode]() if is_k_major else tile_layout_mn_major[_Self.dtype, tile_n, tile_m, swizzle_mode](), _tma_desc_tile_layout[_Self.dtype, 2, IndexList[2, DType.int64](tile_m, tile_n, Tuple[]()), is_k_major, swizzle_mode](), is_k_major]
Creates a TMA tile for efficient GPU memory transfers.
Returns:
TMATensorTile
Was this page helpful?
Thank you! We'll create more content like this.
Thank you for helping us improve!