Skip to content

Commit 4b8b6d2

Browse files
verify docs
1 parent bcc37e2 commit 4b8b6d2

7 files changed

Lines changed: 107 additions & 39 deletions

File tree

README.md

Lines changed: 30 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -16,84 +16,75 @@ It provides worker registration, load balancing, health checking, and request pr
1616
From repository root:
1717

1818
```bash
19-
python3 -m venv .venv
20-
. .venv/bin/activate
21-
pip install .
22-
```
23-
24-
Development install:
25-
26-
```bash
27-
pip install -e .
28-
```
29-
30-
Run tests:
31-
32-
```bash
33-
pip install pytest
34-
pytest tests/unit -v
19+
# Create a virtual environment
20+
# python3 -m venv .venv
21+
# source .venv/bin/activate
22+
# pip install uv
23+
git clone https://github.com/sglang/sglang-diffusion-routing.git
24+
cd sglang-diffusion-routing
25+
uv pip install .
3526
```
3627

3728
Workers require SGLang diffusion support:
3829

3930
```bash
40-
pip install "sglang[diffusion]"
31+
uv pip install "sglang[diffusion]" --prerelease=allow
4132
```
4233

4334
## Quick Start
4435

45-
### 1) Start diffusion workers
36+
### Start diffusion workers
4637

4738
```bash
4839
# worker 1
49-
CUDA_VISIBLE_DEVICES=0 sglang serve \
40+
SGLANG_USE_MODELSCOPE=TRUE CUDA_VISIBLE_DEVICES=0 sglang serve \
5041
--model-path stabilityai/stable-diffusion-3-medium-diffusers \
5142
--num-gpus 1 \
5243
--host 127.0.0.1 \
5344
--port 30000
5445

5546
# worker 2
56-
CUDA_VISIBLE_DEVICES=1 sglang serve \
47+
SGLANG_USE_MODELSCOPE=TRUE CUDA_VISIBLE_DEVICES=1 sglang serve \
5748
--model-path stabilityai/stable-diffusion-3-medium-diffusers \
5849
--num-gpus 1 \
5950
--host 127.0.0.1 \
6051
--port 30001
6152
```
6253

63-
### 2) Start the router
54+
### Start the router
6455

65-
Script entry:
56+
1. Script entry
6657

6758
```bash
68-
sglang-d-router --port 30080 \
59+
sglang-d-router --port 30081 \
6960
--worker-urls http://localhost:30000 http://localhost:30001
7061
```
7162

72-
Module entry:
63+
2. Module entry
7364

7465
```bash
75-
python -m sglang_diffusion_routing --port 30080 \
66+
python -m sglang_diffusion_routing --port 30081 \
7667
--worker-urls http://localhost:30000 http://localhost:30001
7768
```
7869

79-
Or start empty and add workers later:
70+
3. Or start empty and add workers later:
8071

8172
```bash
82-
sglang-d-router --port 30080
83-
curl -X POST "http://localhost:30080/add_worker?url=http://localhost:30000"
73+
sglang-d-router --port 30081
74+
curl -X POST "http://localhost:30081/add_worker?url=http://localhost:30000"
8475
```
8576

86-
### 3) Test the router
77+
### Test the router
8778

8879
```bash
8980
# Check router health
90-
curl http://localhost:30080/health
81+
curl http://localhost:30081/health
9182

9283
# List registered workers
93-
curl http://localhost:30080/list_workers
84+
curl http://localhost:30081/list_workers
9485

9586
# Image generation request (SD3)
96-
curl -X POST http://localhost:30080/generate \
87+
curl -X POST http://localhost:30081/generate \
9788
-H "Content-Type: application/json" \
9889
-d '{
9990
"model": "stabilityai/stable-diffusion-3-medium-diffusers",
@@ -102,15 +93,15 @@ curl -X POST http://localhost:30080/generate \
10293
}'
10394

10495
# Video generation request
105-
curl -X POST http://localhost:30080/generate_video \
96+
curl -X POST http://localhost:30081/generate_video \
10697
-H "Content-Type: application/json" \
10798
-d '{
10899
"model": "stabilityai/stable-video-diffusion",
109100
"prompt": "a flowing river"
110101
}'
111102

112103
# Check per-worker health and load
113-
curl http://localhost:30080/health_workers
104+
curl http://localhost:30081/health_workers
114105
```
115106

116107
## Router API
@@ -135,7 +126,7 @@ Full details: [docs/update_weights_from_disk.md](docs/update_weights_from_disk.m
135126
Example:
136127

137128
```bash
138-
curl -X POST http://localhost:30080/update_weights_from_disk \
129+
curl -X POST http://localhost:30081/update_weights_from_disk \
139130
-H "Content-Type: application/json" \
140131
-d '{"model_path": "/path/to/new/weights"}'
141132
```
@@ -164,8 +155,8 @@ They are not part of default unit test collection (`pytest tests/unit -v`).
164155
Single benchmark:
165156

166157
```bash
167-
python tests/benchmarks/diffusion_router/bench_router.py \
168-
--model Wan-AI/Wan2.2-T2V-A14B-Diffusers \
158+
SGLANG_USE_MODELSCOPE=TRUE python tests/benchmarks/diffusion_router/bench_router.py \
159+
--model stabilityai/stable-diffusion-3-medium-diffusers \
169160
--num-workers 2 \
170161
--num-prompts 20 \
171162
--max-concurrency 4
@@ -174,8 +165,8 @@ python tests/benchmarks/diffusion_router/bench_router.py \
174165
Algorithm comparison:
175166

176167
```bash
177-
python tests/benchmarks/diffusion_router/bench_routing_algorithms.py \
178-
--model Wan-AI/Wan2.2-T2V-A14B-Diffusers \
168+
SGLANG_USE_MODELSCOPE=TRUE python tests/benchmarks/diffusion_router/bench_routing_algorithms.py \
169+
--model stabilityai/stable-diffusion-3-medium-diffusers \
179170
--num-workers 2 \
180171
--num-prompts 20 \
181172
--max-concurrency 4

development.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
Development install:
2+
3+
```bash
4+
pip install -e .
5+
```
6+
7+
Run tests:
8+
9+
```bash
10+
pip install pytest
11+
pytest tests/unit -v
12+
```
2.25 MB
Loading
92.3 KB
Loading
98 KB
Loading
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
algorithm,throughput_qps,latency_mean,latency_median,latency_p99,duration,completed_requests,failed_requests,throughput_qps_delta_pct,latency_mean_delta_pct,latency_median_delta_pct,latency_p99_delta_pct,error
2+
least-request,,,,,,,,,,,,exit_code=2
3+
round-robin,,,,,,,,,,,,exit_code=2
4+
random,,,,,,,,,,,,exit_code=2
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
{
2+
"results": {
3+
"least-request": {
4+
"error": "exit_code=2"
5+
},
6+
"round-robin": {
7+
"error": "exit_code=2"
8+
},
9+
"random": {
10+
"error": "exit_code=2"
11+
}
12+
},
13+
"rows": [
14+
{
15+
"algorithm": "least-request",
16+
"throughput_qps": "",
17+
"latency_mean": "",
18+
"latency_median": "",
19+
"latency_p99": "",
20+
"duration": "",
21+
"completed_requests": "",
22+
"failed_requests": "",
23+
"throughput_qps_delta_pct": "",
24+
"latency_mean_delta_pct": "",
25+
"latency_median_delta_pct": "",
26+
"latency_p99_delta_pct": "",
27+
"error": "exit_code=2"
28+
},
29+
{
30+
"algorithm": "round-robin",
31+
"throughput_qps": "",
32+
"latency_mean": "",
33+
"latency_median": "",
34+
"latency_p99": "",
35+
"duration": "",
36+
"completed_requests": "",
37+
"failed_requests": "",
38+
"throughput_qps_delta_pct": "",
39+
"latency_mean_delta_pct": "",
40+
"latency_median_delta_pct": "",
41+
"latency_p99_delta_pct": "",
42+
"error": "exit_code=2"
43+
},
44+
{
45+
"algorithm": "random",
46+
"throughput_qps": "",
47+
"latency_mean": "",
48+
"latency_median": "",
49+
"latency_p99": "",
50+
"duration": "",
51+
"completed_requests": "",
52+
"failed_requests": "",
53+
"throughput_qps_delta_pct": "",
54+
"latency_mean_delta_pct": "",
55+
"latency_median_delta_pct": "",
56+
"latency_p99_delta_pct": "",
57+
"error": "exit_code=2"
58+
}
59+
],
60+
"baseline": "random"
61+
}

0 commit comments

Comments
 (0)