|
| 1 | +# Benchmarking for Speculative Decoding |
| 2 | + |
| 3 | +## Overview |
| 4 | + |
| 5 | +We provide a unified script to test the performance of the Speculative Decoding with EAGLE3 algorithm on multiple datasets. You can follow the steps below to run the benchmarks. |
| 6 | + |
| 7 | +## Run Benchmarks |
| 8 | + |
| 9 | +### Launch SGLang and Benchmarker Concurrently |
| 10 | + |
| 11 | +`bench_eagle3.py` can help you launch a SGLang server process and a Benchmarking process concurrently. In this way, you don't have to launch the SGLang server manually, this script will manually handle the SGLang launch under different speculative decoding configurations. Some important arguments are: |
| 12 | +- `--model-path`: the path to the target model. |
| 13 | +- `--speculative-draft-model-path`: the path to the draft model. |
| 14 | +- `--port`: the port to launch the SGLang server. |
| 15 | +- `--trust-remote-code`: trust the remote code. |
| 16 | +- `--mem-fraction-static`: the memory fraction for the static memory. |
| 17 | +- `--tp-size`: the tensor parallelism size. |
| 18 | +- `--attention-backend`: the attention backend. |
| 19 | +- `--config-list`: the list of speculative decoding configuration to test, the format is `<batch-size>,<num-steps>,<topk>,<num-draft-tokens>`. |
| 20 | +- `--benchmark-list`: the list of benchmarks to test, the format is `<benchmark-name>:<num-prompts>:<subset>`. |
| 21 | + |
| 22 | +```shell |
| 23 | +python3 bench_eagle3.py \ |
| 24 | + --model-path meta-llama/Llama-3.1-8B-Instruct \ |
| 25 | + --speculative-draft-model-path lmsys/sglang-EAGLE3-LLaMA3.1-Instruct-8B \ |
| 26 | + --port 30000 \ |
| 27 | + --trust-remote-code \ |
| 28 | + --mem-fraction-static 0.8 \ |
| 29 | + --tp-size 1 \ |
| 30 | + --attention-backend fa3 \ |
| 31 | + --config-list 1,0,0,0 1,3,1,4 \ |
| 32 | + --benchmark-list mtbench gsm8k:5 ceval:5:accountant \ |
| 33 | + --dtype bfloat16 |
| 34 | +``` |
| 35 | + |
| 36 | +### Launch Benchmarker Independently |
| 37 | + |
| 38 | +If you want to launch the SGLang server independently, you can use the following command. |
| 39 | + |
| 40 | +```shell |
| 41 | +# you can launch a server |
| 42 | +python3 -m sglang.launch_server \ |
| 43 | + --model meta-llama/Llama-3.1-8B-Instruct \ |
| 44 | + --speculative-algorithm EAGLE3 \ |
| 45 | + --speculative-draft-model-path lmsys/sglang-EAGLE3-LLaMA3.1-Instruct-8B \ |
| 46 | + --speculative-num-steps 3 \ |
| 47 | + --speculative-eagle-topk 1 \ |
| 48 | + --speculative-num-draft-tokens 4 \ |
| 49 | + --mem-fraction-static 0.75 \ |
| 50 | + --cuda-graph-max-bs 1 \ |
| 51 | + --tp 1 \ |
| 52 | + --trust-remote-code \ |
| 53 | + --host 0.0.0.0 \ |
| 54 | + --port 30000 \ |
| 55 | + --dtype bfloat16 |
| 56 | +``` |
| 57 | + |
| 58 | +Then we can start benchmarking. Note that you should use the same host and port as the one used in the SGLang server. Note that `--skip-launch-server` is required to skip the launch of the SGLang server. |
| 59 | + |
| 60 | +```bash |
| 61 | +python bench_eagle3.py \ |
| 62 | + --model-path meta-llama/Llama-3.1-8B-Instruct \ |
| 63 | + --port 30000 \ |
| 64 | + --config-list 1,3,1,4 \ |
| 65 | + --benchmark-list mtbench:5 ceval:5:accountant gsm8k:5 humaneval:5 math500:5 mtbench:5 aime:1 \ |
| 66 | + --skip-launch-server |
| 67 | +``` |
0 commit comments