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