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 function
ssd_combined_gpu
def ssd_combined_gpu[kernel_dtype: DType, DSTATE: Int, output_LT: TensorLayout, x_LT: TensorLayout, out_z_LT: TensorLayout, residual_LT: TensorLayout, u_LT: TensorLayout, delta_LT: TensorLayout, A_LT: TensorLayout, B_LT: TensorLayout, C_LT: TensorLayout, D_LT: TensorLayout, z_LT: TensorLayout, delta_bias_LT: TensorLayout, gamma_LT: TensorLayout](total_batch_dim: Int32, batch: Int32, dim: Int32, seqlen: Int32, group_size: Int32, delta_softplus: Int8, output: TileTensor[kernel_dtype, output_LT, MutAnyOrigin], x: TileTensor[kernel_dtype, x_LT, MutAnyOrigin], out_z: TileTensor[kernel_dtype, out_z_LT, MutAnyOrigin], residual: TileTensor[kernel_dtype, residual_LT, MutAnyOrigin], u: TileTensor[kernel_dtype, u_LT, MutAnyOrigin], delta: TileTensor[kernel_dtype, delta_LT, MutAnyOrigin], A: TileTensor[kernel_dtype, A_LT, MutAnyOrigin], B: TileTensor[kernel_dtype, B_LT, MutAnyOrigin], C: TileTensor[kernel_dtype, C_LT, MutAnyOrigin], D: TileTensor[kernel_dtype, D_LT, MutAnyOrigin], z: TileTensor[kernel_dtype, z_LT, MutAnyOrigin], delta_bias: TileTensor[kernel_dtype, delta_bias_LT, MutAnyOrigin], gamma: TileTensor[kernel_dtype, gamma_LT, MutAnyOrigin], epsilon: Scalar[kernel_dtype], weight_offset: Scalar[kernel_dtype])
GPU kernel for SSD combined operation.
Combines selective scan with normalization and residual connection. Performs: norm(residual + selective_scan(input))
Parameters:
- kernel_dtype (
DType): Element type of the input and output tensors. - DSTATE (
Int): Number of SSM state elements per (batch, dim) pair. - output_LT (
TensorLayout): Memory layout of theoutputtensor. - x_LT (
TensorLayout): Memory layout of thexcheckpoint tensor. - out_z_LT (
TensorLayout): Memory layout of theout_zgated output tensor. - residual_LT (
TensorLayout): Memory layout of theresidualtensor. - u_LT (
TensorLayout): Memory layout of theuinput tensor. - delta_LT (
TensorLayout): Memory layout of thedeltatime-step tensor. - A_LT (
TensorLayout): Memory layout of theArecurrence matrix. - B_LT (
TensorLayout): Memory layout of theBinput projection tensor. - C_LT (
TensorLayout): Memory layout of theCoutput projection tensor. - D_LT (
TensorLayout): Memory layout of theDskip connection tensor. - z_LT (
TensorLayout): Memory layout of thezgating tensor. - delta_bias_LT (
TensorLayout): Memory layout of thedelta_biastensor. - gamma_LT (
TensorLayout): Memory layout of thegammanormalization scale tensor.
Args:
- total_batch_dim (
Int32): Total number of (batch, dim) pairs launched, equal tobatch * dim, used for thread bounds checking. - batch (
Int32): Number of sequences processed in parallel. - dim (
Int32): Hidden dimension, equal to the number of channels per sequence position. - seqlen (
Int32): Number of timesteps in each sequence. - group_size (
Int32): Number of dims per group; dims in the same group shareBandCinputs. - delta_softplus (
Int8): Nonzero appliessoftplustodeltabefore the scan recurrence. - output (
TileTensor[kernel_dtype, output_LT, MutAnyOrigin]): Output tensor of shape(batch, dim, seqlen)holding the normalized result, written. - x (
TileTensor[kernel_dtype, x_LT, MutAnyOrigin]): Checkpoint tensor of shape(batch, dim, n_chunks, 2*DSTATE)storing per-chunk cumulativeAandBvalues, written. - out_z (
TileTensor[kernel_dtype, out_z_LT, MutAnyOrigin]): Gated output tensor of shape(batch, dim, seqlen)holdingoutput * silu(z), written whenzis present. - residual (
TileTensor[kernel_dtype, residual_LT, MutAnyOrigin]): Residual input tensor of shape(batch, dim, seqlen)added to the scan output before normalization, read. - u (
TileTensor[kernel_dtype, u_LT, MutAnyOrigin]): Selective scan input tensor of shape(batch, dim, seqlen), read. - delta (
TileTensor[kernel_dtype, delta_LT, MutAnyOrigin]): Time-step tensor of shape(batch, dim, seqlen), read. - A (
TileTensor[kernel_dtype, A_LT, MutAnyOrigin]): SSM recurrence matrix of shape(dim, DSTATE), read. - B (
TileTensor[kernel_dtype, B_LT, MutAnyOrigin]): SSM input projection of shape(batch, n_groups, DSTATE, seqlen), read. - C (
TileTensor[kernel_dtype, C_LT, MutAnyOrigin]): SSM output projection of shape(batch, n_groups, DSTATE, seqlen), read. - D (
TileTensor[kernel_dtype, D_LT, MutAnyOrigin]): Skip connection vector of shape(dim,), read; added asD * uto the output when present. - z (
TileTensor[kernel_dtype, z_LT, MutAnyOrigin]): Gating tensor of shape(batch, dim, seqlen), read; gates the output viasilu(z)when present. - delta_bias (
TileTensor[kernel_dtype, delta_bias_LT, MutAnyOrigin]): Bias vector of shape(dim,), read; added todeltabeforesoftpluswhen present. - gamma (
TileTensor[kernel_dtype, gamma_LT, MutAnyOrigin]): Normalization scale vector of shape(dim,), read; scales the combined residual and scan output. - epsilon (
Scalar[kernel_dtype]): Small constant for numerical stability in normalization. - weight_offset (
Scalar[kernel_dtype]): Scalar offset added togammabefore scaling the combined output.