[Refactor] Clean up custom op (#15995)
This commit is contained in:
@@ -4,7 +4,8 @@ import torch
|
||||
import triton
|
||||
import triton.language as tl
|
||||
|
||||
from sglang.srt.utils import direct_register_custom_op, is_hip
|
||||
from sglang.srt.utils import is_hip
|
||||
from sglang.srt.utils.custom_op import register_custom_op
|
||||
|
||||
_is_hip = is_hip()
|
||||
|
||||
@@ -358,6 +359,7 @@ def experts_combine_kernel(
|
||||
tl.store(out_hidden_states + start_index_mlp + offsets, combined_x, mask=mask)
|
||||
|
||||
|
||||
@register_custom_op(out_shape="mlp_hidden_states")
|
||||
def experts_combine_triton(
|
||||
moe_hidden_states: torch.Tensor,
|
||||
mlp_hidden_states: torch.Tensor,
|
||||
@@ -401,22 +403,6 @@ def experts_combine_triton(
|
||||
return out_hidden_states
|
||||
|
||||
|
||||
def experts_combine_triton_fake(
|
||||
moe_hidden_states: torch.Tensor,
|
||||
mlp_hidden_states: torch.Tensor,
|
||||
output_buffer: Optional[torch.Tensor] = None,
|
||||
) -> torch.Tensor:
|
||||
return torch.empty_like(mlp_hidden_states)
|
||||
|
||||
|
||||
direct_register_custom_op(
|
||||
op_name="experts_combine_triton",
|
||||
op_func=experts_combine_triton,
|
||||
mutates_args=[],
|
||||
fake_impl=experts_combine_triton_fake,
|
||||
)
|
||||
|
||||
|
||||
# gelu on first half of vector
|
||||
@triton.jit
|
||||
def gelu_and_mul_kernel(
|
||||
|
||||
Reference in New Issue
Block a user