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

QuantStrategy

QuantStrategy​

class max.nn.moe.QuantStrategy(*args, **kwargs)

source

Bases: Protocol

Quantization strategy for MoE layers.

fused_silu_quantize()​

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

source

Applies gating and quantizes activations for the down proj.

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 matmul for routed experts.

Parameters:

Return type:

TensorValue

grouped_quantize()​

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

source

Quantizes activations with per-expert scales and padding.

Parameters:

Return type:

tuple[TensorValue, TensorValue]

prepare_weight_scales()​

prepare_weight_scales(gate_up, down, device)

source

Prepares weight scales for kernel consumption.

Parameters:

Return type:

tuple[TensorValue, TensorValue]

quantize()​

quantize(tensor, group_size)

source

Quantizes activations and returns (quantized, scales).

Parameters:

Return type:

tuple[TensorValue, TensorValue]