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
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, has_variable_topk: Bool = False]
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). - βhas_variable_topk (
Bool): WhenTrue, the sparse top-k length is read per batch fromsparse_topk_lengthsinstead of using the fixed stride (defaults toFalse).
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):
Implemented traitsβ
AnyType,
Copyable,
ImplicitlyCopyable,
ImplicitlyDeletable,
Movable,
RegisterPassable,
TrivialRegisterPassable
Methodsβ
__init__β
def __init__(k: KVLUTType, valid_length: Pointer[Scalar[ValidLengthType.dtype], ImmutAnyOrigin, _safe=False], max_seq_len: Int, num_partitions: Int, batch_size: Int, sparse_indices_stride: Int = Int(0), sparse_topk_lengths: OptionalReg[Pointer[Int32, MutAnyOrigin, _safe=False]] = None, sparse_extra_indices_stride: Int = Int(0), sparse_extra_topk_lengths: OptionalReg[Pointer[Int32, MutAnyOrigin, _safe=False]] = None) -> Self
cache_lenβ
start_posβ
q_row_offset_atβ
out_row_offset_atβ
q_token_idx_atβ
Was this page helpful?
Thank you! We'll create more content like this.
Thank you for helping us improve!