vllm.model_executor.layers.fused_moe.activation ¶
MoE activation function enum and utilities.
Classes:
-
ApplyMoEActivationConfig–Configuration forwarded to
apply_moe_activation. -
MoEActivation–Activation functions for MoE layers.
Functions:
-
activation_without_mul–Get the non-gated variant of an activation function.
-
apply_moe_activation–Apply MoE activation function.
-
apply_moe_activation_supported–Whether
apply_moe_activationsupports an activation.
ApplyMoEActivationConfig dataclass ¶
Configuration forwarded to apply_moe_activation.
Methods:
-
from_configs–Build from the model and quantization configurations.
Source code in vllm/model_executor/layers/fused_moe/activation.py
from_configs(moe_config, quant_config) classmethod ¶
Build from the model and quantization configurations.
Source code in vllm/model_executor/layers/fused_moe/activation.py
MoEActivation ¶
Bases: Enum
Activation functions for MoE layers.
Methods:
-
from_str–Parse from string for backward compatibility.
-
without_mul–Get the non-gated variant of this activation.
Attributes:
-
custom_op_name(str) –Maps to the CustomOp name of activations
-
is_gated(bool) –Returns True if activation expects gate*activation(up) pattern.
Source code in vllm/model_executor/layers/fused_moe/activation.py
custom_op_name property ¶
Maps to the CustomOp name of activations in vllm/model_executor/layers/activation.py.
is_gated property ¶
Returns True if activation expects gate*activation(up) pattern.
Gated activations expect input tensor with 2x the output size, where the first half is the gate and second half is the up projection.
from_str(s) classmethod ¶
Parse from string for backward compatibility.
Source code in vllm/model_executor/layers/fused_moe/activation.py
without_mul() ¶
Get the non-gated variant of this activation.
For activations that have a _no_mul variant, returns that variant. For activations without a _no_mul variant (or already _no_mul), returns self.
Source code in vllm/model_executor/layers/fused_moe/activation.py
activation_without_mul(activation) ¶
Get the non-gated variant of an activation function.
Parameters:
Returns:
-
str–The non-gated activation name (e.g., "silu_no_mul", "gelu_no_mul")
Source code in vllm/model_executor/layers/fused_moe/activation.py
apply_moe_activation(activation, output, input, *, activation_config=None, topk_ids=None, expert_map=None) ¶
Apply MoE activation function.
The configuration drives specialized activation behavior. Routing tensors remain per-call inputs because they depend on the current token assignment.
Source code in vllm/model_executor/layers/fused_moe/activation.py
196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 | |
apply_moe_activation_supported(activation) ¶
Whether apply_moe_activation supports an activation.