Skip to content

vllm.model_executor.layers.fused_moe.experts.cpu_int4_moe

CPU INT4 W4A8 dynamic quantized fused MoE experts.

Classes:

  • CPUExpertsInt4 –

    CPU INT4 W4A8 dynamic quantized monolithic MoE experts.

CPUExpertsInt4

Bases: FusedMoEExpertsMonolithic

CPU INT4 W4A8 dynamic quantized monolithic MoE experts.

Uses the dynamic_4bit_int_moe kernel for efficient 4-bit weight, 8-bit activation MoE inference on CPU.

Methods:

  • apply –

    Apply the monolithic 4-bit INT MoE forward pass.

  • supports_expert_map –

    Expert parallelism not yet supported.

Attributes:

expects_unquantized_inputs property

Expects unquantized inputs (quantization happens in kernel).

_activation_kind(activation) staticmethod

Convert MoEActivation to kernel activation kind integer.

Returns:

  • int –

    0 = SwiGLU_Gu (SiLU(g)*u)

  • int –

    1 = SwiGLU_Ug (SiLU(u)*g)

  • int –

    2 = SiLU

_supports_activation(activation) staticmethod

Supports SiLU and SwiGLU variants.

_supports_no_act_and_mul() staticmethod

Does not support no_act_and_mul (requires SwiGLU or SiLU).

_supports_parallel_config(moe_parallel_config) staticmethod

Currently does not support expert parallelism.

_supports_quant_scheme(weight_key, activation_key) staticmethod

Supports INT4 weights with INT8 dynamic activations.

This is W4A8 with: - Weights: 4-bit integer (stored as int8, packed to uint8 nibbles) Can be channel-wise or group-wise quantization - Activations: dynamic per-token 8-bit integer quantization

_supports_router_logits_dtype(router_logits_dtype, routing_method) staticmethod

Accepts any router logits dtype.

_supports_routing_method(routing_method, weight_key, activation_key) staticmethod

Supports standard routing methods.

apply(hidden_states, w1, w2, router_logits, activation, global_num_experts, expert_map, a1q_scale, apply_router_weight_on_input, num_expert_group=None, e_score_correction_bias=None, routed_scaling_factor=None, topk_group=None, routing_replay_out=None)

Apply the monolithic 4-bit INT MoE forward pass.

Parameters:

  • hidden_states

    (Tensor) –

    Input tensor [num_tokens, hidden_size]

  • w1

    (Tensor) –

    Packed w13 weights (w1+w3 gated weights)

  • w2

    (Tensor) –

    Packed w2 weights (down projection)

  • router_logits

    (Tensor) –

    Router output logits [num_tokens, num_experts]

  • activation

    (MoEActivation) –

    Activation function type

  • global_num_experts

    (int) –

    Total number of experts

  • expert_map

    (Tensor | None) –

    Expert mapping for EP (not supported)

  • a1q_scale

    (Tensor | None) –

    Activation quantization scale (not used, dynamic)

  • apply_router_weight_on_input

    (bool) –

    Whether to apply routing on input

  • num_expert_group

    (int | None, default: None ) –

    For grouped topk

  • e_score_correction_bias

    (Tensor | None, default: None ) –

    Bias for expert scores

  • routed_scaling_factor

    (float | None, default: None ) –

    Scaling factor for routing

  • topk_group

    (int | None, default: None ) –

    Group size for topk

  • routing_replay_out

    (Tensor | None, default: None ) –

    Unused; this kernel does not capture routing

Returns:

  • Tensor –

    Output tensor after MoE computation

supports_expert_map()

Expert parallelism not yet supported.