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

MatmulSwiGLU

struct MatmulSwiGLU

Fused GEMM+SwiGLU on SM100 for BF16 inputs.

Computes output[m, h] = silu(x @ W_gate[h, :]) * (x @ W_up[h, :]) in a single SM100 kernel. The weight b must be pre-permuted on its N axis so that gate/up column pairs are adjacent (sigma permutation: sigma(2i)=i, sigma(2i+1)=H+i where H=N/2).

Output shape is [M, H] where H = N/2, saving the slice+silu+mul elementwise kernel entirely.

Implemented traitsโ€‹

AnyType, ImplicitlyDeletable

Methodsโ€‹

executeโ€‹

static def execute[target: StringSlice[ImmStaticOrigin]](output: ManagedTensorSlice[IOSpec[_, _].Output, static_spec=output.static_spec], a: ManagedTensorSlice[IOSpec[_, _].Input, static_spec=a.static_spec], b: ManagedTensorSlice[IOSpec[_, _].Input, static_spec=b.static_spec], ctx: DeviceContext)