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
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: Int, batch: Int, dim: Int, seqlen: Int, group_size: Int, 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 (
Int): Total number of (batch, dim) pairs launched, equal tobatch * dim, used for thread bounds checking. - βbatch (
Int): Number of sequences processed in parallel. - βdim (
Int): Hidden dimension, equal to the number of channels per sequence position. - βseqlen (
Int): Number of timesteps in each sequence. - βgroup_size (
Int): 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.
Was this page helpful?
Thank you! We'll create more content like this.
Thank you for helping us improve!