Merge remote-tracking branch 'upstream/main' into patches

Signed-off-by: MOVZX <movzx@yahoo.com>
This commit is contained in:
2026-10-03 21:59:03 +07:00
1012 changed files with 61873 additions and 14499 deletions
+183 -9
View File
@@ -147,12 +147,104 @@ def test_rocm_mm_prefix_lm_disables_chunked_mm_input(
assert config.scheduler_config.disable_chunked_mm_input is expected
def _sampling_replay_config(
*,
return_sampling_mask: bool = True,
use_v2_model_runner: bool = True,
speculative_method: str | None = None,
rejection_sample_method: str = "standard",
adaptive: bool = False,
is_diffusion: bool = False,
logits_processors: list[str] | None = None,
logprobs_mode: str = "processed_logprobs",
):
speculative_config = None
if speculative_method is not None:
speculative_config = SimpleNamespace(
method=speculative_method,
enable_adaptive_verification=adaptive,
rejection_sample_method=rejection_sample_method,
)
return SimpleNamespace(
model_config=SimpleNamespace(
return_sampling_mask=return_sampling_mask,
is_diffusion=is_diffusion,
logits_processors=logits_processors or [],
logprobs_mode=logprobs_mode,
),
use_v2_model_runner=use_v2_model_runner,
speculative_config=speculative_config,
)
@pytest.mark.parametrize(
("config", "message"),
[
(_sampling_replay_config(), None),
*(
(_sampling_replay_config(speculative_method=method), None)
for method in (
"mtp",
"eagle",
"eagle3",
"dflash",
"dspark",
"draft_model",
)
),
*(
(
_sampling_replay_config(
speculative_method="mtp",
rejection_sample_method=rejection_sample_method,
),
None,
)
for rejection_sample_method in ("standard", "block", "synthetic")
),
(
_sampling_replay_config(
return_sampling_mask=False, speculative_method="dspark", adaptive=True
),
None,
),
(
_sampling_replay_config(speculative_method="dspark", adaptive=True),
"requires fixed verification boundaries",
),
(
_sampling_replay_config(is_diffusion=True),
"does not support diffusion models",
),
(
_sampling_replay_config(logits_processors=["custom"]),
"does not support custom logits processors",
),
(
_sampling_replay_config(logprobs_mode="raw_logprobs"),
"requires logprobs_mode='processed_logprobs'",
),
(
_sampling_replay_config(use_v2_model_runner=False),
"requires Model Runner V2",
),
],
)
def test_sampling_replay_config(config, message):
if message is None:
VllmConfig._verify_sampling_replay_config(config)
else:
with pytest.raises(ValueError, match=message):
VllmConfig._verify_sampling_replay_config(config)
def test_kda_recoverssm_derivation_is_revalidated():
config = SimpleNamespace(
cache_config=SimpleNamespace(
use_replayssm=True,
use_recoverssm=False,
mamba_cache_mode="none",
replayssm_buffer_len=16,
),
num_speculative_tokens=3,
model_config=SimpleNamespace(
@@ -178,14 +270,12 @@ def test_kda_recoverssm_derivation_is_revalidated():
with pytest.raises(ValueError, match="VLLM_USE_V2_MODEL_RUNNER=1"):
VllmConfig.validate_mamba_cached_kernel(config)
config.use_v2_model_runner = True
config.cache_config.mamba_cache_mode = "all"
with pytest.raises(ValueError, match="only none and align"):
VllmConfig.validate_mamba_cached_kernel(config)
config.cache_config.mamba_cache_mode = "none"
config.model_config.architecture = "NemotronHForCausalLM"
with pytest.raises(ValueError, match="only supported for Kimi-K3 KDA"):
VllmConfig.validate_mamba_cached_kernel(config)
config.mamba_config.backend = MambaBackendEnum.FLASHINFER
VllmConfig.validate_mamba_cached_kernel(config)
assert not config.cache_config.use_recoverssm
config.model_config.architecture = "KimiLinearForCausalLM"
config.parallel_config.pipeline_parallel_size = 2
@@ -193,6 +283,12 @@ def test_kda_recoverssm_derivation_is_revalidated():
VllmConfig.validate_mamba_cached_kernel(config)
def test_mamba_cache_mode_all_is_rejected():
"""The removed 'all' mode must fail validation instead of being ignored."""
with pytest.raises(ValidationError, match="mamba_cache_mode"):
CacheConfig(mamba_cache_mode="all")
def test_per_request_spec_decode_metrics_requires_spec_decode():
# The flag only makes sense with speculative decoding configured; enabling
# it without --speculative-config should fail fast rather than silently
@@ -420,6 +516,19 @@ def test_hisparse_rejects_disabled_hybrid_kv_cache_manager(monkeypatch):
)
def test_hisparse_rejects_disabled_full_isl_reservation(monkeypatch):
monkeypatch.setattr(current_platform, "is_cuda", lambda: True)
with pytest.raises(ValueError, match="requires --scheduler-reserve-full-isl"):
VllmConfig(
attention_config=AttentionConfig(hisparse_config=HiSparseConfig()),
scheduler_config=SchedulerConfig(
max_model_len=2048,
is_encoder_decoder=False,
scheduler_reserve_full_isl=False,
),
)
def test_hisparse_rejects_non_cuda(monkeypatch):
monkeypatch.setattr(current_platform, "is_cuda", lambda: False)
with pytest.raises(ValueError, match="requires NVIDIA CUDA"):
@@ -1590,14 +1699,14 @@ def test_engram_dp_shared_memory_config_validation(
("DeepseekV41ForCausalLM", [1], "cuda", True),
("DeepseekV41ForCausalLM", [1], "rocm", True),
("DeepseekV41ForCausalLM", [], "cuda", False),
("DeepseekV41ForCausalLM", [1], "cpu", False),
("DeepseekV41ForCausalLM", [1], "cpu", True),
("Qwen4ExpForCausalLM", [1], "cuda", True),
("Qwen4ExpForCausalLM", [1], "rocm", True),
("Qwen4ExpForConditionalGeneration", [1], "cuda", True),
("Qwen4ExpForConditionalGeneration", [1], "rocm", True),
("Qwen4ExpForCausalLM", [], "cuda", False),
("Qwen4ExpForCausalLM", None, "cuda", False),
("Qwen4ExpForCausalLM", [1], "cpu", False),
("Qwen4ExpForCausalLM", [1], "cpu", True),
("LlamaForCausalLM", [1], "cuda", False),
("Qwen4ExpMTP", [], "cuda", False),
(None, None, "cuda", False),
@@ -3550,7 +3659,6 @@ def test_target_only_gumbel_allows_speculative_decoding(caplog_vllm, disable_log
config._check_watermarking_unsupported()
assert "Target-only watermarking leaves accepted draft tokens" in caplog_vllm.text
assert "Context deduplication is not supported" in caplog_vllm.text
def test_speculative_watermarking_without_context_dedup_does_not_warn(
@@ -3567,10 +3675,32 @@ def test_speculative_watermarking_without_context_dedup_does_not_warn(
parallel_drafting=False,
)
caplog_vllm.clear()
with caplog_vllm.at_level(logging.WARNING):
config._check_watermarking_unsupported()
assert "Context deduplication is not supported" not in caplog_vllm.text
assert "dedup" not in caplog_vllm.text.lower()
def test_speculative_context_dedup_logs_no_unsupported_warning(
caplog_vllm, disable_log_dedup
):
config = _watermarked_vllm_config()
config.watermark_config = WatermarkConfig(
algorithm="dual_key_gumbel", key=42, deduplicate_contexts="single_turn"
)
config.speculative_config = SimpleNamespace(
method="mtp",
draft_sample_method="probabilistic",
rejection_sample_method="standard",
parallel_drafting=False,
)
caplog_vllm.clear()
with caplog_vllm.at_level(logging.WARNING):
config._check_watermarking_unsupported()
assert "dedup" not in caplog_vllm.text.lower()
def test_gumbel_rejects_speculative_decoding_without_target_only():
@@ -4021,3 +4151,47 @@ def test_revision_resolved_for_model(mock_resolve):
assert isinstance(config.revision, ResolvedRevision)
assert config.revision.resolved == REVISION
mock_resolve.assert_any_call(model, None, config.hf_token)
@pytest.mark.parametrize(
("layer_types", "expected_attention"),
[
# Qwen3-Next / Qwen3.5 spell their attention layers "full_attention".
(["linear_attention", "full_attention"], 1),
# GLM-5.3-Flash and Qwen4-Exp use sparse attention, which still caches
# every token and so must count as attention.
(["linear_attention", "deepseek_sparse_attention"], 1),
(["linear_attention", "qwen_sparse_attention"], 1),
(["linear_attention", "linear_attention"], 0),
],
)
def test_hybrid_layer_counts_sparse_attention_as_attention(
layer_types, expected_attention
):
"""Sparse-attention layer types consume a full attention KV cache."""
model_config = object.__new__(ModelConfig)
model_config.hf_config = SimpleNamespace()
model_config.hf_text_config = SimpleNamespace(layer_types=layer_types)
model_config.model_arch_config = SimpleNamespace(text_model_type="glm5_next")
parallel_config = SimpleNamespace()
with (
patch.object(ModelConfig, "is_hybrid", True),
patch.object(ModelConfig, "has_noops", False),
patch.object(ModelConfig, "is_attention_free", False),
patch.object(
ModelConfig,
"get_layers_start_end_indices",
return_value=(0, len(layer_types)),
),
):
assert (
model_config.get_num_layers_by_block_type(parallel_config, "attention")
== expected_attention
)
assert (
model_config.get_num_layers_by_block_type(
parallel_config, "linear_attention"
)
== len(layer_types) - expected_attention
)