Skip to content

vllm.model_executor.layers.fused_moe.experts.trtllm_mxfp4_moe

Classes:

TrtLlmMxfp4ExpertsBase

MXFP4 TRTLLM-Gen MoE kernels. Shared base for modular and monolithic.

TrtLlmMxfp4ExpertsModular

Bases: TrtLlmMxfp4ExpertsModularBase

Modular MXFP4 TRTLLM experts with unquantized activations.

TrtLlmMxfp4ExpertsModularBase

Bases: TrtLlmMxfp4ExpertsBase, FusedMoEExpertsModular

Modular base version of the MXFP4 TRTLLM kernel (just the experts). Wraps flashinfer.trtllm_fp4_block_scale_routed_moe().

The TRTLLM-Gen kernel skips padding rows (topk_ids == -1), so every subclass consumes the padded contiguous layout DeepEP v2 produces.

_invoke_kernel(output, x_quant, x_scale, topk_ids, topk_weights, w1, w2, activation, global_num_experts, local_num_experts, local_expert_offset, topk)

Finalize into output, or stop after GEMM2 when it is None.

_max_supported_tokens(top_k, global_num_experts)

Max tokens per kernel call before the batched-GEMM grid overflows.

The TRTLLM-Gen batched GEMM launches a static grid whose batch (Y) dimension is getMaxNumCtasInBatchDim(num_tokens, top_k, num_experts, tileTokensDim) and must stay <= 65535. Solving that for num_tokens with the smallest tile the kernel may pick (tileTokensDim=8, the runner default) gives a bound that is safe regardless of the tactic selected. Without it, large batches (e.g. Kimi-K3 top_k=16, EP16 profiling with 131072 gathered tokens) overflow the grid and the GEMM launch fails.

TrtLlmMxfp4ExpertsMonolithic

Bases: TrtLlmMxfp4ExpertsBase, FusedMoEExpertsMonolithic

Monolithic version of the MXFP4 TRTLLM kernel (router + experts). Wraps flashinfer.trtllm_fp4_block_scale_moe().

TrtLlmMxfp4Mxfp8ExpertsModular

Bases: TrtLlmMxfp4ExpertsModularBase

Modular MXFP4 TRTLLM experts with dynamic MXFP8 activations.