Merge branch 'main' into patches

Signed-off-by: MOVZX <movzx@yahoo.com>
This commit is contained in:
2026-10-15 21:16:39 +07:00
1693 changed files with 99919 additions and 32440 deletions
+73 -69
View File
@@ -290,6 +290,28 @@ def test_mamba_cache_mode_all_is_rejected():
CacheConfig(mamba_cache_mode="all")
@pytest.mark.parametrize(
("cache_dtype", "model_dtype", "should_raise"),
[
("float16", torch.bfloat16, True),
("bfloat16", torch.float16, True),
("float16", torch.float32, True),
("float16", torch.float16, False),
("auto", torch.bfloat16, False),
("fp8", torch.bfloat16, False),
],
)
def test_mismatched_float_kv_cache_is_rejected(cache_dtype, model_dtype, should_raise):
config = VllmConfig(cache_config=CacheConfig(cache_dtype=cache_dtype))
config.model_config = SimpleNamespace(dtype=model_dtype)
if should_raise:
with pytest.raises(ValueError, match="kv_cache_dtype"):
config._reject_mismatched_float_kv_cache()
else:
config._reject_mismatched_float_kv_cache()
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
@@ -651,21 +673,14 @@ def test_no_hisparse_connector_keeps_attention_config_unset(monkeypatch):
def test_rocm_keeps_compiled_deepseek_defaults(monkeypatch):
"""ROCm keeps the DSA models (DeepSeek V3.2/V4, GLM-5.2) on their compiled
MRV1 paths and off breakable cudagraphs by default."""
from vllm.config.vllm import (
ROCM_DEFAULT_MRV1_ARCHITECTURES,
default_breakable_cudagraph_architectures,
)
paths and off breakable cudagraphs by default."""
from vllm.config.vllm import default_breakable_cudagraph_architectures
from vllm.platforms import current_platform
monkeypatch.setattr(current_platform, "is_rocm", lambda: True)
# The lookup is lru_cached against a fixed platform.
default_breakable_cudagraph_architectures.cache_clear()
try:
assert "DeepseekV32ForCausalLM" in ROCM_DEFAULT_MRV1_ARCHITECTURES
assert "DeepseekV4ForCausalLM" in ROCM_DEFAULT_MRV1_ARCHITECTURES
assert "GlmMoeDsaForCausalLM" in ROCM_DEFAULT_MRV1_ARCHITECTURES
breakable_architectures = default_breakable_cudagraph_architectures()
assert "DeepseekV32ForCausalLM" not in breakable_architectures
assert "DeepseekV32MTPModel" not in breakable_architectures
@@ -674,66 +689,10 @@ def test_rocm_keeps_compiled_deepseek_defaults(monkeypatch):
# supports uniform-batch CUDA graphs, so it must opt in or the
# default FULL_AND_PIECEWISE serve path cannot start.
assert "DeepseekV41ForCausalLM" in breakable_architectures
# The carve-out takes effect via the runner-selection property
# (warning_once args must be hashable for its lru_cache).
monkeypatch.delenv("VLLM_USE_V2_MODEL_RUNNER", raising=False)
config = SimpleNamespace(
model_config=SimpleNamespace(architectures=["DeepseekV32ForCausalLM"]),
attention_config=AttentionConfig(),
)
config._get_v1_model_runner_unsupported_features = lambda: []
assert VllmConfig.use_v2_model_runner.fget(config) is False
finally:
default_breakable_cudagraph_architectures.cache_clear()
def test_rocm_mrv1_default_yields_to_v1_unsupported_config(monkeypatch):
"""The ROCm V1 default is a speed preference, not a capability claim.
DSpark runs only on V2, so pinning DeepSeek V4 to V1 would fail config
validation instead of serving it. With nothing V1 refuses, it still holds.
"""
from vllm.platforms import current_platform
monkeypatch.setattr(current_platform, "is_rocm", lambda: True)
monkeypatch.setattr(vllm_config_module, "HAS_TRITON", True)
monkeypatch.delenv("VLLM_USE_V2_MODEL_RUNNER", raising=False)
config = SimpleNamespace(
model_config=SimpleNamespace(
architectures=["DeepseekV4ForCausalLM"], is_diffusion=False
),
attention_config=AttentionConfig(),
parallel_config=SimpleNamespace(
prefill_context_parallel_size=1,
pipeline_parallel_size=1,
enable_batch_sharded_sampling=False,
),
scheduler_config=SimpleNamespace(async_scheduling=False),
speculative_config=None,
)
config._dflash_needs_multi_kv_group = lambda: False
config._is_dflash_candidate_draft = lambda: False
config._get_v2_model_runner_unsupported_features = lambda: []
# The real predicate, so the test also pins where dspark lands in it.
config._get_v1_model_runner_unsupported_features = lambda: (
VllmConfig._get_v1_model_runner_unsupported_features(config)
)
assert VllmConfig.use_v2_model_runner.fget(config) is False
config.speculative_config = SimpleNamespace(
method="dspark", enable_adaptive_verification=False
)
assert VllmConfig.use_v2_model_runner.fget(config) is True
# Yielding is not the same as selecting V2: the later checks still run, so
# a config neither runner can serve lands on V1 and fails validation there.
config._get_v2_model_runner_unsupported_features = lambda: ["sequence parallelism"]
assert VllmConfig.use_v2_model_runner.fget(config) is False
@pytest.mark.parametrize(
("model", "architecture"),
[
@@ -2083,9 +2042,7 @@ def test_draft_inherits_ep_only_for_moe(
draft_is_moe: bool,
):
"""Validate final draft configs without loading weights or mocking validation."""
from transformers import LlamaConfig, MixtralConfig
from vllm.transformers_utils.configs.deepseek_v4 import DeepseekV4Config
from transformers import DeepseekV4Config, LlamaConfig, MixtralConfig
common = dict(
hidden_size=128,
@@ -2102,7 +2059,7 @@ def test_draft_inherits_ep_only_for_moe(
n_routed_experts=4,
num_experts_per_tok=2,
num_nextn_predict_layers=1,
compress_ratios=[1, 1],
layer_types=["sliding_attention"] * 2,
head_dim=32,
**common,
)
@@ -3523,6 +3480,12 @@ def test_scheduler_config_init():
print(SchedulerConfig.default_factory().max_model_len)
def test_scheduler_config_rejects_zero_max_num_scheduled_tokens():
"""A zero token budget never schedules anything, so generation would hang."""
with pytest.raises(ValidationError, match="max_num_scheduled_tokens"):
SchedulerConfig.default_factory(max_num_scheduled_tokens=0)
@pytest.mark.parametrize(
(
"model_id",
@@ -4203,6 +4166,47 @@ def test_revision_resolved_for_model(mock_resolve):
mock_resolve.assert_any_call(model, None, config.hf_token)
@pytest.mark.parametrize(
"enabled,supported,is_cuda,tp_size,pp_size,error",
[
(True, True, True, 2, 1, None),
(True, False, True, 2, 1, "not supported for this model"),
(True, True, False, 2, 1, "requires CUDA"),
(True, True, True, 1, 1, None),
(True, False, False, 1, 2, None),
(True, True, True, 2, 2, "requires PP=1"),
(False, False, False, 2, 1, None),
],
)
def test_hc_sp_model_support(enabled, supported, is_cuda, tp_size, pp_size, error):
"""Validate active HC SP configurations and ignore the flag with TP=1."""
from vllm.model_executor.models.registry import ModelRegistry
model = SimpleNamespace(
architectures=["HCModel"],
registry=ModelRegistry,
model_arch_config=SimpleNamespace(total_num_attention_heads=8),
multimodal_config=None,
)
parallel = ParallelConfig(
enable_hc_sp=enabled,
tensor_parallel_size=tp_size,
pipeline_parallel_size=pp_size,
# Avoid backend auto-detection in this config-only test.
distributed_executor_backend="mp",
)
with (
patch("vllm.config.model.current_platform.is_cuda", return_value=is_cuda),
patch.object(ModelRegistry, "is_hc_sp_supported_model", return_value=supported),
patch.object(ModelRegistry, "is_pp_supported_model", return_value=True),
):
if error:
with pytest.raises(ValueError, match=error):
ModelConfig.verify_with_parallel_config(model, parallel)
else:
ModelConfig.verify_with_parallel_config(model, parallel)
@pytest.mark.parametrize(
("layer_types", "expected_attention"),
[