|
| 1 | +import warnings |
| 2 | + |
1 | 3 | import pytest
|
| 4 | +import torch.cuda |
2 | 5 |
|
3 | 6 | from vllm.model_executor.models import _MODELS, ModelRegistry
|
4 | 7 |
|
| 8 | +from ..utils import fork_new_process_for_each_test |
| 9 | + |
5 | 10 |
|
6 |
| -@pytest.mark.parametrize("model_cls", _MODELS) |
7 |
| -def test_registry_imports(model_cls): |
| 11 | +@pytest.mark.parametrize("model_arch", _MODELS) |
| 12 | +def test_registry_imports(model_arch): |
8 | 13 | # Ensure all model classes can be imported successfully
|
9 |
| - ModelRegistry.resolve_model_cls([model_cls]) |
| 14 | + ModelRegistry.resolve_model_cls(model_arch) |
10 | 15 |
|
11 | 16 |
|
12 |
| -@pytest.mark.parametrize("model_cls,is_mm", [ |
13 |
| - ("LlamaForCausalLM", False), |
14 |
| - ("MllamaForConditionalGeneration", True), |
| 17 | +@fork_new_process_for_each_test |
| 18 | +@pytest.mark.parametrize("model_arch,is_mm,init_cuda", [ |
| 19 | + ("LlamaForCausalLM", False, False), |
| 20 | + ("MllamaForConditionalGeneration", True, False), |
| 21 | + ("LlavaForConditionalGeneration", True, True), |
15 | 22 | ])
|
16 |
| -def test_registry_is_multimodal(model_cls, is_mm): |
17 |
| - assert ModelRegistry.is_multimodal_model(model_cls) is is_mm |
| 23 | +def test_registry_is_multimodal(model_arch, is_mm, init_cuda): |
| 24 | + assert ModelRegistry.is_multimodal_model(model_arch) is is_mm |
| 25 | + |
| 26 | + if init_cuda: |
| 27 | + assert not torch.cuda.is_initialized() |
18 | 28 |
|
| 29 | + ModelRegistry.resolve_model_cls(model_arch) |
| 30 | + if not torch.cuda.is_initialized(): |
| 31 | + warnings.warn( |
| 32 | + "This model no longer initializes CUDA on import. " |
| 33 | + "Please test using a different model.", |
| 34 | + stacklevel=2) |
19 | 35 |
|
20 |
| -@pytest.mark.parametrize("model_cls,is_pp", [ |
21 |
| - ("MLPSpeculatorPreTrainedModel", False), |
22 |
| - ("DeepseekV2ForCausalLM", True), |
| 36 | + |
| 37 | +@fork_new_process_for_each_test |
| 38 | +@pytest.mark.parametrize("model_arch,is_pp,init_cuda", [ |
| 39 | + ("MLPSpeculatorPreTrainedModel", False, False), |
| 40 | + ("DeepseekV2ForCausalLM", True, False), |
| 41 | + ("Qwen2VLForConditionalGeneration", True, True), |
23 | 42 | ])
|
24 |
| -def test_registry_is_pp(model_cls, is_pp): |
25 |
| - assert ModelRegistry.is_pp_supported_model(model_cls) is is_pp |
| 43 | +def test_registry_is_pp(model_arch, is_pp, init_cuda): |
| 44 | + assert ModelRegistry.is_pp_supported_model(model_arch) is is_pp |
| 45 | + |
| 46 | + if init_cuda: |
| 47 | + assert not torch.cuda.is_initialized() |
| 48 | + |
| 49 | + ModelRegistry.resolve_model_cls(model_arch) |
| 50 | + if not torch.cuda.is_initialized(): |
| 51 | + warnings.warn( |
| 52 | + "This model no longer initializes CUDA on import. " |
| 53 | + "Please test using a different model.", |
| 54 | + stacklevel=2) |
0 commit comments