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
+2 -2
View File
@@ -133,7 +133,7 @@ def test_get_diff_sampling_param_includes_penalties():
},
)
diff = ModelConfig.get_diff_sampling_param(fake) # type: ignore[arg-type]
diff = ModelConfig.get_diff_sampling_param(fake)
assert diff["presence_penalty"] == 1.5
assert diff["frequency_penalty"] == 0.5
@@ -161,7 +161,7 @@ def test_generation_config_penalties_survive_diff_sampling_filter():
},
)
diff = ModelConfig.get_diff_sampling_param(fake) # type: ignore[arg-type]
diff = ModelConfig.get_diff_sampling_param(fake)
assert diff["presence_penalty"] == 1.1
assert diff["frequency_penalty"] == 0.7
+61 -2
View File
@@ -8,7 +8,12 @@ import pytest
from vllm.config.cache import CacheConfig
from vllm.config.scheduler import SchedulerConfig
from vllm.config.utils import get_hash_factors, hash_factors, normalize_value
from vllm.config.utils import (
get_attr_docs,
get_hash_factors,
hash_factors,
normalize_value,
)
# Helpers
@@ -114,7 +119,7 @@ def test_normalize_value_uuid_and_to_json():
[
(lambda x: x),
(type("CallableInstance", (), {"__call__": lambda self: 0}))(),
(lambda: (lambda: 0))(), # nested function instance
(lambda: lambda: 0)(), # nested function instance
],
)
def test_error_cases(bad):
@@ -168,6 +173,53 @@ def test_classes_are_types():
assert endswith_fqname(LocalDummy, ".LocalDummy")
def test_ir_config_hash_initializes_provider_and_tracks_implementation(monkeypatch):
from types import SimpleNamespace
from vllm.config.kernel import IrOpPriorityConfig
from vllm.ir.op import IrOp
from vllm.platforms import current_platform
op = IrOp.registry["rms_norm"]
implementation = SimpleNamespace(uuid=lambda: "first-implementation")
def import_ir_kernels():
monkeypatch.setitem(op.impls, "test_lazy_provider", implementation)
monkeypatch.setattr(current_platform, "import_ir_kernels", import_ir_kernels)
config = IrOpPriorityConfig(rms_norm=["test_lazy_provider"])
first_hash = config.compute_hash()
assert config.compute_hash() == first_hash
implementation.uuid = lambda: "changed-implementation"
assert config.compute_hash() != first_hash
def test_get_attr_docs_includes_inherited_fields():
"""get_attr_docs must collect attribute docstrings inherited from base
classes, not just those declared in the class's own body."""
@dataclass
class Base:
inherited: object = None
"""doc for inherited (base)."""
overridden: object = None
"""base version of overridden."""
@dataclass
class Derived(Base):
own: object = None
"""doc for own (derived)."""
overridden: object = None
"""derived override of overridden."""
docs = get_attr_docs(Derived)
assert docs["own"] == "doc for own (derived)."
assert docs["inherited"] == "doc for inherited (base)."
assert docs["overridden"] == "derived override of overridden."
def test_envs_compile_factors_stable():
"""Test that envs.compile_factors() hash is stable across fresh initializations.
@@ -303,3 +355,10 @@ print(hash_factors(envs.compile_factors()))
"HOME relocation changed the compile-cache env hash - a "
"location-only derived var is leaking into the key"
)
def test_get_attr_docs_rejects_non_class():
"""The annotation forbids it, but the runtime guard still protects
untyped callers, so keep asserting the documented TypeError."""
with pytest.raises(TypeError, match="Given object was not a class."):
get_attr_docs(object()) # type: ignore[arg-type]
+42 -5
View File
@@ -40,18 +40,18 @@ def test_supports_multimodal_inputs(model_id, limit_mm_per_prompt, expected):
def test_mm_encoder_attn_backend_str_conversion():
config = MultiModalConfig(mm_encoder_attn_backend="FLASH_ATTN") # type: ignore[arg-type]
config = MultiModalConfig(mm_encoder_attn_backend="FLASH_ATTN")
assert config.mm_encoder_attn_backend == AttentionBackendEnum.FLASH_ATTN
def test_mm_encoder_attn_backend_invalid():
with pytest.raises(ValueError):
MultiModalConfig(mm_encoder_attn_backend="not_a_backend") # type: ignore[arg-type]
MultiModalConfig(mm_encoder_attn_backend="not_a_backend")
def test_mm_hasher_algorithm_invalid():
with pytest.raises(ValueError, match="mm_hasher_algorithm"):
MultiModalConfig(mm_hasher_algorithm="md5") # type: ignore[arg-type]
MultiModalConfig(mm_hasher_algorithm="md5")
def test_mm_encoder_attn_backend_hash_updates():
@@ -240,6 +240,43 @@ def test_merge_mm_processor_kwargs_scoped_precedence():
}
def test_merge_mm_processor_kwargs_preserves_scoped_siblings_and_precedence():
config = MultiModalConfig(
mm_processor_kwargs={
"size": {
"shortest_edge": 100,
"longest_edge": 1000,
},
"videos_kwargs": {
"fps": 2,
"size": {"longest_edge": 1200},
},
},
mm_device_do_normalize=False,
)
assert config.merge_mm_processor_kwargs(
{
"size": {"longest_edge": 1800},
"videos_kwargs": {
"size": {"shortest_edge": 200},
},
}
) == {
"size": {
"shortest_edge": 100,
"longest_edge": 1800,
},
"videos_kwargs": {
"fps": 2,
"size": {
"shortest_edge": 200,
"longest_edge": 1800,
},
},
}
def test_merge_mm_processor_kwargs_mapping_vs_replacement():
config = MultiModalConfig(
mm_processor_kwargs={
@@ -523,7 +560,7 @@ def _resolve_mm_processor_device(
"""Run the `auto` resolution and report where the processor ended up."""
mm_config = MultiModalConfig(
mm_processor_kwargs={} if device is None else {"device": device},
mm_tensor_ipc=mm_tensor_ipc, # type: ignore[arg-type]
mm_tensor_ipc=mm_tensor_ipc,
)
model_config = MagicMock(spec=ModelConfig)
model_config.multimodal_config = mm_config
@@ -625,7 +662,7 @@ def _resolve_mm_video_decode_device(
the resulting video media IO kwargs."""
mm_config = MultiModalConfig(
mm_processor_kwargs={} if device is None else {"device": device},
mm_tensor_ipc=mm_tensor_ipc, # type: ignore[arg-type]
mm_tensor_ipc=mm_tensor_ipc,
media_io_kwargs={} if video_kwargs is None else {"video": dict(video_kwargs)},
)
model_config = MagicMock(spec=ModelConfig)
+53
View File
@@ -0,0 +1,53 @@
# SPDX-License-Identifier: Apache-2.0
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
"""Tests for ObservabilityConfig validation."""
import pytest
from pydantic import ValidationError
from vllm.config.observability import ObservabilityConfig
def test_custom_histogram_buckets_default_none():
assert ObservabilityConfig().custom_histogram_buckets is None
def test_custom_histogram_buckets_valid():
config = ObservabilityConfig(
custom_histogram_buckets={
"request_latency": [0.01, 0.05, 0.1, 0.5],
"time_to_first_token": [1, 2, 5],
}
)
assert config.custom_histogram_buckets == {
"request_latency": [0.01, 0.05, 0.1, 0.5],
"time_to_first_token": [1.0, 2.0, 5.0],
}
@pytest.mark.parametrize(
("buckets", "match"),
[
({"bogus": [1.0, 2.0]}, "unknown bucket family 'bogus'"),
({"request_latency": []}, "must not be empty"),
({"request_latency": [0.0, 1.0]}, "must be finite and greater than 0"),
({"request_latency": [-1.0, 1.0]}, "must be finite and greater than 0"),
(
{"request_latency": [1.0, float("inf")]},
"must be finite and greater than 0",
),
({"request_latency": [float("nan")]}, "must be finite and greater than 0"),
({"request_latency": [1.0, 1.0]}, "must be strictly increasing"),
({"request_latency": [2.0, 1.0]}, "must be strictly increasing"),
({"request_latency": [True, 2.0]}, "must be a number, not a boolean"),
({"request_latency": [False]}, "must be a number, not a boolean"),
(
{"request_latency": [1.0, 2.0], "request_tokens": [16, 8]},
r"request_tokens.*must be strictly increasing",
),
],
)
def test_custom_histogram_buckets_rejects_invalid(buckets, match):
"""Each validation rule must name the field, the value, and the rule."""
with pytest.raises(ValidationError, match=match):
ObservabilityConfig(custom_histogram_buckets=buckets)