test_vision_openai_server_b.py 7.2 KB
Newer Older
1
2
import unittest

3
4
5
6
7
8
9
10
from test_vision_openai_server_common import *

from sglang.test.test_utils import (
    DEFAULT_TIMEOUT_FOR_SERVER_LAUNCH,
    popen_launch_server,
)


11
class TestPixtralServer(ImageOpenAITestMixin):
12
13
14
15
16
17
18
19
20
21
22
23
    @classmethod
    def setUpClass(cls):
        cls.model = "mistral-community/pixtral-12b"
        cls.base_url = DEFAULT_URL_FOR_TEST
        cls.api_key = "sk-123456"
        cls.process = popen_launch_server(
            cls.model,
            cls.base_url,
            timeout=DEFAULT_TIMEOUT_FOR_SERVER_LAUNCH,
            other_args=[
                "--trust-remote-code",
                "--mem-fraction-static",
24
                "0.70",
25
26
                "--cuda-graph-max-bs",
                "4",
27
28
29
30
31
            ],
        )
        cls.base_url += "/v1"


32
class TestMistral3_1Server(ImageOpenAITestMixin):
33
34
35
36
37
38
39
40
41
42
43
44
    @classmethod
    def setUpClass(cls):
        cls.model = "unsloth/Mistral-Small-3.1-24B-Instruct-2503"
        cls.base_url = DEFAULT_URL_FOR_TEST
        cls.api_key = "sk-123456"
        cls.process = popen_launch_server(
            cls.model,
            cls.base_url,
            timeout=DEFAULT_TIMEOUT_FOR_SERVER_LAUNCH,
            other_args=[
                "--trust-remote-code",
                "--mem-fraction-static",
45
                "0.75",
46
47
                "--cuda-graph-max-bs",
                "4",
48
49
50
51
52
            ],
        )
        cls.base_url += "/v1"


53
class TestDeepseekVL2Server(ImageOpenAITestMixin):
54
55
56
57
58
59
60
61
62
63
64
65
66
    @classmethod
    def setUpClass(cls):
        cls.model = "deepseek-ai/deepseek-vl2-small"
        cls.base_url = DEFAULT_URL_FOR_TEST
        cls.api_key = "sk-123456"
        cls.process = popen_launch_server(
            cls.model,
            cls.base_url,
            timeout=DEFAULT_TIMEOUT_FOR_SERVER_LAUNCH,
            other_args=[
                "--trust-remote-code",
                "--context-length",
                "4096",
67
68
                "--cuda-graph-max-bs",
                "4",
69
70
71
72
73
            ],
        )
        cls.base_url += "/v1"


74
class TestJanusProServer(ImageOpenAITestMixin):
75
76
77
78
79
80
81
82
83
84
85
86
    @classmethod
    def setUpClass(cls):
        cls.model = "deepseek-ai/Janus-Pro-7B"
        cls.base_url = DEFAULT_URL_FOR_TEST
        cls.api_key = "sk-123456"
        cls.process = popen_launch_server(
            cls.model,
            cls.base_url,
            timeout=DEFAULT_TIMEOUT_FOR_SERVER_LAUNCH,
            other_args=[
                "--trust-remote-code",
                "--mem-fraction-static",
87
                "0.35",
88
89
                "--cuda-graph-max-bs",
                "4",
90
91
92
93
            ],
        )
        cls.base_url += "/v1"

94
    def test_video_images_chat_completion(self):
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
        pass


## Skip for ci test
# class TestLlama4Server(TestOpenAIVisionServer):
#     @classmethod
#     def setUpClass(cls):
#         cls.model = "meta-llama/Llama-4-Scout-17B-16E-Instruct"
#         cls.base_url = DEFAULT_URL_FOR_TEST
#         cls.api_key = "sk-123456"
#         cls.process = popen_launch_server(
#             cls.model,
#             cls.base_url,
#             timeout=DEFAULT_TIMEOUT_FOR_SERVER_LAUNCH,
#             other_args=[
#                 "--chat-template",
#                 "llama-4",
#                 "--mem-fraction-static",
#                 "0.8",
#                 "--tp-size=8",
#                 "--context-length=8192",
116
117
118
119
#                 "--mm-attention-backend",
#                 "fa3",
#                 "--cuda-graph-max-bs",
#                 "4",
120
121
122
123
124
#             ],
#         )
#         cls.base_url += "/v1"


125
class TestGemma3itServer(ImageOpenAITestMixin):
126
127
128
129
130
131
132
133
134
135
136
137
    @classmethod
    def setUpClass(cls):
        cls.model = "google/gemma-3-4b-it"
        cls.base_url = DEFAULT_URL_FOR_TEST
        cls.api_key = "sk-123456"
        cls.process = popen_launch_server(
            cls.model,
            cls.base_url,
            timeout=DEFAULT_TIMEOUT_FOR_SERVER_LAUNCH,
            other_args=[
                "--trust-remote-code",
                "--mem-fraction-static",
138
                "0.70",
139
                "--enable-multimodal",
140
141
                "--cuda-graph-max-bs",
                "4",
142
143
144
145
146
            ],
        )
        cls.base_url += "/v1"


147
class TestGemma3nServer(ImageOpenAITestMixin, AudioOpenAITestMixin):
148
149
    @classmethod
    def setUpClass(cls):
150
        cls.model = "google/gemma-3n-E4B-it"
151
152
153
154
155
156
157
158
159
160
161
        cls.base_url = DEFAULT_URL_FOR_TEST
        cls.api_key = "sk-123456"
        cls.process = popen_launch_server(
            cls.model,
            cls.base_url,
            timeout=DEFAULT_TIMEOUT_FOR_SERVER_LAUNCH,
            other_args=[
                "--trust-remote-code",
                "--mem-fraction-static",
                "0.70",
                "--cuda-graph-max-bs",
162
                "4",
163
164
165
166
            ],
        )
        cls.base_url += "/v1"

167
168
169
    # This _test_audio_ambient_completion test is way too complicated to pass for a small LLM
    def test_audio_ambient_completion(self):
        pass
170

171
172
173
    def _test_mixed_image_audio_chat_completion(self):
        self._test_mixed_image_audio_chat_completion()

174

175
class TestQwen2AudioServer(AudioOpenAITestMixin):
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
    @classmethod
    def setUpClass(cls):
        cls.model = "Qwen/Qwen2-Audio-7B-Instruct"
        cls.base_url = DEFAULT_URL_FOR_TEST
        cls.api_key = "sk-123456"
        cls.process = popen_launch_server(
            cls.model,
            cls.base_url,
            timeout=DEFAULT_TIMEOUT_FOR_SERVER_LAUNCH,
            other_args=[
                "--trust-remote-code",
                "--mem-fraction-static",
                "0.70",
            ],
        )
        cls.base_url += "/v1"


194
class TestKimiVLServer(ImageOpenAITestMixin):
Stefan He's avatar
Stefan He committed
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
    @classmethod
    def setUpClass(cls):
        cls.model = "moonshotai/Kimi-VL-A3B-Instruct"
        cls.base_url = DEFAULT_URL_FOR_TEST
        cls.api_key = "sk-123456"
        cls.process = popen_launch_server(
            cls.model,
            cls.base_url,
            timeout=DEFAULT_TIMEOUT_FOR_SERVER_LAUNCH,
            other_args=[
                "--trust-remote-code",
                "--context-length",
                "4096",
                "--dtype",
                "bfloat16",
210
211
                "--cuda-graph-max-bs",
                "4",
Stefan He's avatar
Stefan He committed
212
213
214
            ],
        )
        cls.base_url += "/v1"
215

Stefan He's avatar
Stefan He committed
216
217
    def test_video_images_chat_completion(self):
        pass
218
219


220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
# Skip for ci test
# class TestGLM41VServer(TestOpenAIVisionServer):
#     @classmethod
#     def setUpClass(cls):
#         cls.model = "zai-org/GLM-4.1V-9B-Thinking"
#         cls.base_url = DEFAULT_URL_FOR_TEST
#         cls.api_key = "sk-123456"
#         cls.process = popen_launch_server(
#             cls.model,
#             cls.base_url,
#             timeout=DEFAULT_TIMEOUT_FOR_SERVER_LAUNCH,
#             other_args=[
#                 "--trust-remote-code",
#                 "--mem-fraction-static",
#                 "0.68",
#                 "--cuda-graph-max-bs",
#                 "4",
#                 "--reasoning-parser",
#                 "glm45",
#             ],
#         )
#         cls.base_url += "/v1"

#     def test_video_chat_completion(self):
#         self._test_video_chat_completion()


247
if __name__ == "__main__":
248
249
250
251
252
253
    del (
        TestOpenAIOmniServerBase,
        ImageOpenAITestMixin,
        VideoOpenAITestMixin,
        AudioOpenAITestMixin,
    )
254
    unittest.main()