IMPORTANT: To view this page as Markdown, append `.md` to the URL (e.g. /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. /get-started.md).

Mojo struct

Struct_ep_fused_silu_mxfp4

struct Struct_ep_fused_silu_mxfp4

Registers the ep.fused_silu.mxfp4 graph op with the graph compiler.

Implemented traitsโ€‹

AnyType, Deinitable, Movable

Methodsโ€‹

executeโ€‹

static def execute[quant_dtype: DType, scales_dtype: DType, input_dtype: DType, target: StringSpan[ImmStaticOrigin], *, fuse_a_scale_preshuffle: Bool = False, max_padded_M: Int = Int(0), clamp_activation: Bool = False, trace_name: StringSpan[ImmStaticOrigin] = StringSpan("ep.fused_silu.mxfp4")](output: ManagedTensorSlice[IOSpec[_, _].Output, static_spec=output.static_spec], scales: ManagedTensorSlice[IOSpec[_, _].Output, static_spec=scales.static_spec], input: ManagedTensorSlice[IOSpec[_, _].Input, static_spec=input.static_spec], row_offsets: ManagedTensorSlice[IOSpec[_, _].Input, static_spec=row_offsets.static_spec], alpha: Float32, limit: Float32, context: DeviceContext)

Execute the Expert Parallelism fused SILU kernel with MX quantization.

Shared body for ep.fused_silu.mxfp4 and ep.fused_silu.mxfp8: fused_silu_mx_kernel takes its element packing from quant_dtype. trace_name only labels the op in traces; it is defaulted and no caller sets it through MOGG's parameters dict, so the mxfp8 registration overrides it directly at the Mojo call site.

This function launches the shared fused_silu_mx_kernel to perform the SILU operation for all the MLPs in the EP MoE module.

This kernel will read the row offsets to determine the actual number of received tokens in the input tensor, and then only perform the SILU operation on the received tokens. Once the SILU operation is performed, the output will be quantized to the MXFP4 or MXFP8 format.

When fuse_a_scale_preshuffle=True (KS64 fusion), the kernel writes the E8M0 scale directly into the grouped matmul's per-expert fixed-stride scale_4d slot layout (slot stride max_padded_M * K_SCALES), so the standalone preshuffle_grouped_scale_4d_gpu can be omitted from the critical path. The scales output tensor must then have shape [n_local_experts * max_padded_M, K_SCALES].