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

selective_scan_update_gpu

def selective_scan_update_gpu[kernel_dtype: DType, DSTATE: Int, state_out_LT: TensorLayout, output_LT: TensorLayout, state_in_LT: TensorLayout, x_LT: TensorLayout, dt_LT: TensorLayout, A_LT: TensorLayout, B_LT: TensorLayout, C_LT: TensorLayout, D_LT: TensorLayout, z_LT: TensorLayout, dt_bias_LT: TensorLayout](total_batch_dim: Int, batch: Int, dim: Int, group_size: Int, delta_softplus: Int8, state_out: TileTensor[kernel_dtype, state_out_LT, MutUntrackedOrigin], output: TileTensor[kernel_dtype, output_LT, MutUntrackedOrigin], state_in: TileTensor[kernel_dtype, state_in_LT, MutUntrackedOrigin], x: TileTensor[kernel_dtype, x_LT, MutUntrackedOrigin], dt: TileTensor[kernel_dtype, dt_LT, MutUntrackedOrigin], A: TileTensor[kernel_dtype, A_LT, MutUntrackedOrigin], B: TileTensor[kernel_dtype, B_LT, MutUntrackedOrigin], C: TileTensor[kernel_dtype, C_LT, MutUntrackedOrigin], D: TileTensor[kernel_dtype, D_LT, MutUntrackedOrigin], z: TileTensor[kernel_dtype, z_LT, MutUntrackedOrigin], dt_bias: TileTensor[kernel_dtype, dt_bias_LT, MutUntrackedOrigin], state_out_strides: IndexList[Int(3)], output_strides: IndexList[Int(2)], state_in_strides: IndexList[Int(3)], x_strides: IndexList[Int(2)], dt_strides: IndexList[Int(2)], A_strides: IndexList[Int(2)], B_strides: IndexList[Int(3)], C_strides: IndexList[Int(3)], D_strides: IndexList[Int(1)], z_strides: IndexList[Int(2)], dt_bias_strides: IndexList[Int(1)])

GPU kernel for selective scan update (single step).

Each thread processes one (batch, dim) pair. Reads initial state from state_in, writes updated state to state_out.

Parameters:

  • ​kernel_dtype (DType): Element type of the input and output tensors.
  • ​DSTATE (Int): Number of SSM state elements per (batch, dim) pair.
  • ​state_out_LT (TensorLayout): Memory layout of the state_out tensor.
  • ​output_LT (TensorLayout): Memory layout of the output tensor.
  • ​state_in_LT (TensorLayout): Memory layout of the state_in tensor.
  • ​x_LT (TensorLayout): Memory layout of the x input tensor.
  • ​dt_LT (TensorLayout): Memory layout of the dt time-step tensor.
  • ​A_LT (TensorLayout): Memory layout of the A recurrence matrix.
  • ​B_LT (TensorLayout): Memory layout of the B input projection tensor.
  • ​C_LT (TensorLayout): Memory layout of the C output projection tensor.
  • ​D_LT (TensorLayout): Memory layout of the D skip connection tensor.
  • ​z_LT (TensorLayout): Memory layout of the z gating tensor.
  • ​dt_bias_LT (TensorLayout): Memory layout of the dt_bias tensor.

Args:

Was this page helpful?