[Bugfix] Reject contradictory custom-op directives (#49134)

Signed-off-by: Taneem Ibrahim <taneem.ibrahim@gmail.com>
This commit is contained in:
Taneem Ibrahim
2026-07-26 08:42:14 -04:00
committed by GitHub
parent 5559679229
commit 0da6e7f3d6
3 changed files with 59 additions and 11 deletions
+26 -2
View File
@@ -83,9 +83,33 @@ def test_copy_pass():
def test_custom_op():
# proper syntax
_ = CompilationConfig(custom_ops=["+quant_fp8", "-silu_and_mul"])
_ = CompilationConfig(custom_ops=["none", "+rms_norm"])
_ = CompilationConfig(custom_ops=["+rms_norm", "+rms_norm"])
with pytest.raises(ValueError, match="Invalid syntax '"):
_ = CompilationConfig(custom_ops=["quant_fp8"])
for custom_ops in (["quant_fp8"], ["+"], ["-"]):
with pytest.raises(ValueError, match="Invalid syntax '"):
CompilationConfig(custom_ops=custom_ops)
@pytest.mark.parametrize(
("custom_ops", "config_kwargs", "match"),
[
(["all", "none"], {}, "can contain only one base mode"),
(
["none", "+rms_norm", "-rms_norm"],
{},
"cannot both enable and disable.*rms_norm",
),
(
["-rotary_embedding"],
{"pass_config": PassConfig(enable_qk_norm_rope_fusion=True)},
"cannot both enable and disable.*rotary_embedding",
),
],
)
def test_reject_contradictory_custom_ops(custom_ops, config_kwargs, match):
with pytest.raises(ValueError, match=match):
CompilationConfig(custom_ops=custom_ops, **config_kwargs)
# forked needed to workaround https://github.com/vllm-project/vllm/issues/21073