A high-throughput and memory-efficient inference and serving engine for LLMs
Mirrored from https://github.com/tduncan-lum/Nvidia-Optimization-Stack---VLLM.git
Synced Nov 7, 09:00 UTC
add regression test (#35834)
Signed-off-by: hallerite <git@hallerite.com>
hallerite committed
Mar 2, 2026 at 23:32 UTC
b8401cde0ebb8ea3896f809fc84d6e7ea5eb830e
1 file changed
+61
tests/entrypoints/openai/test_tokenization_vlm.py
new
+61
@@ -0,0 +1,61 @@
1
+# SPDX-License-Identifier: Apache-2.0
2
+# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
3
+"""
4
+Regression test: ``/tokenize`` must expand image placeholders for VLM models.
5
+
6
+Fixed by PR #34560 ("Move InputPreprocessor into Renderer (2/2)").
7
+Before that change, ``/tokenize`` returned ~26 tokens for a message with an
8
+image instead of the expected 1451. Confirmed broken on 0.15.1 and 0.16.0.
9
+"""
10
+
11
+import json
12
+
13
+import pytest
14
+import requests
15
+
16
+from ...utils import RemoteOpenAIServer
17
+
18
+MODEL_NAME = "Qwen/Qwen2.5-VL-3B-Instruct"
19
+
20
+
21
+@pytest.fixture(scope="module")
22
+def server():
23
+ args = [
24
+ "--dtype",
25
+ "bfloat16",
26
+ "--max-model-len",
27
+ "4096",
28
+ "--max-num-seqs",
29
+ "5",
30
+ "--enforce-eager",
31
+ "--limit-mm-per-prompt",
32
+ json.dumps({"image": 1}),
33
+ ]
34
+ with RemoteOpenAIServer(MODEL_NAME, args) as remote_server:
35
+ yield remote_server
36
+
37
+
38
+def test_tokenize_chat_expands_image_placeholders(
39
+ server: RemoteOpenAIServer,
40
+ local_asset_server,
41
+):
42
+ image_url = local_asset_server.url_for("stop_sign.jpg")
43
+ messages = [
44
+ {
45
+ "role": "user",
46
+ "content": [
47
+ {"type": "image_url", "image_url": {"url": image_url}},
48
+ {"type": "text", "text": "Describe this image."},
49
+ ],
50
+ }
51
+ ]
52
+
53
+ response = requests.post(
54
+ server.url_for("tokenize"),
55
+ json={"model": MODEL_NAME, "messages": messages},
56
+ )
57
+ response.raise_for_status()
58
+
59
+ # stop_sign.jpg (1300x876) produces 1451 tokens after expansion.
60
+ # Without expansion the count would be ~26 (text + one placeholder).
61
+ assert response.json()["count"] == 1451