vllm.model_executor.layers.fused_moe.oracle.mxfp4
¶
Classes:
-
Mxfp4MoEKernelOracle–MXFP4 MoE backend selection for one deployment configuration.
Functions:
-
convert_gpt_oss_weight_to_mxfp4_moe_kernel_format–Convert loaded weights into backend-specific kernel format.
-
convert_weight_to_mxfp4_moe_kernel_format–Convert loaded weights into backend-specific kernel format.
-
make_mxfp4_moe_kernel–Create a FusedMoEKernel for the given MXFP4 backend.
-
make_mxfp4_moe_quant_config–Create a FusedMoEQuantConfig for the given MXFP4 backend.
-
map_mxfp4_backend–Map a moe_backend string to its candidate Mxfp4MoeBackends.
-
mxfp4_round_up_hidden_size_and_intermediate_size–Round up hidden_size and intermediate_size based on backend requirements.
-
select_deepseek_v4_mxfp4_moe_backend–Select the MXFP4 MoE backend with MXFP8 activation as top priority.
-
select_mxfp4_moe_backend–Select the primary MXFP4 MoE backend.
-
store_params_in_triton–Back each loaded param and its triton_kernels tensor by one storage, so the
-
triton_weight–The triton_kernels tensor stored for weight
name, else the param.
Mxfp4MoEKernelOracle
¶
Bases: MoEKernelOracle[Mxfp4MoeBackend]
MXFP4 MoE backend selection for one deployment configuration.
_applies_requested_activation(backend, requested_activation_key)
¶
Whether backend quantizes activations to the requested key itself
rather than to a key of its own.
_backend_activation_key(backend)
¶
Map backend to its activation key (FP8, MXFP8, or None for BF16).
_filter_by_activation(backends, requested_activation_key)
¶
Pick variants matching requested_activation_key, followed by BF16
variants as a higher-precision fallback unless VLLM_STRICT_QUANT_SCHEME
forbids it; without one, prefer BF16 if the list has any, else keep the
list as-is so explicit non-BF16 picks (e.g. the _afp8 aliases) still
land.
_get_priority_backends()
¶
Get available backends in priority order. SM100+ prefers DeepGEMM FP4 /
TRTLLM MXFP8; SM90 falls through to Humming or Marlin (the
backend-level is_supported_config check filters by device capability).
_get_priority_backends_for_gpt_oss()
¶
Available backends in priority order, BF16-act variant before activation-quantized variant within each vendor family.
_humming_input_schema(model_activation_key)
¶
Humming input schema for the checkpoint activation combined with the user override, or None to keep Humming's default (BF16 or the VLLM_HUMMING_INPUT_QUANT_CONFIG env override, which wins).
_interleave_gate_up_rows(t)
¶
Repack [E, 2n, X] from [all gates | all ups] to [g0, u0, g1, u1, ...].
_requested_kernel_cls(backend, config)
¶
Kernel classes for an explicitly requested backend. The LoRA-aware TRT-LLM experts are opt-in: "auto" keeps its current LoRA selection.
_resolve_activation_key(model_activation_key)
¶
Apply --quantization-config.moe.activation to the checkpoint's
activation key. An explicit override wins, null included (BF16).
_swizzle_cutlass_mxfp4_scales(scale)
¶
Swizzle [E, N, K // 32] block scales into the CUTLASS tiled layout.
_user_moe_activation_override()
¶
User's MoE activation override from quantization_config, or None.
_user_moe_activation_override_is_set()
¶
Whether the user set the MoE activation, explicit null included.
_validate_mxfp4_experts_config(experts_cls, moe_config, mxfp4_backend)
¶
Fail closed when a caller bypasses the oracle and picks experts directly.
convert_gpt_oss_weight_to_mxfp4_moe_kernel_format(mxfp4_backend, layer, w13_weight, w2_weight, w13_weight_scale, w2_weight_scale, w13_bias=None, w2_bias=None, w13_input_scale=None, w2_input_scale=None, _cache_permute_indices=None)
¶
Convert loaded weights into backend-specific kernel format.
convert_weight_to_mxfp4_moe_kernel_format(mxfp4_backend, layer, w13_weight, w2_weight, w13_weight_scale, w2_weight_scale, w13_bias=None, w2_bias=None, _cache_permute_indices=None, activation=None, use_separated_a4w4=False, activation_key=None)
¶
Convert loaded weights into backend-specific kernel format.
Supports CUTLASS, DeepGEMM, FlashInfer, TRTLLM MXFP8, Triton and Marlin backends.
make_mxfp4_moe_kernel(moe_quant_config, moe_config, experts_cls, mxfp4_backend, routing_tables=None)
¶
Create a FusedMoEKernel for the given MXFP4 backend.
make_mxfp4_moe_quant_config(mxfp4_backend, w1_scale, w2_scale, gemm1_alpha=None, gemm1_beta=None, swiglu_limit=None, w1_bias=None, w2_bias=None, a1_scale=None, a2_scale=None, layer=None)
¶
Create a FusedMoEQuantConfig for the given MXFP4 backend.
map_mxfp4_backend(runner_backend)
¶
Map a moe_backend string to its candidate Mxfp4MoeBackends.
Vendor families return all activation variants; the caller picks one
via activation_key and is_supported_config.
mxfp4_round_up_hidden_size_and_intermediate_size(backend, hidden_size, intermediate_size, activation=None)
¶
Round up hidden_size and intermediate_size based on backend requirements.
select_deepseek_v4_mxfp4_moe_backend(config)
¶
Select the MXFP4 MoE backend with MXFP8 activation as top priority.
Falls back through BF16 and other backends.
Returns NONE and a placeholder experts class for requantization sources.
select_mxfp4_moe_backend(config, activation_key=None)
¶
Select the primary MXFP4 MoE backend.
Parameters:
-
(config¶FusedMoEConfig) –MoE configuration
-
(activation_key¶QuantKey | None, default:None) –Optional activation quantization key declared by the checkpoint. Backends that match it are preferred, with BF16 activation backends as a fallback. Use kFp8StaticTensorSym for W4A8 scheme.
Note: Shape-specific fallbacks may still occur at runtime.
Returns NONE and a placeholder experts class for requantization sources.
store_params_in_triton(layer, **tensors)
¶
Back each loaded param and its triton_kernels tensor by one storage, so the param keeps its loaded bytes without a second copy of the data.
triton_weight(layer, name)
¶
The triton_kernels tensor stored for weight name, else the param.