Convert formatting to use ruff instead of yapf + isort (#26247)
Signed-off-by: Harry Mellor <19981378+hmellor@users.noreply.github.com>
This commit is contained in:
@@ -8,13 +8,19 @@ import pytest
|
||||
|
||||
from vllm import LLM
|
||||
from vllm.utils import GiB_bytes
|
||||
from vllm.v1.core.kv_cache_utils import (generate_scheduler_kv_cache_config,
|
||||
get_kv_cache_configs)
|
||||
from vllm.v1.core.kv_cache_utils import (
|
||||
generate_scheduler_kv_cache_config,
|
||||
get_kv_cache_configs,
|
||||
)
|
||||
from vllm.v1.engine.core import EngineCore as V1EngineCore
|
||||
|
||||
from ..utils import create_new_process_for_each_test
|
||||
from .registry import (_TRANSFORMERS_BACKEND_MODELS, AUTO_EXAMPLE_MODELS,
|
||||
HF_EXAMPLE_MODELS, HfExampleModels)
|
||||
from .registry import (
|
||||
_TRANSFORMERS_BACKEND_MODELS,
|
||||
AUTO_EXAMPLE_MODELS,
|
||||
HF_EXAMPLE_MODELS,
|
||||
HfExampleModels,
|
||||
)
|
||||
from .utils import dummy_hf_overrides
|
||||
|
||||
# This minimal list of model architectures is smaller than the total list of
|
||||
@@ -24,23 +30,32 @@ from .utils import dummy_hf_overrides
|
||||
# generation, sequence classification, causal LM, ranking, chat, reward model,
|
||||
# multimodal, geospatial, voice, embedding, MTP)
|
||||
MINIMAL_MODEL_ARCH_LIST = [
|
||||
"LlavaForConditionalGeneration", "Llama4ForConditionalGeneration",
|
||||
"BertForSequenceClassification", "Gemma3nForCausalLM", "JinaVLForRanking",
|
||||
"InternVLChatModel", "InternLM2ForRewardModel",
|
||||
"TransformersForMultimodalLM", "PrithviGeoSpatialMAE", "UltravoxModel",
|
||||
"DeepSeekMTPModel", "XLMRobertaModel"
|
||||
"LlavaForConditionalGeneration",
|
||||
"Llama4ForConditionalGeneration",
|
||||
"BertForSequenceClassification",
|
||||
"Gemma3nForCausalLM",
|
||||
"JinaVLForRanking",
|
||||
"InternVLChatModel",
|
||||
"InternLM2ForRewardModel",
|
||||
"TransformersForMultimodalLM",
|
||||
"PrithviGeoSpatialMAE",
|
||||
"UltravoxModel",
|
||||
"DeepSeekMTPModel",
|
||||
"XLMRobertaModel",
|
||||
]
|
||||
|
||||
# This list is the complement of the minimal list above. The intention is that
|
||||
# this list of models is only tested in a "special case" i.e. most PRs should
|
||||
# not test these models
|
||||
OTHER_MODEL_ARCH_LIST = (set(HF_EXAMPLE_MODELS.get_supported_archs()) -
|
||||
set(MINIMAL_MODEL_ARCH_LIST))
|
||||
OTHER_MODEL_ARCH_LIST = set(HF_EXAMPLE_MODELS.get_supported_archs()) - set(
|
||||
MINIMAL_MODEL_ARCH_LIST
|
||||
)
|
||||
|
||||
|
||||
@create_new_process_for_each_test()
|
||||
def can_initialize(model_arch: str, monkeypatch: pytest.MonkeyPatch,
|
||||
EXAMPLE_MODELS: HfExampleModels):
|
||||
def can_initialize(
|
||||
model_arch: str, monkeypatch: pytest.MonkeyPatch, EXAMPLE_MODELS: HfExampleModels
|
||||
):
|
||||
"""The reason for using create_new_process_for_each_test is to avoid
|
||||
the WARNING:
|
||||
"We must use the 'spawn' multiprocessing start method. Overriding
|
||||
@@ -53,12 +68,12 @@ def can_initialize(model_arch: str, monkeypatch: pytest.MonkeyPatch,
|
||||
model_info.check_available_online(on_fail="skip")
|
||||
model_info.check_transformers_version(on_fail="skip")
|
||||
|
||||
hf_overrides_fn = partial(dummy_hf_overrides,
|
||||
model_arch=model_arch,
|
||||
exist_overrides=model_info.hf_overrides,
|
||||
use_original_num_layers=getattr(
|
||||
model_info, 'use_original_num_layers',
|
||||
False))
|
||||
hf_overrides_fn = partial(
|
||||
dummy_hf_overrides,
|
||||
model_arch=model_arch,
|
||||
exist_overrides=model_info.hf_overrides,
|
||||
use_original_num_layers=getattr(model_info, "use_original_num_layers", False),
|
||||
)
|
||||
|
||||
# Avoid calling model.forward()
|
||||
def _initialize_kv_caches_v1(self, vllm_config):
|
||||
@@ -68,14 +83,15 @@ def can_initialize(model_arch: str, monkeypatch: pytest.MonkeyPatch,
|
||||
kv_cache_specs,
|
||||
[10 * GiB_bytes],
|
||||
)
|
||||
scheduler_kv_cache_config = generate_scheduler_kv_cache_config(
|
||||
kv_cache_configs)
|
||||
scheduler_kv_cache_config = generate_scheduler_kv_cache_config(kv_cache_configs)
|
||||
|
||||
# gpu_blocks (> 0), cpu_blocks, scheduler_kv_cache_config
|
||||
return 1, 0, scheduler_kv_cache_config
|
||||
|
||||
with (patch.object(V1EngineCore, "_initialize_kv_caches",
|
||||
_initialize_kv_caches_v1), monkeypatch.context() as m):
|
||||
with (
|
||||
patch.object(V1EngineCore, "_initialize_kv_caches", _initialize_kv_caches_v1),
|
||||
monkeypatch.context() as m,
|
||||
):
|
||||
if model_info.v0_only:
|
||||
# NOTE(woosuk): skip the test for V0-only models
|
||||
return
|
||||
@@ -97,21 +113,24 @@ def can_initialize(model_arch: str, monkeypatch: pytest.MonkeyPatch,
|
||||
speculative_config={
|
||||
"model": model_info.speculative_model,
|
||||
"num_speculative_tokens": 1,
|
||||
} if model_info.speculative_model else None,
|
||||
}
|
||||
if model_info.speculative_model
|
||||
else None,
|
||||
trust_remote_code=model_info.trust_remote_code,
|
||||
max_model_len=model_info.max_model_len,
|
||||
# these tests seem to produce leftover memory
|
||||
gpu_memory_utilization=0.80,
|
||||
load_format="dummy",
|
||||
model_impl="transformers"
|
||||
if model_arch in _TRANSFORMERS_BACKEND_MODELS else "vllm",
|
||||
if model_arch in _TRANSFORMERS_BACKEND_MODELS
|
||||
else "vllm",
|
||||
hf_overrides=hf_overrides_fn,
|
||||
max_num_seqs=model_info.max_num_seqs)
|
||||
max_num_seqs=model_info.max_num_seqs,
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.parametrize("model_arch", MINIMAL_MODEL_ARCH_LIST)
|
||||
def test_can_initialize_small_subset(model_arch: str,
|
||||
monkeypatch: pytest.MonkeyPatch):
|
||||
def test_can_initialize_small_subset(model_arch: str, monkeypatch: pytest.MonkeyPatch):
|
||||
"""Test initializing small subset of supported models"""
|
||||
if model_arch == "Lfm2ForCausalLM":
|
||||
pytest.skip("Skipping until test supports V1-only models")
|
||||
@@ -119,10 +138,9 @@ def test_can_initialize_small_subset(model_arch: str,
|
||||
|
||||
|
||||
@pytest.mark.parametrize("model_arch", OTHER_MODEL_ARCH_LIST)
|
||||
def test_can_initialize_large_subset(model_arch: str,
|
||||
monkeypatch: pytest.MonkeyPatch):
|
||||
def test_can_initialize_large_subset(model_arch: str, monkeypatch: pytest.MonkeyPatch):
|
||||
"""Test initializing large subset of supported models
|
||||
|
||||
|
||||
This test covers the complement of the tests covered in the "small subset"
|
||||
test.
|
||||
"""
|
||||
@@ -131,8 +149,6 @@ def test_can_initialize_large_subset(model_arch: str,
|
||||
can_initialize(model_arch, monkeypatch, HF_EXAMPLE_MODELS)
|
||||
|
||||
|
||||
@pytest.mark.parametrize("model_arch",
|
||||
AUTO_EXAMPLE_MODELS.get_supported_archs())
|
||||
def test_implicit_converted_models(model_arch: str,
|
||||
monkeypatch: pytest.MonkeyPatch):
|
||||
@pytest.mark.parametrize("model_arch", AUTO_EXAMPLE_MODELS.get_supported_archs())
|
||||
def test_implicit_converted_models(model_arch: str, monkeypatch: pytest.MonkeyPatch):
|
||||
can_initialize(model_arch, monkeypatch, AUTO_EXAMPLE_MODELS)
|
||||
|
||||
Reference in New Issue
Block a user