For the complete documentation index, see llms.txt. Markdown versions of all pages are available by appending .md to any URL (e.g. /get-started.md).
Mojo struct
OffsetPosition
struct OffsetPosition[config: MLA_SM100_Decode_Config, KVLUTType: MHAOperand, ragged: Bool, is_cache_length_accurate: Bool, ValidLengthType: OptionalPointer, decoding_warp_split_k: Bool = False, sparse: Bool = False, has_extra_kv: Bool = False, TopkLengthsPtrType: OptionalPointer = NullPointer[.int32]]
Computes and stores per-CTA row offsets and KV key ranges for the decode kernel.
Parameters
- config (
MLA_SM100_Decode_Config): Decode config supplying tile sizes and head counts used to compute Q and output row offsets. - KVLUTType (
MHAOperand):MHAOperandproviding the KV cache tensor and itscache_lengthaccessor. - ragged (
Bool): WhenTrue, the valid-lengths tensor is interpreted as input row offsets enabling ragged batching. - is_cache_length_accurate (
Bool): WhenFalse, the kernel adds the local sequence length to the cache length to compute the total key count. - ValidLengthType (
OptionalPointer):OptionalPointertype wrapping the per-batch valid-sequence-length tensor. - decoding_warp_split_k (
Bool): WhenTrue, the CTA processes a split-K partition of the KV cache (defaults toFalse). - sparse (
Bool): WhenTrue, the kernel iterates over a sparse subset of tokens selected byd_indicesinstead of the full KV cache (defaults toFalse). - has_extra_kv (
Bool): WhenTrue, sparse attention additionally attends to a separate extra-KV cache (defaults toFalse). - TopkLengthsPtrType (
OptionalPointer):OptionalPointertype of the per-batch sparse top-k lengths. When non-null, the top-k length is read per batch fromsparse_topk_lengthsinstead of using the fixed stride (defaults toNullPointer).
Fields
- seq_len (
Int): - max_seq_len (
Int): - num_keys (
Int): - q_row_offset (
Int): - out_row_offset (
Int): - split_idx (
Int): - batch_idx (
Int): - kv_start_row (
Int): - num_keys_this_split (
Int): - q_token_idx (
Int): - actual_num_keys (
Int):
Implemented traits
AnyType,
Copyable,
Deinitable,
ImplicitlyCopyable,
Movable,
RegisterPassable,
TrivialRegisterPassable
comptime members
has_variable_topk
comptime has_variable_topk = not TopkLengthsPtrType.is_null.__bool__()
Methods
__init__
def __init__(k: KVLUTType, valid_length: Pointer[Scalar[ValidLengthType.dtype], ImmutAnyOrigin], max_seq_len: Int, num_partitions: Int, batch_size: Int, sparse_indices_stride: Int = Int(0), sparse_topk_lengths: TopkLengthsPtrType = null_pointer[TopkLengthsPtrType](), sparse_extra_indices_stride: Int = Int(0), sparse_extra_topk_lengths: TopkLengthsPtrType = unread_pointer[TopkLengthsPtrType]()) -> Self