|
| 1 | +# Qwen2.5-0.5B-Instruct Benchmark Example |
| 2 | + |
| 3 | +This example benchmarks `Qwen/Qwen2.5-0.5B-Instruct` against either a vLLM or |
| 4 | +SGLang server. It is intended as a small-GPU example that works on typical |
| 5 | +8-16 GB cards. |
| 6 | + |
| 7 | +## Requirements |
| 8 | + |
| 9 | +- Python 3.12+ |
| 10 | +- Docker with NVIDIA GPU support |
| 11 | +- NVIDIA GPU with at least 8 GB VRAM |
| 12 | + |
| 13 | +## Fastest Path |
| 14 | + |
| 15 | +From the repo root: |
| 16 | + |
| 17 | +```bash |
| 18 | +# Offline benchmark with vLLM |
| 19 | +bash examples/08_Qwen2.5-0.5B_Example/run_benchmark.sh vllm offline |
| 20 | + |
| 21 | +# Offline benchmark with SGLang |
| 22 | +bash examples/08_Qwen2.5-0.5B_Example/run_benchmark.sh sglang offline |
| 23 | + |
| 24 | +# Online concurrency sweep |
| 25 | +bash examples/08_Qwen2.5-0.5B_Example/run_benchmark.sh vllm online |
| 26 | +``` |
| 27 | + |
| 28 | +The script prepares the dataset, starts or reuses a container, waits for the |
| 29 | +server, and runs the benchmark. |
| 30 | + |
| 31 | +## Manual Flow |
| 32 | + |
| 33 | +If you do not want to use `run_benchmark.sh`, the minimum manual flow is: |
| 34 | + |
| 35 | +```bash |
| 36 | +python3.12 -m venv .venv |
| 37 | +source .venv/bin/activate |
| 38 | +pip install -e ".[test]" |
| 39 | + |
| 40 | +python examples/08_Qwen2.5-0.5B_Example/prepare_dataset.py |
| 41 | +``` |
| 42 | + |
| 43 | +Start one server: |
| 44 | + |
| 45 | +```bash |
| 46 | +# vLLM |
| 47 | +docker run --runtime nvidia --gpus all \ |
| 48 | + -v ~/.cache/huggingface:/root/.cache/huggingface \ |
| 49 | + -e PYTORCH_ALLOC_CONF=expandable_segments:True \ |
| 50 | + -p 8000:8000 \ |
| 51 | + --ipc=host \ |
| 52 | + --name vllm-qwen \ |
| 53 | + -d \ |
| 54 | + vllm/vllm-openai:latest \ |
| 55 | + --model Qwen/Qwen2.5-0.5B-Instruct \ |
| 56 | + --gpu-memory-utilization 0.85 |
| 57 | + |
| 58 | +# SGLang |
| 59 | +docker run --runtime nvidia --gpus all --net host \ |
| 60 | + -v ~/.cache/huggingface:/root/.cache/huggingface \ |
| 61 | + --ipc=host \ |
| 62 | + --name sglang-qwen \ |
| 63 | + -d \ |
| 64 | + lmsysorg/sglang:latest \ |
| 65 | + python3 -m sglang.launch_server \ |
| 66 | + --model-path Qwen/Qwen2.5-0.5B-Instruct \ |
| 67 | + --host 0.0.0.0 \ |
| 68 | + --port 30000 \ |
| 69 | + --mem-fraction-static 0.9 \ |
| 70 | + --attention-backend flashinfer |
| 71 | +``` |
| 72 | + |
| 73 | +Run one benchmark: |
| 74 | + |
| 75 | +```bash |
| 76 | +# vLLM offline |
| 77 | +inference-endpoint benchmark from-config \ |
| 78 | + -c examples/08_Qwen2.5-0.5B_Example/offline_qwen_benchmark.yaml |
| 79 | + |
| 80 | +# SGLang offline |
| 81 | +inference-endpoint benchmark from-config \ |
| 82 | + -c examples/08_Qwen2.5-0.5B_Example/sglang_offline_qwen_benchmark.yaml |
| 83 | + |
| 84 | +# vLLM online sweep |
| 85 | +python scripts/concurrency_sweep/run.py \ |
| 86 | + --config examples/08_Qwen2.5-0.5B_Example/online_qwen_benchmark.yaml |
| 87 | + |
| 88 | +# SGLang online sweep |
| 89 | +python scripts/concurrency_sweep/run.py \ |
| 90 | + --config examples/08_Qwen2.5-0.5B_Example/sglang_online_qwen_benchmark.yaml |
| 91 | +``` |
| 92 | + |
| 93 | +## Files |
| 94 | + |
| 95 | +- `offline_qwen_benchmark.yaml`: vLLM offline benchmark |
| 96 | +- `online_qwen_benchmark.yaml`: vLLM online concurrency sweep |
| 97 | +- `sglang_offline_qwen_benchmark.yaml`: SGLang offline benchmark |
| 98 | +- `sglang_online_qwen_benchmark.yaml`: SGLang online concurrency sweep |
| 99 | +- `prepare_dataset.py`: converts `tests/datasets/dummy_1k.pkl` into the example dataset |
| 100 | +- `run_benchmark.sh`: wrapper that automates dataset prep, container startup, and benchmark execution |
| 101 | + |
| 102 | +## Results |
| 103 | + |
| 104 | +- vLLM offline: `results/qwen_offline_benchmark/` |
| 105 | +- vLLM online: `results/qwen_online_benchmark/concurrency_sweep/` |
| 106 | +- SGLang offline: `results/qwen_sglang_offline_benchmark/` |
| 107 | +- SGLang online: `results/qwen_sglang_online_benchmark/concurrency_sweep/` |
| 108 | + |
| 109 | +To summarize an online sweep: |
| 110 | + |
| 111 | +```bash |
| 112 | +python scripts/concurrency_sweep/summarize.py \ |
| 113 | + results/qwen_online_benchmark/concurrency_sweep/ |
| 114 | +``` |
| 115 | + |
| 116 | +## Notes |
| 117 | + |
| 118 | +- The online sweep defaults to `1 2 4 8 16 32 64 128 256 512 1024`. |
| 119 | +- Use `scripts/concurrency_sweep/run.py --concurrency ... --duration-ms ...` to shorten or customize the sweep. |
| 120 | +- If vLLM runs out of memory at higher concurrency, lower `--gpu-memory-utilization`. |
0 commit comments