vllm.model_executor.layers.fused_moe.flashinfer_cutlass_moe
FlashInferExperts ¶
Bases: FusedMoEPermuteExpertsUnpermute
Source code in vllm/model_executor/layers/fused_moe/flashinfer_cutlass_moe.py
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 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 |
|
activation_formats property
¶
activation_formats: tuple[
FusedMoEActivationFormat, FusedMoEActivationFormat
]
__init__ ¶
__init__(
g1_alphas: Tensor,
g2_alphas: Tensor,
a1_gscale: Tensor,
a2_gscale: Tensor,
out_dtype: dtype,
quant_dtype: Union[dtype, str, None],
ep_rank: int = 0,
ep_size: int = 1,
tp_rank: int = 0,
tp_size: int = 1,
)
Source code in vllm/model_executor/layers/fused_moe/flashinfer_cutlass_moe.py
apply ¶
apply(
output: Tensor,
hidden_states: Tensor,
w1: Tensor,
w2: Tensor,
topk_weights: Tensor,
topk_ids: Tensor,
activation: str,
global_num_experts: int,
expert_map: Optional[Tensor],
w1_scale: Optional[Tensor],
w2_scale: Optional[Tensor],
w1_zp: Optional[Tensor],
w2_zp: Optional[Tensor],
a1q_scale: Optional[Tensor],
a2_scale: Optional[Tensor],
workspace13: Optional[Tensor],
workspace2: Optional[Tensor],
expert_tokens_meta: Optional[ExpertTokensMetadata],
apply_router_weight_on_input: Optional[bool],
)
Source code in vllm/model_executor/layers/fused_moe/flashinfer_cutlass_moe.py
finalize_weight_and_reduce_impl ¶
finalize_weight_and_reduce_impl() -> TopKWeightAndReduce
workspace_shapes ¶
workspace_shapes(
a: Tensor,
aq: Tensor,
M: int,
N: int,
K: int,
topk: int,
global_num_experts: int,
local_num_experts: int,
expert_tokens_meta: Optional[ExpertTokensMetadata],
) -> tuple[
tuple[int, ...], tuple[int, ...], tuple[int, ...], dtype
]
Compute the shapes for the temporary and final outputs of the two gemms and activation in the fused expert function. Since the gemms are independent, the workspace for the first gemm can be shared with the workspace for the last gemm.
Returns a tuple of: - workspace13 shape tuple: must be large enough to hold the result of either expert gemm. - workspace2 shape tuple: must be large enough to hold the result of the activation function. - output shape tuple: must be exact size of the final gemm output. - Workspace type: The dtype to use for the workspace tensors. - Note: in order for activation chunking to work, the first dimension of each tuple must be the number of tokens.
Source code in vllm/model_executor/layers/fused_moe/flashinfer_cutlass_moe.py
flashinfer_cutlass_moe_fp4 ¶
flashinfer_cutlass_moe_fp4(
hidden_states: Tensor,
w1: Tensor,
w2: Tensor,
topk_weights: Tensor,
topk_ids: Tensor,
w1_scale: Tensor,
w2_scale: Tensor,
g1_alphas: Tensor,
g2_alphas: Tensor,
a1_gscale: Tensor,
a2_gscale: Tensor,
inplace: bool = False,
activation: str = "silu",
global_num_experts: int = -1,
expert_map: Optional[Tensor] = None,
apply_router_weight_on_input: bool = False,
) -> Tensor
Source code in vllm/model_executor/layers/fused_moe/flashinfer_cutlass_moe.py
is_valid_flashinfer_cutlass_fused_moe ¶
Check if the given problem size is supported by the FlashInfer CUTLASS MoE kernel.