Skip to content

Commit 7e0a78c

Browse files
Merge pull request #8 from alphabetc1/fix/benchmark
2 parents 4b8b6d2 + 0ec855f commit 7e0a78c

10 files changed

Lines changed: 37 additions & 83 deletions

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,9 @@ cython_debug/
188188
# you could uncomment the following to ignore the entire vscode folder
189189
.vscode/
190190

191+
# sglang diffusion worker generated outputs
192+
outputs/
193+
191194
# Ruff stuff:
192195
.ruff_cache/
193196

README.md

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,14 @@ uv pip install "sglang[diffusion]" --prerelease=allow
3838
```bash
3939
# worker 1
4040
SGLANG_USE_MODELSCOPE=TRUE CUDA_VISIBLE_DEVICES=0 sglang serve \
41-
--model-path stabilityai/stable-diffusion-3-medium-diffusers \
41+
--model-path Qwen/Qwen-Image \
4242
--num-gpus 1 \
4343
--host 127.0.0.1 \
4444
--port 30000
4545

4646
# worker 2
4747
SGLANG_USE_MODELSCOPE=TRUE CUDA_VISIBLE_DEVICES=1 sglang serve \
48-
--model-path stabilityai/stable-diffusion-3-medium-diffusers \
48+
--model-path Qwen/Qwen-Image \
4949
--num-gpus 1 \
5050
--host 127.0.0.1 \
5151
--port 30001
@@ -83,20 +83,38 @@ curl http://localhost:30081/health
8383
# List registered workers
8484
curl http://localhost:30081/list_workers
8585

86-
# Image generation request (SD3)
86+
# Image generation request (returns base64-encoded image)
8787
curl -X POST http://localhost:30081/generate \
8888
-H "Content-Type: application/json" \
8989
-d '{
90-
"model": "stabilityai/stable-diffusion-3-medium-diffusers",
90+
"model": "Qwen/Qwen-Image",
9191
"prompt": "a cute cat",
92-
"num_images": 1
92+
"num_images": 1,
93+
"response_format": "b64_json"
9394
}'
9495

96+
# Decode and save the image locally
97+
curl -s -X POST http://localhost:30081/generate \
98+
-H "Content-Type: application/json" \
99+
-d '{
100+
"model": "Qwen/Qwen-Image",
101+
"prompt": "a cute cat",
102+
"num_images": 1,
103+
"response_format": "b64_json"
104+
}' | python3 -c "
105+
import sys, json, base64
106+
resp = json.load(sys.stdin)
107+
img = base64.b64decode(resp['data'][0]['b64_json'])
108+
with open('output.png', 'wb') as f:
109+
f.write(img)
110+
print('Saved to output.png')
111+
"
112+
95113
# Video generation request
96114
curl -X POST http://localhost:30081/generate_video \
97115
-H "Content-Type: application/json" \
98116
-d '{
99-
"model": "stabilityai/stable-video-diffusion",
117+
"model": "Qwen/Qwen-Image",
100118
"prompt": "a flowing river"
101119
}'
102120

@@ -156,7 +174,7 @@ Single benchmark:
156174

157175
```bash
158176
SGLANG_USE_MODELSCOPE=TRUE python tests/benchmarks/diffusion_router/bench_router.py \
159-
--model stabilityai/stable-diffusion-3-medium-diffusers \
177+
--model Qwen/Qwen-Image \
160178
--num-workers 2 \
161179
--num-prompts 20 \
162180
--max-concurrency 4
@@ -166,7 +184,7 @@ Algorithm comparison:
166184

167185
```bash
168186
SGLANG_USE_MODELSCOPE=TRUE python tests/benchmarks/diffusion_router/bench_routing_algorithms.py \
169-
--model stabilityai/stable-diffusion-3-medium-diffusers \
187+
--model Qwen/Qwen-Image \
170188
--num-workers 2 \
171189
--num-prompts 20 \
172190
--max-concurrency 4

development.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@ Run tests:
99
```bash
1010
pip install pytest
1111
pytest tests/unit -v
12-
```
12+
```
-2.25 MB
Binary file not shown.
-92.3 KB
Binary file not shown.
-98 KB
Binary file not shown.

tests/benchmarks/diffusion_router/bench_router.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44
55
Example:
66
python tests/benchmarks/diffusion_router/bench_router.py \
7-
--model Wan-AI/Wan2.2-T2V-A14B-Diffusers \
7+
--model Qwen/Qwen-Image \
88
--num-workers 2 \
99
--num-prompts 20 \
10-
--max-concurrency 4
10+
--max-concurrency 2
1111
"""
1212

1313
from __future__ import annotations
@@ -201,19 +201,15 @@ def _build_bench_command(args: argparse.Namespace, base_url: str) -> list[str]:
201201
cmd = [
202202
sys.executable,
203203
"-m",
204-
"sglang.bench_serving",
205-
"--backend",
206-
"sglang",
204+
"sglang.multimodal_gen.benchmarks.bench_serving",
207205
"--base-url",
208206
base_url,
209207
"--model",
210208
args.model,
211-
"--dataset-name",
209+
"--dataset",
212210
args.dataset,
213211
"--num-prompts",
214212
str(args.num_prompts),
215-
"--max-concurrency",
216-
str(args.max_concurrency),
217213
"--request-rate",
218214
str(args.request_rate),
219215
"--log-level",
@@ -222,6 +218,8 @@ def _build_bench_command(args: argparse.Namespace, base_url: str) -> list[str]:
222218

223219
if args.dataset_path:
224220
cmd += ["--dataset-path", args.dataset_path]
221+
if args.max_concurrency:
222+
cmd += ["--max-concurrency", str(args.max_concurrency)]
225223
if args.task:
226224
cmd += ["--task", args.task]
227225
if args.width:

tests/benchmarks/diffusion_router/bench_routing_algorithms.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
66
Example:
77
python tests/benchmarks/diffusion_router/bench_routing_algorithms.py \
8-
--model Wan-AI/Wan2.2-T2V-A14B-Diffusers \
8+
--model Qwen/Qwen-Image \
99
--num-workers 2 \
1010
--num-prompts 10 \
1111
--max-concurrency 2

tests/benchmarks/diffusion_router/outputs/routing_algo_compare_20260220_215441/routing_algorithm_comparison.csv

Lines changed: 0 additions & 4 deletions
This file was deleted.

tests/benchmarks/diffusion_router/outputs/routing_algo_compare_20260220_215441/routing_algorithm_comparison.json

Lines changed: 0 additions & 61 deletions
This file was deleted.

0 commit comments

Comments
 (0)