@@ -16,84 +16,75 @@ It provides worker registration, load balancing, health checking, and request pr
1616From 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
3728Workers 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
135126Example:
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`).
164155Single 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 \
174165Algorithm 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
0 commit comments