vllm.model_executor.layers.fused_moe.oracle.fp8
¶
Classes:
-
Fp8MoEKernelOracle–FP8 MoE backend selection for one deployment configuration.
Functions:
-
convert_to_fp8_moe_kernel_format–Convert loaded FP8 MoE weights to the selected experts' layout.
-
make_fp8_moe_quant_config–Create FusedMoEQuantConfig for the specified FP8 Backend.
-
map_fp8_backend–Map a user-facing name to its FP8 backend enum value.
-
pad_tp_shard_to_weight_blocks–Pad the TP shard to whole checkpoint blocks, keeping scales rank-local.
-
refine_fp8_moe_block_shape–Compute a refined block shape for block-quantized FP8 MoE weights whose
-
resolve_fp8_moe_weight_block_shape–Return the TP-adapted block shape and refine factor:
-
select_fp8_moe_backend–Select the primary FP8 MoE backend
Fp8MoEKernelOracle
¶
_get_priority_backends(moe_config, weight_key, activation_key)
¶
Get available backends in priority order based on platform and config.
This function can be extended to become more complex as needed.
_resolve_fp8_backend(runner_backend)
¶
Resolve an explicit name, including its experts class for OOT names.
convert_to_fp8_moe_kernel_format(experts_cls, layer, w13, w2, w13_scale, w2_scale, w13_input_scale, w2_input_scale)
¶
Convert loaded FP8 MoE weights to the selected experts' layout.
make_fp8_moe_quant_config(fp8_backend, w1_scale, w2_scale, a1_scale, a2_scale, w1_bias=None, w2_bias=None, block_shape=None, per_act_token_quant=False, per_out_ch_quant=False, swiglu_limit=None, gemm1_alpha=None, gemm1_beta=None, layer=None)
¶
Create FusedMoEQuantConfig for the specified FP8 Backend. The FusedMoEQuantConfig holds the scales that are used at runtime by the Modular Kernel abstraction.
Note that certain kernels (e.g. Flashinfer CUTLASS) need special Quant configs to handle non-standard inputs to their kernel interfaces.
In a future PR, we will have this function should be a method of the modular kernel itself.
map_fp8_backend(runner_backend)
¶
Map a user-facing name to its FP8 backend enum value.
pad_tp_shard_to_weight_blocks(config, weight_block_size)
¶
Pad the TP shard to whole checkpoint blocks, keeping scales rank-local.
refine_fp8_moe_block_shape(config, weight_block_size)
¶
Compute a refined block shape for block-quantized FP8 MoE weights whose checkpoint blocks cannot be sharded exactly across TP ranks.
TP shards the intermediate dim of the expert weights, so a per-shard size that is not a multiple of the checkpoint's block size makes the checkpoint's block scales impossible to shard exactly. When a finer block size (>= 32) divides both the checkpoint blocks and all involved dims, the weight scales can be refined to that granularity at load time (a lossless upsampling, since the refined block divides the checkpoint block). Only Triton-based kernels can consume the refined block shape: they take it as a runtime argument, while the other backends require the native 128x128 blocks. The refined shape is encoded in the QuantKey used for backend selection, so backends that only support 128x128 blocks are rejected by the oracle automatically.
Returns the refined [block_n, block_k] shape, or None if no refinement is needed or possible.
resolve_fp8_moe_weight_block_shape(config, weight_block_size, activation_key, is_checkpoint_fp8_serialized)
¶
Return the TP-adapted block shape and refine factor: refine if kernels allow, else pad to the TP shard.
select_fp8_moe_backend(config, weight_key, activation_key, allow_vllm_cutlass=False)
¶
Select the primary FP8 MoE backend
Note: Shape-specific fallbacks may still occur at runtime.
Returns NONE and a placeholder experts class for requantization sources.