[watermark] compatibility validation (#56801)

Signed-off-by: Raphael Rialland <raphael.rialland@mistral.ai>
Signed-off-by: Simon Veitner <sveitner@redhat.com>
Co-authored-by: Simon Veitner <sveitner@redhat.com>
This commit is contained in:
Raphaël Rialland
2026-10-05 14:37:13 -04:00
committed by GitHub
co-authored by Simon Veitner
parent 88f3c601b3
commit c32495d58f
45 changed files with 1670 additions and 101 deletions
+39 -15
View File
@@ -47,6 +47,7 @@ from vllm.config.speculative import _validate_qwen3_omni_dspark
from vllm.config.utils import get_field
from vllm.config.vllm import OPTIMIZATION_LEVEL_TO_CONFIG, OptimizationLevel
from vllm.platforms import current_platform
from vllm.sampling_params import BeamSearchParams
from vllm.transformers_utils.config import (
_patch_hf_transformers_nested_rope_validation,
get_pooling_config,
@@ -3630,7 +3631,7 @@ def test_target_only_gumbel_allows_speculative_decoding(caplog_vllm, disable_log
)
with caplog_vllm.at_level(logging.WARNING):
config._check_watermarking_unsupported()
config._check_supports_watermarking()
assert "Target-only watermarking leaves accepted draft tokens" in caplog_vllm.text
@@ -3651,7 +3652,7 @@ def test_speculative_watermarking_without_context_dedup_does_not_warn(
caplog_vllm.clear()
with caplog_vllm.at_level(logging.WARNING):
config._check_watermarking_unsupported()
config._check_supports_watermarking()
assert "dedup" not in caplog_vllm.text.lower()
@@ -3672,7 +3673,7 @@ def test_speculative_context_dedup_logs_no_unsupported_warning(
caplog_vllm.clear()
with caplog_vllm.at_level(logging.WARNING):
config._check_watermarking_unsupported()
config._check_supports_watermarking()
assert "dedup" not in caplog_vllm.text.lower()
@@ -3690,7 +3691,7 @@ def test_gumbel_rejects_speculative_decoding_without_target_only():
)
with pytest.raises(ValueError, match="'gumbel'.*allow_target_only_watermarking"):
config._check_watermarking_unsupported()
config._check_supports_watermarking()
def test_dual_key_gumbel_warns_that_configured_alpha_is_unused(
@@ -3708,7 +3709,7 @@ def test_dual_key_gumbel_warns_that_configured_alpha_is_unused(
)
with caplog_vllm.at_level(logging.WARNING):
config._check_watermarking_unsupported()
config._check_supports_watermarking()
assert "The configured alpha=0.25 is not used" in caplog_vllm.text
@@ -3734,7 +3735,7 @@ def test_dual_key_gumbel_alpha_warning_is_not_emitted(
)
with caplog_vllm.at_level(logging.WARNING):
config._check_watermarking_unsupported()
config._check_supports_watermarking()
assert "is not used" not in caplog_vllm.text
@@ -3750,7 +3751,7 @@ def test_dual_key_gumbel_requires_probabilistic_drafting():
)
with pytest.raises(ValueError, match="draft_sample_method='probabilistic'"):
config._check_watermarking_unsupported()
config._check_supports_watermarking()
@pytest.mark.parametrize("method", ["eagle", "eagle3", "mtp"])
@@ -3764,7 +3765,7 @@ def test_dual_key_gumbel_supports_probabilistic_speculative_decoding(method):
parallel_drafting=False,
)
config._check_watermarking_unsupported()
config._check_supports_watermarking()
def test_dual_key_gumbel_supports_dspark():
@@ -3777,7 +3778,7 @@ def test_dual_key_gumbel_supports_dspark():
parallel_drafting=True,
)
config._check_watermarking_unsupported()
config._check_supports_watermarking()
def test_dual_key_gumbel_rejects_non_autoregressive_speculation():
@@ -3791,7 +3792,7 @@ def test_dual_key_gumbel_rejects_non_autoregressive_speculation():
)
with pytest.raises(ValueError, match="autoregressive model-based"):
config._check_watermarking_unsupported()
config._check_supports_watermarking()
@pytest.mark.parametrize(
@@ -3815,17 +3816,40 @@ def test_dual_key_gumbel_rejects_incompatible_speculative_modes(overrides, match
config.speculative_config = SimpleNamespace(**values)
with pytest.raises(ValueError, match=match):
config._check_watermarking_unsupported()
config._check_supports_watermarking()
def test_gumbel_watermark_rejects_beam_search():
with pytest.raises(ValueError, match="Beam search is not supported"):
_watermarked_vllm_config()._check_watermarking_unsupported(beam_search=True)
def test_gumbel_watermark_disables_beam_search_watermarking(caplog_vllm):
enabled = _watermarked_vllm_config()._check_supports_watermarking(
BeamSearchParams(beam_width=2, max_tokens=1)
)
assert not enabled
assert "beam search requests will run without watermarking" in caplog_vllm.text
def test_gumbel_watermark_allows_unwatermarked_beam_search():
_watermarked_vllm_config()._check_supports_watermarking(
BeamSearchParams(beam_width=2, max_tokens=1, watermarking=False)
)
def test_unwatermarked_beam_does_not_bypass_engine_incompatibilities():
config = _watermarked_vllm_config()
config.speculative_config = SpeculativeConfig(
method="ngram",
num_speculative_tokens=1,
)
with pytest.raises(ValueError, match="Speculative decoding with watermarking"):
config._check_supports_watermarking(
BeamSearchParams(beam_width=2, max_tokens=1, watermarking=False)
)
def test_gumbel_watermark_rejects_custom_sampler():
with pytest.raises(ValueError, match="custom samplers are not supported"):
_watermarked_vllm_config()._check_watermarking_unsupported(custom_sampler=True)
_watermarked_vllm_config()._check_supports_watermarking(custom_sampler=True)
def test_watermark_key_must_fit_in_64_bits():