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 struct

SelectiveScanUpdate

struct SelectiveScanUpdate[delta_softplus: Bool = False]

Selective scan update operation for autoregressive inference.

Performs a single step of the SSM recurrence for incremental token generation.

Tensor Shapes: - state_out: (batch, dim, dstate) - Updated state output - output: (batch, dim) - Output tensor - state_in: (batch, dim, dstate) - Input state - x: (batch, dim) - Input tensor - dt: (batch, dim) - Time delta tensor - A: (dim, dstate) - State transition matrix - B: (batch, n_groups, dstate) - Input matrix - C: (batch, n_groups, dstate) - Output matrix - D: (dim,) - Skip connection (optional, can be empty) - z: (batch, dim) - Gating tensor (optional, can be empty) - dt_bias: (dim,) - Time delta bias (optional, can be empty)

Parameters​

  • ​delta_softplus (Bool): If True, applies softplus activation to delta values.

Implemented traits​

AnyType, ImplicitlyDestructible

Methods​

execute​

static execute[dtype: DType, target: StringSlice[StaticConstantOrigin]](state_out: ManagedTensorSlice[Output, static_spec=state_out.static_spec], output: ManagedTensorSlice[Output, static_spec=output.static_spec], state_in: ManagedTensorSlice[Input, static_spec=state_in.static_spec], x: ManagedTensorSlice[Input, static_spec=x.static_spec], dt: ManagedTensorSlice[Input, static_spec=dt.static_spec], A: ManagedTensorSlice[Input, static_spec=A.static_spec], B: ManagedTensorSlice[Input, static_spec=B.static_spec], C: ManagedTensorSlice[Input, static_spec=C.static_spec], D: ManagedTensorSlice[Input, static_spec=D.static_spec], z: ManagedTensorSlice[Input, static_spec=z.static_spec], dt_bias: ManagedTensorSlice[Input, static_spec=dt_bias.static_spec], ctx: DeviceContext)

shape​

static shape[dtype: DType](state_in: ManagedTensorSlice[Input, static_spec=state_in.static_spec], x: ManagedTensorSlice[Input, static_spec=x.static_spec], dt: ManagedTensorSlice[Input, static_spec=dt.static_spec], A: ManagedTensorSlice[Input, static_spec=A.static_spec], B: ManagedTensorSlice[Input, static_spec=B.static_spec], C: ManagedTensorSlice[Input, static_spec=C.static_spec], D: ManagedTensorSlice[Input, static_spec=D.static_spec], z: ManagedTensorSlice[Input, static_spec=z.static_spec], dt_bias: ManagedTensorSlice[Input, static_spec=dt_bias.static_spec]) -> Tuple[IndexList[3], IndexList[2]]

Returns:

Tuple[IndexList[3], IndexList[2]]