[vLLM IR] 2/N fused_add_rms_norm and maybe_inplace overload (#36823)

Signed-off-by: Luka Govedič <lgovedic@redhat.com>
Signed-off-by: Luka Govedič <ProExpertProg@users.noreply.github.com>
This commit is contained in:
Luka Govedič
2026-05-01 23:41:15 -04:00
committed by GitHub
parent 3e49479c4b
commit d58c42e19c
44 changed files with 2833 additions and 779 deletions
+37 -3
View File
@@ -1295,11 +1295,14 @@ def test_ir_op_priority_default():
# Assert default is applied to ops
priority_config = IrOpPriorityConfig.with_default(["vllm_c", "native"])
assert priority_config.rms_norm == ["vllm_c", "native"]
assert priority_config.fused_add_rms_norm == ["vllm_c", "native"]
# Assert single ops override the default
assert IrOpPriorityConfig.with_default(
["vllm_c", "native"], rms_norm=["oink", "native"]
) == IrOpPriorityConfig(rms_norm=["oink", "native"])
priority_config = IrOpPriorityConfig.with_default(
["native"], rms_norm=["oink", "native"]
)
assert priority_config.rms_norm == ["oink", "native"]
assert priority_config.fused_add_rms_norm == ["native"]
def test_ir_op_priority_str():
@@ -1318,3 +1321,34 @@ def test_ir_op_priority_str():
with pytest.raises(pydantic.ValidationError):
# must be list of only strings
priority_config = IrOpPriorityConfig(rms_norm=["vllm_c", 4, "native"])
def test_ir_op_priority_ctx():
"""Test that the priority-setting context sets priority correctly."""
from vllm import ir
from vllm.config.kernel import IrOpPriorityConfig
priority = IrOpPriorityConfig.with_default(["native"], rms_norm=["vllm_c"])
priority2 = IrOpPriorityConfig.with_default(
["native"], fused_add_rms_norm=["vllm_c"]
)
with priority.set_priority():
assert ir.ops.rms_norm.get_priority() == ["vllm_c", "native"]
assert ir.ops.fused_add_rms_norm.get_priority() == ["native"]
with priority2.set_priority():
assert ir.ops.rms_norm.get_priority() == ["native"]
assert ir.ops.fused_add_rms_norm.get_priority() == ["vllm_c", "native"]
# context restored
assert ir.ops.rms_norm.get_priority() == ["vllm_c", "native"]
assert ir.ops.fused_add_rms_norm.get_priority() == ["native"]
with pytest.raises(ValueError), priority2.set_priority():
assert ir.ops.rms_norm.get_priority() == ["native"]
assert ir.ops.fused_add_rms_norm.get_priority() == ["vllm_c", "native"]
raise ValueError
# context restored even after exception
assert ir.ops.rms_norm.get_priority() == ["vllm_c", "native"]
assert ir.ops.fused_add_rms_norm.get_priority() == ["native"]