vllm.model_executor.layers.fused_moe.oracle.w4a8_int8
¶
Classes:
-
W4A8Int8MoEKernelOracle–W4A8 INT8 MoE backend selection for one deployment configuration.
Functions:
-
backend_to_kernel_cls–Map W4A8Int8MoeBackend to kernel class.
-
convert_to_w4a8_int8_moe_format–Pack INT4 MoE weights to KleidiAI format.
-
make_w4a8_int8_moe_kernel–Create FusedMoEKernel for W4A8 Int8 MoE.
-
make_w4a8_int8_moe_quant_config–Create FusedMoEQuantConfig for W4A8 Int8 MoE.
-
map_w4a8_int8_backend–Map user's MoEBackend to W4A8Int8MoeBackend.
-
pack_int4_weights_for_kleidi–Pack INT4 weights (stored as int8 in [-8,7]) to KleidiAI format.
-
select_w4a8_int8_moe_backend–Select the primary W4A8 Int8 MoE backend.
W4A8Int8MoEKernelOracle
¶
Bases: MoEKernelOracle[W4A8Int8MoeBackend]
W4A8 INT8 MoE backend selection for one deployment configuration.
Source code in vllm/model_executor/layers/fused_moe/oracle/w4a8_int8.py
_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.
Source code in vllm/model_executor/layers/fused_moe/oracle/w4a8_int8.py
backend_to_kernel_cls(backend)
¶
Map W4A8Int8MoeBackend to kernel class.
Source code in vllm/model_executor/layers/fused_moe/oracle/w4a8_int8.py
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:
-
tuple[Tensor, Tensor, Tensor, Tensor, Tensor | None, Tensor | None]–Tuple of (w13_packed, w2_packed) tensors
Source code in vllm/model_executor/layers/fused_moe/oracle/w4a8_int8.py
make_w4a8_int8_moe_kernel(moe_quant_config, moe_config, experts_cls, routing_tables=None)
¶
Create FusedMoEKernel for W4A8 Int8 MoE.
Parameters:
-
(moe_quant_config¶FusedMoEQuantConfig) –Quantization configuration
-
(moe_config¶FusedMoEConfig) –MoE configuration
-
(experts_cls¶type[FusedMoEExperts]) –Expert kernel class (should be CPUExpertsInt4)
-
(routing_tables¶tuple[Tensor, Tensor, Tensor] | None, default:None) –Optional routing tables for expert parallelism
Returns:
-
FusedMoEKernel–Configured FusedMoEKernel instance
Source code in vllm/model_executor/layers/fused_moe/oracle/w4a8_int8.py
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:
-
FusedMoEQuantConfig–FusedMoEQuantConfig with appropriate settings for W4A8 Int8
Source code in vllm/model_executor/layers/fused_moe/oracle/w4a8_int8.py
map_w4a8_int8_backend(runner_backend)
¶
Map user's MoEBackend to W4A8Int8MoeBackend.
Source code in vllm/model_executor/layers/fused_moe/oracle/w4a8_int8.py
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
Source code in vllm/model_executor/layers/fused_moe/oracle/w4a8_int8.py
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:
-
tuple[W4A8Int8MoeBackend, type[FusedMoEExperts]]–Tuple of (backend, kernel_class)