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).

Python class

Fp8Strategy

Fp8Strategy​

class max.nn.moe.Fp8Strategy(config, dtype)

source

Bases: object

FP8 quantization for MoE.

Parameters:

fused_silu_quantize()​

fused_silu_quantize(gate_up_projs, input_scales=None, expert_inputs=(), max_padded_M=0, activation=None)

source

Applies the gated activation and returns quantized activations.

The activation is plain graph ops feeding the row-bounded quantize, which the graph compiler fuses into a single kernel.

max_padded_M is accepted for QuantStrategy conformance; it only applies to the MX EP paths and is ignored here.

Parameters:

Return type:

tuple[TensorValue, TensorValue]

grouped_matmul()​

grouped_matmul(weight, weight_scales, expert_scales=None, expert_inputs=(), estimated_total_m=None, a_scales_max_padded_m=0)

source

Runs grouped FP8 matmul for the routed experts.

a_scales_max_padded_m is accepted for QuantStrategy conformance; it only applies to the MX EP paths and is ignored here.

Parameters:

Return type:

TensorValue

grouped_quantize()​

grouped_quantize(tensor, group_size, input_scale, expert_start, scales_offset, expert_ids)

source

Quantizes to FP8, stopping at the last row expert_start covers.

FP8 needs no per-expert scale padding, so this differs from quantize() only in what it skips: tensor is the EP receive buffer, sized for the worst-case dispatch, and expert_start ends at the row count this step actually received. The rows below that count quantize identically either way.

Parameters:

Return type:

tuple[TensorValue, TensorValue]

prepare_weight_scales()​

prepare_weight_scales(gate_up, down, device)

source

Passes FP8 weight scales through without reformatting.

Parameters:

Return type:

tuple[TensorValue, TensorValue]

quantize()​

quantize(tensor, group_size)

source

Quantizes activations to FP8 and returns (quantized, scales).

Parameters:

Return type:

tuple[TensorValue, TensorValue]