Skip to content

vllm.model_executor.layers.fused_moe.oracle.w4a8_int8

Classes:

Functions:

W4A8Int8MoEKernelOracle

Bases: MoEKernelOracle[W4A8Int8MoeBackend]

W4A8 INT8 MoE backend selection for one deployment configuration.

_get_priority_backends(moe_config)

Get available backends in priority order based on platform and config.

Currently only CPU INT4 backend is available for W4A8 INT8 MoE.

backend_to_kernel_cls(backend)

Map W4A8Int8MoeBackend to kernel class.

convert_to_w4a8_int8_moe_format(w13_weight, w2_weight, w13_weight_scale, w2_weight_scale, group_size, w13_bias=None, w2_bias=None)

Pack INT4 MoE weights to KleidiAI format.

This function packs the INT4 weights (stored as int8 values) into the format expected by the KleidiAI dynamic_4bit_int_moe kernel.

Parameters:

  • w13_weight

    (Tensor) –

    [E, 2*IN, H] int8 tensor (int4 values in [-8,7])

  • w2_weight

    (Tensor) –

    [E, H, IN] int8 tensor (int4 values in [-8,7])

  • w13_weight_scale

    (Tensor) –

    [E, 2*IN, H/g or 1] scale tensor

  • w2_weight_scale

    (Tensor) –

    [E, H, IN/g or 1] scale tensor

  • group_size

    (int) –

    Quantization group size (-1 for channel-wise)

  • w13_bias

    (Tensor | None, default: None ) –

    Optional [E, 2*IN] bias tensor

  • w2_bias

    (Tensor | None, default: None ) –

    Optional [E, H] bias tensor

Returns:

make_w4a8_int8_moe_kernel(moe_quant_config, moe_config, experts_cls, routing_tables=None)

Create FusedMoEKernel for W4A8 Int8 MoE.

Parameters:

Returns:

make_w4a8_int8_moe_quant_config(block_shape=None)

Create FusedMoEQuantConfig for W4A8 Int8 MoE.

Parameters:

  • block_shape

    (tuple[int, int] | None, default: None ) –

    Quantization block shape (row, col). For channel-wise: (-1, 1) or None For group-wise: (1, group_size)

Returns:

map_w4a8_int8_backend(runner_backend)

Map user's MoEBackend to W4A8Int8MoeBackend.

pack_int4_weights_for_kleidi(int4_as_int8, scales, bias, in_features, out_features, group_size)

Pack INT4 weights (stored as int8 in [-8,7]) to KleidiAI format.

Parameters:

  • int4_as_int8

    (Tensor) –

    [out, in] int8 tensor with values in [-8, 7]

  • scales

    (Tensor) –

    [out, in//group_size] or [out, 1] for channel-wise

  • bias

    (Tensor | None) –

    [out] optional bias

  • in_features

    (int) –

    Input dimension

  • out_features

    (int) –

    Output dimension

  • group_size

    (int) –

    Quantization group size (-1 for channel-wise)

Returns:

  • Tensor –

    Packed weight tensor in KleidiAI format

select_w4a8_int8_moe_backend(config, weight_key, activation_key)

Select the primary W4A8 Int8 MoE backend.

Parameters:

  • config

    (FusedMoEConfig) –

    MoE configuration

  • weight_key

    (QuantKey | None) –

    Weight quantization key (should be one of kInt4W4A8Static*)

  • activation_key

    (QuantKey | None) –

    Activation quantization key (currently unused for W4A8)

Returns:

  • W4A8Int8MoeBackend –

    Tuple of (backend, kernel_class); NONE and a placeholder experts class

  • type[FusedMoEExperts] –

    for requantization sources, which have no kernel.