vllm.model_executor.layers.fused_moe.experts.moonep_experts
¶
MoonEP experts: grouped GEMM over MoonEP's expert-grouped activations.
MoonEP dispatch delivers tokens already contiguous per weight row
([NvS, H] in cu_seqlens[E+B] segment order), so the expert compute
is three grouped GEMMs over those segments with no permute/unpermute:
gate = grouped_mm(x, w_gate[E+B]) # [NvS, I]
up = grouped_mm(x, w_up[E+B]) # [NvS, I]
act = silu(gate) * up * route_weight # route weights applied here
out = grouped_mm(act, w_down[E+B]) # [NvS, H]
Rows [E, E+B) are the redundant-expert prefetch slots that
MoonEPPrepareAndFinalize fills before apply runs. Empty segments
(including unused prefetch slots) are skipped by the grouped GEMM.
Weight layout: MoonEP's prefetch_weight requires each projection to be
its own contiguous [E+B, ., .] tensor, so gate and up are separate
tensors rather than vLLM's interleaved [E, 2I, H] w13. The modular
kernel passes w1/w2 from the layer (w1 is the gate tensor); the
full layout is picked up from the layer in process_weights_after_loading
and shared with MoonEPPrepareAndFinalize via post_init_setup.
Classes:
-
MoonEPExperts–Grouped-GEMM experts over MoonEP's
[NvS, H]layout (BF16).
Functions:
-
moonep_grouped_gemm–out[seg_g] = a[seg_g] @ w[g].Tfor eachcu_seqlenssegment.
MoonEPExperts
¶
moonep_grouped_gemm(a, w, cu_seqlens)
¶
out[seg_g] = a[seg_g] @ w[g].T for each cu_seqlens segment.
Parameters:
-
(a¶Tensor) –[NvS, K]activations in segment order. -
(w¶Tensor) –[G, N, K]weights (vLLM[E, N, K]convention). -
(cu_seqlens¶Tensor) –[G]int32 cumulative segment end offsets.
Returns:
-
Tensor–[NvS, N]; rows pastcu_seqlens[-1]are zero-filled.