Use aiter triton fused_add_rmsnorm_pad for gpt-oss (#30976)
Signed-off-by: Rohan138 <rohanpotdar138@gmail.com>
This commit is contained in:
@@ -790,6 +790,41 @@ def _rocm_aiter_act_mul_and_fp8_group_quant_fake(
|
||||
return x_fp8, out_bs
|
||||
|
||||
|
||||
def _rocm_aiter_triton_add_rmsnorm_pad_impl(
|
||||
x: torch.Tensor,
|
||||
weight: torch.Tensor,
|
||||
variance_epsilon: float,
|
||||
residual: torch.Tensor,
|
||||
x_pad_to_multiple: int,
|
||||
) -> tuple[torch.Tensor, torch.Tensor]:
|
||||
from aiter.ops.triton.fused_add_rmsnorm_pad import fused_add_rmsnorm_pad
|
||||
|
||||
return fused_add_rmsnorm_pad(
|
||||
x,
|
||||
weight,
|
||||
variance_epsilon,
|
||||
residual,
|
||||
x_pad_to_multiple=x_pad_to_multiple,
|
||||
)
|
||||
|
||||
|
||||
def _rocm_aiter_triton_add_rmsnorm_pad_fake(
|
||||
x: torch.Tensor,
|
||||
weight: torch.Tensor,
|
||||
variance_epsilon: float,
|
||||
residual: torch.Tensor,
|
||||
x_pad_to_multiple: int,
|
||||
) -> tuple[torch.Tensor, torch.Tensor]:
|
||||
M, N = x.shape
|
||||
if x_pad_to_multiple > 0:
|
||||
N_out = (N + x_pad_to_multiple - 1) // x_pad_to_multiple * x_pad_to_multiple
|
||||
else:
|
||||
N_out = N
|
||||
out = torch.empty((M, N_out), dtype=x.dtype, device=x.device)
|
||||
residual_out = torch.empty_like(residual)
|
||||
return out, residual_out
|
||||
|
||||
|
||||
# Global flag to ensure ops are registered only once
|
||||
_OPS_REGISTERED = False
|
||||
|
||||
@@ -1108,6 +1143,13 @@ class rocm_aiter_ops:
|
||||
fake_impl=_rocm_aiter_act_mul_and_fp8_group_quant_fake,
|
||||
)
|
||||
|
||||
direct_register_custom_op(
|
||||
op_name="rocm_aiter_triton_add_rmsnorm_pad",
|
||||
op_func=_rocm_aiter_triton_add_rmsnorm_pad_impl,
|
||||
fake_impl=_rocm_aiter_triton_add_rmsnorm_pad_fake,
|
||||
dispatch_key=current_platform.dispatch_key,
|
||||
)
|
||||
|
||||
direct_register_custom_op(
|
||||
op_name="rocm_aiter_group_fp8_quant",
|
||||
op_func=_rocm_aiter_group_fp8_quant_impl,
|
||||
@@ -1175,6 +1217,10 @@ class rocm_aiter_ops:
|
||||
def get_act_mul_fused_fp8_group_quant_op() -> OpOverload:
|
||||
return torch.ops.vllm.rocm_aiter_act_mul_and_fp8_group_quant.default
|
||||
|
||||
@staticmethod
|
||||
def get_triton_add_rmsnorm_pad_op() -> OpOverload:
|
||||
return torch.ops.vllm.rocm_aiter_triton_add_rmsnorm_pad.default
|
||||
|
||||
@staticmethod
|
||||
def rms_norm(
|
||||
x: torch.Tensor, weight: torch.Tensor, variance_epsilon: float
|
||||
|
||||
Reference in New Issue
Block a user