[MyPy][3/N] Fix MyPy errors in test groups (part 3) (#55939)
Signed-off-by: Taimys <ffy2281693949@gmail.com> Signed-off-by: Luyi Xiao <81631911+luyixiao95@users.noreply.github.com> Signed-off-by: Harry Mellor <19981378+hmellor@users.noreply.github.com> Co-authored-by: Codex <noreply@openai.com> Co-authored-by: Luyi Xiao <81631911+luyixiao95@users.noreply.github.com> Co-authored-by: Taimys <ffy2281693949@gmail.com> Co-authored-by: Harry Mellor <19981378+hmellor@users.noreply.github.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Codex
Luyi Xiao
Taimys
Harry Mellor
Claude Opus 5.5
parent
c4fa6f36a7
commit
5225f1bacb
@@ -2,6 +2,7 @@
|
||||
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
|
||||
|
||||
import time
|
||||
from collections.abc import Sequence
|
||||
from contextlib import nullcontext
|
||||
from copy import deepcopy
|
||||
from types import SimpleNamespace
|
||||
@@ -868,7 +869,7 @@ def test_limit_mm_per_prompt_apply(model_id, num_images, limit, is_valid):
|
||||
],
|
||||
)
|
||||
def test_budget_caps_prevent_dummy_input_validation_failure(
|
||||
model_id, user_limit, supported_limit
|
||||
model_id, user_limit, supported_limit, monkeypatch
|
||||
):
|
||||
limit_mm_per_prompt = {"image": user_limit}
|
||||
|
||||
@@ -878,7 +879,9 @@ def test_budget_caps_prevent_dummy_input_validation_failure(
|
||||
)
|
||||
|
||||
processor = MULTIMODAL_REGISTRY.create_processor(model_config)
|
||||
processor.info.get_supported_mm_limits = lambda: {"image": supported_limit}
|
||||
monkeypatch.setattr(
|
||||
processor.info, "get_supported_mm_limits", lambda: {"image": supported_limit}
|
||||
)
|
||||
|
||||
# This is what budget.py uses to derive mm_counts
|
||||
allowed = processor.info.allowed_mm_limits
|
||||
@@ -936,7 +939,7 @@ def test_hf_processor_init_kwargs(
|
||||
)
|
||||
|
||||
processor = ctx.get_hf_processor(
|
||||
DummyProcessor, # type: ignore[arg-type]
|
||||
DummyProcessor,
|
||||
**inference_kwargs,
|
||||
)
|
||||
assert processor.a == expected_kwargs["a"]
|
||||
@@ -967,7 +970,7 @@ def test_hf_processor_call_kwargs(
|
||||
tokenizer=None,
|
||||
)
|
||||
|
||||
processor = ctx.get_hf_processor(DummyProcessor) # type: ignore[arg-type]
|
||||
processor = ctx.get_hf_processor(DummyProcessor)
|
||||
|
||||
result = ctx.call_hf_processor(processor, {}, inference_kwargs)
|
||||
assert result == expected_kwargs
|
||||
@@ -1278,7 +1281,7 @@ def test_get_supported_mm_processor_kwargs_uses_supported_modalities(
|
||||
processor: SimpleNamespace,
|
||||
expected: dict[str, set[str]],
|
||||
) -> None:
|
||||
info = BaseProcessingInfo(SimpleNamespace())
|
||||
info = BaseProcessingInfo(SimpleNamespace()) # type: ignore[arg-type]
|
||||
info.__dict__["supported_mm_limits"] = supported_mm_limits
|
||||
monkeypatch.setattr(info, "get_hf_processor", lambda **_: processor)
|
||||
|
||||
@@ -1288,7 +1291,7 @@ def test_get_supported_mm_processor_kwargs_uses_supported_modalities(
|
||||
def test_supported_mm_processor_kwargs_is_cached(
|
||||
monkeypatch: pytest.MonkeyPatch,
|
||||
) -> None:
|
||||
info = BaseProcessingInfo(SimpleNamespace())
|
||||
info = BaseProcessingInfo(SimpleNamespace()) # type: ignore[arg-type]
|
||||
expected = {"images_kwargs": {"size"}}
|
||||
calls = 0
|
||||
|
||||
@@ -1541,7 +1544,10 @@ def test_processor_inputs_hashes_scope_kwargs_by_modality():
|
||||
"video": [np.zeros((2, 8, 8, 3), dtype=np.uint8)],
|
||||
}
|
||||
)
|
||||
mm_uuid_items = {"image": ["image-uuid"], "video": ["video-uuid"]}
|
||||
mm_uuid_items: dict[str, Sequence[str | None]] = {
|
||||
"image": ["image-uuid"],
|
||||
"video": ["video-uuid"],
|
||||
}
|
||||
|
||||
def get_hashes(video_frames: int, image_size: int, video_size: int):
|
||||
return ProcessorInputs(
|
||||
@@ -1621,7 +1627,7 @@ def test_processor_inputs_hashes_distinguish_kwargs_shapes(left, right):
|
||||
[(None, 491520, 491520), (True, 491520, 8192), (True, 128, 128), (False, 128, 128)],
|
||||
)
|
||||
def test_dummy_inputs_scheduler_budget(
|
||||
chunked_prefill, max_model_len, expected_seq_len
|
||||
chunked_prefill, max_model_len, expected_seq_len, monkeypatch
|
||||
):
|
||||
ctx = build_model_context(
|
||||
"llava-hf/llava-v1.6-mistral-7b-hf",
|
||||
@@ -1634,11 +1640,9 @@ def test_dummy_inputs_scheduler_budget(
|
||||
ctx.model_config,
|
||||
tokenizer=ctx.tokenizer,
|
||||
)
|
||||
processor.apply = lambda *args, **kwargs: {"prompt_token_ids": [7]}
|
||||
|
||||
kwargs = {}
|
||||
scheduler_config = None
|
||||
if chunked_prefill is not None:
|
||||
kwargs["scheduler_config"] = SchedulerConfig(
|
||||
scheduler_config = SchedulerConfig(
|
||||
max_model_len=max_model_len,
|
||||
is_encoder_decoder=False,
|
||||
max_num_batched_tokens=8192,
|
||||
@@ -1646,5 +1650,10 @@ def test_dummy_inputs_scheduler_budget(
|
||||
enable_chunked_prefill=chunked_prefill,
|
||||
)
|
||||
|
||||
result = processor.get_dummy_mm_inputs({"image": 1}, **kwargs)
|
||||
monkeypatch.setattr(
|
||||
processor, "apply", lambda *args, **kwargs: {"prompt_token_ids": [7]}
|
||||
)
|
||||
result = processor.get_dummy_mm_inputs(
|
||||
{"image": 1}, scheduler_config=scheduler_config
|
||||
)
|
||||
assert len(result["prompt_token_ids"]) == expected_seq_len
|
||||
|
||||
Reference in New Issue
Block a user