[CustomOp] Register RMSNorm instead of overwrite forward_oot (#2284)

### What this PR does / why we need it?
Use function CustomOp.register_oot to achieve the customop registery
```
from vllm.model_executor.custom_op import CustomOp
CustomOp.register_oot(_decorated_op_cls=AscendRMSNorm, name="RMSNorm")
```

### Does this PR introduce _any_ user-facing change?
N/A

### How was this patch tested?
CI passed with new added/existing test.

- vLLM version: v0.10.0
- vLLM main:
afa5b7ca0b

---------

Signed-off-by: Icey <1790571317@qq.com>
This commit is contained in:
Icey
2025-08-14 17:18:30 +08:00
committed by GitHub
parent e14f2ef669
commit c721ae6042
4 changed files with 85 additions and 28 deletions

View File

@@ -347,20 +347,22 @@ class TestUtils(TestBase):
@mock.patch("vllm.model_executor.custom_op.CustomOp")
@mock.patch("vllm_ascend.ops.activation.AscendQuickGELU")
@mock.patch("vllm_ascend.ops.activation.AscendSiluAndMul")
def test_register_ascend_customop(self, mock_ascend_silu_and_mul,
@mock.patch("vllm_ascend.ops.layernorm.AscendRMSNorm")
def test_register_ascend_customop(self, mock_ascend_rmsnorm,
mock_ascend_silu_and_mul,
mock_ascend_quick_gelu, mock_customop):
utils._ASCEND_CUSTOMOP_IS_REIGISTERED = False
# ascend custom op is not registered
utils.register_ascend_customop()
# should call register_oot twice
self.assertEqual(mock_customop.register_oot.call_count, 2)
# should call register_oot three
self.assertEqual(mock_customop.register_oot.call_count, 3)
self.assertTrue(utils._ASCEND_CUSTOMOP_IS_REIGISTERED)
# ascend custom op is already registered
utils.register_ascend_customop()
# should not register_oot again, thus only called twice in this ut
self.assertEqual(mock_customop.register_oot.call_count, 2)
# should not register_oot again, thus only called three in this ut
self.assertEqual(mock_customop.register_oot.call_count, 3)
class TestProfileExecuteDuration(TestBase):