Skip to content

vllm.model_executor.layers.fused_moe.experts.cpu_moe

CPU fused MoE experts.

Classes:

Functions:

ArmCPUExpertsInt8

Bases: FusedMoEExpertsModular

Arm INT8 MoE with per-token activation and channelwise weight quantization.

ArmCPUUnquantizedExperts

Bases: CPUUnquantizedExperts

Arm NEON grouped-gemm unquantized MoE experts.

CPUExpertsFp8

Bases: FusedMoEExpertsModular

CPU FP8 W8A16 block-quantized modular MoE experts.

CPUExpertsFp8W8A8

Bases: FusedMoEExpertsModular

CPU FP8 W8A8 block-quantized modular MoE experts.

CPUExpertsInt4

Bases: FusedMoEExpertsModular

CPU INT4 W4A16 group-quantized modular MoE experts.

Weights are int4 (packed), activations are bf16/fp16. Internally uses int8 compute via fused_experts_cpu with INT4_W4A8.

CPUExpertsInt8

Bases: _CPUPaddedIntermediateMixin, FusedMoEExpertsModular

CPU INT8 W8A8 per-channel weight / dynamic per-token activation modular MoE experts.

Methods:

process_weights_after_loading(layer)

VNNI-prepack INT8 MoE weights for CPU kernel.

CPUExpertsMxfp4

Bases: FusedMoEExpertsModular

CPU MXFP4 W4A16 modular MoE experts.

CPUUnquantizedExperts

Bases: _CPUPaddedIntermediateMixin, FusedMoEExpertsModular

Portable vector grouped-gemm unquantized MoE experts.

PowerCPUExpertsInt8

Bases: FusedMoEExpertsModular

POWER VSX INT8 MoE with per-token activation and channelwise weight quant.

PowerCPUUnquantizedExperts

Bases: CPUUnquantizedExperts

PowerPC VSX grouped-gemm unquantized MoE experts.

X86CPUUnquantizedExperts

Bases: CPUUnquantizedExperts

x86 AMX grouped-gemm unquantized MoE experts.

ZenCPUExpertsInt8

Bases: FusedMoEExpertsModular

AMD Zen INT8 MoE with per-token activation and channelwise weight quantization, dispatched through zentorch.

_CPUPaddedIntermediateMixin

Zero-pads the per-partition MoE intermediate dim to the kernel's alignment before prepacking.

_pad_moe_intermediate(layer)

Zero-pad the per-partition MoE intermediate dim of both weights and the expert bias and w13 scale, see _padded_intermediate_size.

prepare_fp8_moe_layer_for_cpu(w13, w2)

VNNI-prepack FP8 MoE weights for CPU kernel.

prepare_fp8_w8a8_moe_layer_for_cpu(w13, w2, w13_scale, w2_scale)

Prepack FP8 W8A8 MoE weights for CPU kernel.

prepare_int4_moe_layer_for_cpu(w13_packed, w2_packed, w13_scale, w2_scale, quant_algo=CPUQuantAlgo.GPTQ, w13_zeros=None, w2_zeros=None)

Repack INT4 MoE weights via convert_weight_packed_scale_zp for CPU.

Parameters:

  • w13_packed

    (Tensor) –

    [E, K//8, 2*I] int32 (packed int4)

  • w2_packed

    (Tensor) –

    [E, I//8, K] int32 (packed int4)

  • w13_scale

    (Tensor) –

    [E, num_groups, 2*I] float16/bf16

  • w2_scale

    (Tensor) –

    [E, num_groups, K] float16/bf16

  • quant_algo

    (CPUQuantAlgo, default: GPTQ ) –

    CPUQuantAlgo.GPTQ or CPUQuantAlgo.AWQ

  • w13_zeros

    (Tensor | None, default: None ) –

    optional [E, num_groups, N//8] int32 packed zeros. If None, synthetic zeros are created for symmetric quant.

  • w2_zeros

    (Tensor | None, default: None ) –

    optional [E, num_groups, N//8] int32 packed zeros. If None, synthetic zeros are created for symmetric quant.

Returns:

prepare_mxfp4_moe_layer_for_cpu(w13, w2, w13_scale, w2_scale)

VNNI-prepack MXFP4 MoE weights and repack scales for CPU AMX kernel.

swigluoai_w13_interleave_perm(experts_cls, activation, two_i, device)

Index taking a half-split w13 [gate | up] to the interleaved order ZenDNN's swiglu_oai_mul expects, or None when no reorder is needed. Callers apply it along whichever axis holds their output channels.