[4/N] MoE Refactor: Unified Triton Kernel for FusedMoE and EPMoE (#8515)
This commit is contained in:
@@ -172,7 +172,6 @@ class Fp8Config(QuantizationConfig):
|
||||
self, layer: torch.nn.Module, prefix: str
|
||||
) -> Optional[QuantizeMethodBase]:
|
||||
from sglang.srt.layers.linear import LinearBase
|
||||
from sglang.srt.layers.moe.ep_moe.layer import EPMoE
|
||||
from sglang.srt.layers.moe.fused_moe_triton import FusedMoE
|
||||
|
||||
if isinstance(layer, LinearBase):
|
||||
@@ -181,8 +180,6 @@ class Fp8Config(QuantizationConfig):
|
||||
return Fp8LinearMethod(self)
|
||||
elif isinstance(layer, FusedMoE):
|
||||
return Fp8MoEMethod(self)
|
||||
elif isinstance(layer, EPMoE):
|
||||
return Fp8EPMoEMethod(self)
|
||||
return None
|
||||
|
||||
def get_scaled_act_names(self) -> List[str]:
|
||||
@@ -984,23 +981,8 @@ class Fp8MoEMethod(FusedMoEMethodBase):
|
||||
no_combine: bool = False,
|
||||
routed_scaling_factor: Optional[float] = None,
|
||||
) -> torch.Tensor:
|
||||
from sglang.srt.layers.moe.ep_moe.layer import EPMoE
|
||||
from sglang.srt.layers.moe.fused_moe_triton.fused_moe import fused_experts
|
||||
|
||||
if isinstance(layer, EPMoE):
|
||||
layer.w13_weight_scale = (
|
||||
layer.w13_weight_scale_inv
|
||||
if self.block_quant
|
||||
else layer.w13_weight_scale
|
||||
)
|
||||
layer.w2_weight_scale = (
|
||||
layer.w2_weight_scale_inv if self.block_quant else layer.w2_weight_scale
|
||||
)
|
||||
return layer.run_moe(
|
||||
hidden_states=x,
|
||||
topk_output=topk_output,
|
||||
)
|
||||
|
||||
if use_intel_amx_backend(layer):
|
||||
from sglang.srt.layers.moe.topk import apply_topk_weights_cpu
|
||||
|
||||
|
||||
@@ -204,14 +204,6 @@ class UnquantizedFusedMoEMethod(FusedMoEMethodBase, CustomOp):
|
||||
routed_scaling_factor: Optional[float] = None,
|
||||
) -> torch.Tensor:
|
||||
|
||||
from sglang.srt.layers.moe.ep_moe.layer import EPMoE
|
||||
|
||||
if isinstance(layer, EPMoE):
|
||||
return layer.run_moe(
|
||||
hidden_states=x,
|
||||
topk_output=topk_output,
|
||||
)
|
||||
|
||||
return self.forward(
|
||||
x=x,
|
||||
layer=layer,
|
||||
|
||||
@@ -276,6 +276,7 @@ class W4AFp8MoEMethod(FusedMoEMethodBase):
|
||||
layer: EPMoE,
|
||||
hidden_states: torch.Tensor,
|
||||
topk_output: TopKOutput,
|
||||
**kwargs,
|
||||
) -> torch.Tensor:
|
||||
|
||||
# TODO(ch-wan): move it out of this class
|
||||
|
||||
Reference in New Issue
Block a user