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_masked_supported–Whether the masked
apply_moe_activationpath supports an activation. -
apply_moe_activation_supported–Whether
apply_moe_activationsupports an activation. -
situ_and_mul_quant–Fused Kimi SITU activation + dynamic FP8 quantization.
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, valid_token_counts=None) ¶
Apply MoE activation function.
The configuration drives specialized activation behavior. Routing tensors and valid token counts remain per-call inputs because they depend on the current token assignment. A single token count masks a flat [T, D] buffer; one count per expert masks each prefix in a padded [E, T, D] buffer.
Source code in vllm/model_executor/layers/fused_moe/activation.py
313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 | |
apply_moe_activation_masked_supported(activation) ¶
Whether the masked apply_moe_activation path supports an activation.
apply_moe_activation_supported(activation) ¶
Whether apply_moe_activation supports an activation.
situ_and_mul_quant(output, scale, input, *, beta, linear_beta, group_size=0, num_valid_tokens=None, topk=1) ¶
Fused Kimi SITU activation + dynamic FP8 quantization.
Writes the quantized fp8 down-projection input into output [M, d] and its float32 scale into scale (dequant = q * scale), fusing the SITU activation with the FP8 quant that Humming's w2 GEMM would otherwise perform in a separate pass -- this avoids materializing (and rounding through) the bf16 activation_output buffer.
group_size selects the quant granularity: 0 gives per-token scales scale [M, 1]; 128 gives k-major block-FP8 group scales scale [M, d // 128], matching humming quant_input(group_size=128, float32).
linear_beta <= 0 (or None) means "unset" (up passed through), matching SituAndMul(linear_beta=None). num_valid_tokens (int32 scalar tensor) is the DeepEP v2 contiguous-layout token count (e.g. psum[-1:]); the kernel multiplies it by topk to bound rows. Padding rows are skipped and receive a benign scale of 1.0. Kept in this module so that every torch.ops._C.situ* call lives in one file.