[MoE] Remove inplace fused experts mechanism (#43727)

Signed-off-by: Yongye Zhu <zyy1102000@gmail.com>
This commit is contained in:
Yongye Zhu
2026-05-27 20:00:19 -07:00
committed by GitHub
parent 05eec7120e
commit 2d2c660104
44 changed files with 11 additions and 237 deletions
@@ -30,7 +30,6 @@ from vllm.model_executor.layers.fused_moe.topk_weight_and_reduce import (
)
from vllm.model_executor.layers.fused_moe.utils import (
_resize_cache,
disable_inplace,
swiglu_limit_func,
)
from vllm.model_executor.layers.quantization.utils.marlin_utils import (
@@ -257,7 +256,6 @@ def fused_marlin_moe(
is_k_full: bool = True,
output: torch.Tensor | None = None,
input_dtype: torch.dtype | None = None,
inplace: bool = False,
clamp_limit: float | None = None,
) -> torch.Tensor:
"""
@@ -286,10 +284,6 @@ def fused_marlin_moe(
- torch.Tensor: The output tensor after applying the MoE layer.
"""
if inplace:
assert output is None, "Conflicting request"
assert not disable_inplace()
quant_type = ScalarType.from_id(quant_type_id)
assert quant_type in [
scalar_types.uint4,
@@ -379,7 +373,7 @@ def fused_marlin_moe(
).view(-1, topk, K)
if output is None:
output = hidden_states if inplace else torch.empty_like(hidden_states)
output = torch.empty_like(hidden_states)
if moe_sum is None:
return torch.sum(moe_output.view(-1, topk, K), dim=1, out=output)
@@ -417,7 +411,6 @@ def batched_fused_marlin_moe(
is_k_full: bool = True,
output: torch.Tensor | None = None,
input_dtype: torch.dtype | None = None,
inplace: bool = False,
clamp_limit: float | None = None,
) -> torch.Tensor:
"""
@@ -449,8 +442,6 @@ def batched_fused_marlin_moe(
f"hidden states must be batched. e.g. [B, MAX_TOKENS, K]."
f"But got {hidden_states.size()}"
)
if inplace:
assert output is None, "Conflicting request."
quant_type = ScalarType.from_id(quant_type_id)
assert quant_type in [
@@ -508,9 +499,6 @@ def batched_fused_marlin_moe(
expert_num_tokens=expert_num_tokens,
)
if output is None and inplace:
output = hidden_states
# TODO (varun): This can be avoided by plumbing the marlin kernel to
# ignore topk_weights when topk_weights_ptr is a nullptr.
topk_weights = torch.ones(
@@ -17,7 +17,6 @@ from vllm.model_executor.layers.fused_moe.config import (
from vllm.model_executor.layers.fused_moe.topk_weight_and_reduce import (
TopKWeightAndReduceNoOP,
)
from vllm.model_executor.layers.fused_moe.utils import disable_inplace
from vllm.model_executor.layers.quantization.utils.quant_utils import (
QuantKey,
kFp8Dynamic128Sym,
@@ -516,7 +515,6 @@ class AiterExperts(mk.FusedMoEExpertsModular):
and output.is_contiguous()
and result.is_contiguous()
and output._base is None
and disable_inplace()
):
output.set_(result)
else: