Skip to content

vllm.model_executor.layers.fused_moe.experts.flashinfer_moe_ep

FlashInfer MoE-EP megakernels as a modular-kernel experts implementation.

The megakernel routes on vLLM's top-k output and then dispatches, computes and combines in one launch, so it is paired with a pass-through prepare/finalize.

Classes:

Functions:

FlashInferMoeEpExperts

Bases: FusedMoEExpertsModular

Methods:

process_weights_after_loading(layer)

Build the megakernel from the layer's canonical weights.

The oracle supplies the weights in the backend's input format. Per-expert global scales arrive through the quant config and become epilogue alphas. On SM107 the checkpoint's activation input scales also set the activation and FC1-output quantization of NVFP4 experts (sm107_nvfp4_epilogue); MXFP4 experts have no such scales.

epilogue_from_quant_config(quant_config)

Per-expert epilogue constants from the canonical quant config.

The weight global scales (g1_alphas/g2_alphas) become the fc1/fc2 alphas. Activations are quantized dynamically inside the megakernel, so on SM100/SM103 the checkpoint's input scales drop out; SM107 uses them (sm107_nvfp4_epilogue). MXFP4 checkpoints carry no global scales and keep the default epilogue. The alphas alias the layer's parameters, so EPLB permutations reach the kernel.

sm107_nvfp4_epilogue(epilogue, w13_input_scale, w2_input_scale)

NVFP4 epilogue of the SM107 megakernel from the checkpoint's activation scales.

With unit norm constants small activations can underflow the E4M3 block scales. Tokens are quantized on their source rank, so the activation grid is the layer maximum over every EP rank. The alphas are scaled in place and keep aliasing the layer's weight global scales. Collective over the EP group: every EP rank must call it for the same MoE layers in the same order.