vllm.model_executor.layers.fused_moe.oracle
¶
Modules:
-
base–Abstract base class for MoE kernel oracles.
-
fp8– -
int8– -
int_wna16– -
mxfp4– -
mxfp8– -
nvfp4– -
unquantized– -
w4a8_int8–
Classes:
-
MoEKernelOracle–Abstract base for MoE kernel-selection oracles.
-
UnquantizedMoEKernelOracle–Class-based view of the unquantized MoE kernel oracle.
MoEKernelOracle
¶
Abstract base for MoE kernel-selection oracles.
Concrete oracles provide name and backend_to_kernel_cls today; the
remaining methods below are the #37753 migration target and are still
implemented per module, so they are declared but not enforced.
Methods:
-
backend_enum_cls–Return the concrete
Enumclass enumerating this oracle's -
backend_to_kernel_cls–Map a backend enum value to its concrete
FusedMoEExperts -
convert_to_kernel_format–Shuffle weights into the layout expected by
backend. -
get_oot_backends–Return platform registrations for an oracle that supports them.
-
get_priority_backends–Return platform-appropriate backends in priority order for
-
make_kernel–Construct the
FusedMoEKernel(Prepare/Finalize + Experts -
make_log_backend–Message for the backend a select loop settled on.
-
make_log_unsupported–Message for a backend that does not support the configuration.
-
make_quant_config–Build a
FusedMoEQuantConfigfor this oracle. -
map_backend–Map a user-facing
MoEBackend(from the runner config) to -
maybe_skip_for_requantization_source–Skip backend selection for online requantization sources.
-
return_or_raise–Return
backendwith its first supported kernel class, or raise. -
select_backend–Primary entry point: choose the best supported backend for
-
select_oot_backend–Select a registered backend, or let the caller try in-tree selection.
-
try_backend–Probe
backend's candidate kernel classes, first supported wins.
backend_enum_cls()
¶
Return the concrete Enum class enumerating this oracle's
backends (e.g. UnquantizedMoeBackend, Fp8MoeBackend).
backend_to_kernel_cls(backend)
¶
Map a backend enum value to its concrete FusedMoEExperts
subclasses, in selection priority order.
Implementations must forward to the module-level function at call time,
not alias it with = staticmethod(fn), which snapshots it at import.
convert_to_kernel_format(backend, moe_config, w13_weight, w2_weight)
¶
Shuffle weights into the layout expected by backend.
Default implementation returns the inputs unchanged. Oracles
whose backends need weight permutation should override this
(e.g. UnquantizedMoEKernelOracle handles AITER and FlashInfer
layouts).
moe_config carries MoE-layer state (e.g. is_act_and_mul)
that the conversion needs without coupling the oracle to a
Module reference. Quantized oracles whose conversion
additionally needs scales / zero-points / block shapes will
override with a wider signature (and ultimately a per-oracle
config object — tracked in the #37753 follow-up PRs).
get_oot_backends()
classmethod
¶
Return platform registrations for an oracle that supports them.
get_priority_backends(moe_config)
¶
Return platform-appropriate backends in priority order for
this moe_config.
make_kernel(quant_config, moe_config, backend, experts_cls, routing_tables=None)
¶
Construct the FusedMoEKernel (Prepare/Finalize + Experts
combinator) for the chosen backend.
make_log_backend(backend, available_backends=None, is_lora=False, *, backend_name=None)
¶
Message for the backend a select loop settled on.
make_log_unsupported(backend, reason, is_lora=False, *, backend_name=None)
¶
Message for a backend that does not support the configuration.
make_quant_config(*args, **kwargs)
¶
Build a FusedMoEQuantConfig for this oracle.
Quantized oracles (fp8, nvfp4, mxfp4, ...) override this with the appropriate signature for their quantization scheme. Unquantized oracles inherit the default, which raises because there is no quantization-specific config to build.
map_backend(runner_backend)
¶
Map a user-facing MoEBackend (from the runner config) to
this oracle's enum.
maybe_skip_for_requantization_source()
classmethod
¶
Skip backend selection for online requantization sources.
return_or_raise(backend, available_backends=None, kernel_classes=None, activation_key=_UNSET, is_lora=False, *, backend_name=None)
¶
Return backend with its first supported kernel class, or raise.
Raises:
-
ValueError–no candidate kernel class supports the deployment configuration; the message carries the last rejection reason.
select_backend(moe_config, weight_key=None, activation_key=None)
¶
Primary entry point: choose the best supported backend for
the given moe_config.
weight_key / activation_key carry the quantization scheme of
the weights and activations and are consumed by quantized oracles
(fp8, nvfp4, int8, ...) to disambiguate backends. The unquantized
oracle ignores them. Subclasses with additional selection inputs
(e.g. int_wna16 needs weight_bits, fp8 needs
allow_vllm_cutlass) widen the signature in their override; a
per-oracle config object is the longer-term target tracked in
the #37753 follow-up PRs.
select_oot_backend()
¶
Select a registered backend, or let the caller try in-tree selection.
A named registration is required to support the configuration. With
auto, try registrations in order and warn if all are rejected.
try_backend(backend, kernel_classes=None, activation_key=_UNSET, *, backend_name=None)
¶
Probe backend's candidate kernel classes, first supported wins.
A miss logs a DEBUG line and yields to the next candidate; whether that
is fatal stays with the caller. activation_key overrides this oracle's
own key for oracles whose activation key varies per backend.
Returns:
-
type[FusedMoEExperts] | None–(kernel_cls, rejected): the winning class, orNone, plus every -
list[Rejection]–(kernel_cls, reason)probed and rejected before it, in order, so -
tuple[type[FusedMoEExperts] | None, list[Rejection]]–that callers collecting reasons for a report keep one entry per
-
tuple[type[FusedMoEExperts] | None, list[Rejection]]–candidate rather than only the last.
UnquantizedMoEKernelOracle
¶
Bases: MoEKernelOracle[UnquantizedMoeBackend]
Class-based view of the unquantized MoE kernel oracle.
Each method delegates to its module-level counterpart so that instantiating and calling this class is bit-identical to calling the standalone functions. Follow-up PRs may move logic from the module-level functions into these methods.