[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:
+37
-3
@@ -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"]
|
||||
|
||||
Reference in New Issue
Block a user