| 1 | # SPDX-License-Identifier: Apache-2.0 |
| 2 | # SPDX-FileCopyrightText: Copyright contributors to the vLLM project |
| 3 | |
| 4 | import openai # use the official client for correctness check |
| 5 | import pytest |
| 6 | import pytest_asyncio |
| 7 | |
| 8 | from tests.utils import RemoteOpenAIServer |
| 9 | |
| 10 | # any model with a chat template should work here |
| 11 | MODEL_NAME = "Qwen/Qwen3-0.6B" |
| 12 | # technically this needs Mistral-7B-v0.1 as base, but we're not testing |
| 13 | # generation quality here |
| 14 | |
| 15 | |
| 16 | @pytest.fixture(scope="module") |
| 17 | def server(qwen3_lora_files): |
| 18 | args = [ |
| 19 | # use half precision for speed and memory savings in CI environment |
| 20 | "--dtype", |
| 21 | "bfloat16", |
| 22 | "--max-model-len", |
| 23 | "8192", |
| 24 | "--enforce-eager", |
| 25 | # lora config below |
| 26 | "--enable-lora", |
| 27 | "--lora-modules", |
| 28 | f"qwen3-lora={qwen3_lora_files}", |
| 29 | "--max-lora-rank", |
| 30 | "64", |
| 31 | "--max-cpu-loras", |
| 32 | "2", |
| 33 | "--max-num-seqs", |
| 34 | "128", |
| 35 | ] |
| 36 | |
| 37 | with RemoteOpenAIServer(MODEL_NAME, args) as remote_server: |
| 38 | yield remote_server |
| 39 | |
| 40 | |
| 41 | @pytest_asyncio.fixture |
| 42 | async def client(server): |
| 43 | async with server.get_async_client() as async_client: |
| 44 | yield async_client |
| 45 | |
| 46 | |
| 47 | @pytest.mark.asyncio |
| 48 | async def test_check_models(client: openai.AsyncOpenAI, qwen3_lora_files): |
| 49 | models = await client.models.list() |
| 50 | models = models.data |
| 51 | served_model = models[0] |
| 52 | lora_models = models[1:] |
| 53 | assert served_model.id == MODEL_NAME |
| 54 | assert served_model.root == MODEL_NAME |
| 55 | assert all(lora_model.root == qwen3_lora_files for lora_model in lora_models) |
| 56 | assert lora_models[0].id == "qwen3-lora" |