vllm.model_executor.layers.fused_moe.router.fused_moe_router
¶
Classes:
-
FusedMoERouter–FusedMoERouter is an abstract class that provides a 'select_experts'
FusedMoERouter
¶
Bases: PluggableLayer, ABC
FusedMoERouter is an abstract class that provides a 'select_experts' method that is used for routing hidden states based on router logits.
Methods:
-
select_experts–Route the input hidden states to the top-k experts based on the
Attributes:
-
kernel_routing_method_type(RoutingMethodType) –Routing method executed by kernels, before any router override.
-
masks_padding(bool) –Whether
select_expertsalready gives padding rows expert id -1.
Source code in vllm/model_executor/layers/fused_moe/router/fused_moe_router.py
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 | |
kernel_routing_method_type
property
¶
Routing method executed by kernels, before any router override.
masks_padding
property
¶
Whether select_experts already gives padding rows expert id -1.
select_experts(hidden_states, router_logits, topk_indices_dtype=None, *, input_ids=None)
¶
Route the input hidden states to the top-k experts based on the router logits.
Returns:
-
Tensor–(topk_weights, topk_ids)
-
tuple[Tensor, Tensor]– -
tuple[Tensor, Tensor]–The weights and expert ids computation result.
-
tuple[Tensor, Tensor]–Compatibility: When EPLB is not enabled, the returned ids are
-
tuple[Tensor, Tensor]–equivalent to global logical ids, so should be compatible with
-
tuple[Tensor, Tensor]–plain MoE implementations without redundant experts.