IMPORTANT: To view this page as Markdown, append `.md` to the URL (e.g. /max/get-started.md). For the complete documentation index, see llms.txt.
Skip to main content
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 function

mamba2_ssd_chunk_scan_varlen_fwd_gpu

def mamba2_ssd_chunk_scan_varlen_fwd_gpu[kernel_dtype: DType, DSTATE: Int, x_LT: TensorLayout, dt_LT: TensorLayout, A_LT: TensorLayout, B_LT: TensorLayout, C_LT: TensorLayout, D_LT: TensorLayout, dt_bias_LT: TensorLayout, initial_states_LT: TensorLayout, y_LT: TensorLayout, final_states_LT: TensorLayout, query_start_loc_LT: TensorLayout, has_initial_state_LT: TensorLayout, Storage: TensorStorage = PointerStorage](nheads: Int, head_dim: Int, ngroups: Int, nheads_ngroups_ratio: Int, batch: Int, dt_softplus: Int8, x: TileTensor[kernel_dtype, x_LT, MutUntrackedOrigin, Storage=Storage], dt: TileTensor[kernel_dtype, dt_LT, MutUntrackedOrigin, Storage=Storage], A: TileTensor[kernel_dtype, A_LT, MutUntrackedOrigin, Storage=Storage], B: TileTensor[kernel_dtype, B_LT, MutUntrackedOrigin, Storage=Storage], C: TileTensor[kernel_dtype, C_LT, MutUntrackedOrigin, Storage=Storage], D: TileTensor[kernel_dtype, D_LT, MutUntrackedOrigin, Storage=Storage], dt_bias: TileTensor[kernel_dtype, dt_bias_LT, MutUntrackedOrigin, Storage=Storage], initial_states: TileTensor[DType.float32, initial_states_LT, MutUntrackedOrigin, Storage=Storage], y: TileTensor[kernel_dtype, y_LT, MutUntrackedOrigin, Storage=Storage], final_states: TileTensor[DType.float32, final_states_LT, MutUntrackedOrigin, Storage=Storage], query_start_loc: TileTensor[DType.int32, query_start_loc_LT, MutUntrackedOrigin, Storage=Storage], has_initial_state: TileTensor[DType.bool, has_initial_state_LT, MutUntrackedOrigin, Storage=Storage], x_strides: IndexList[Int(3)], dt_strides: IndexList[Int(2)], A_strides: IndexList[Int(1)], B_strides: IndexList[Int(3)], C_strides: IndexList[Int(3)], D_strides: IndexList[Int(1)], dt_bias_strides: IndexList[Int(1)], initial_states_strides: IndexList[Int(4)], y_strides: IndexList[Int(3)], final_states_strides: IndexList[Int(4)])

GPU kernel: Mamba-2 SSD varlen prefill scan, one thread per (head, channel).

Grid: (ceildiv(head_dim, BLOCK), nheads, batch). Each thread owns one (b, h, p) channel, carries the dstate-vector state in registers, and walks its sequence [seq_start, seq_end) sequentially.