Francesco commited on
Commit
977eef0
·
verified ·
1 Parent(s): 7521d9e

README: what it measures, how, the data and why

Browse files
Files changed (1) hide show
  1. README.md +69 -21
README.md CHANGED
@@ -1,34 +1,82 @@
1
  ---
2
  license: apache-2.0
3
  pretty_name: llm-serving-bench
 
4
  task_categories: [text-generation]
5
- tags: [benchmark, llm-serving, speculative-decoding, long-context]
 
 
 
 
 
 
 
 
6
  ---
7
- # llm-serving-bench v3
8
 
9
- llm-serving-bench: a small benchmark for the single-stream serving speed of OpenAI-compatible LLM servers. It shows what the server is doing: decode speed on short and code prompts, prefill speed and decode-at-depth on long prompts. One script, stdlib Python, any OpenAI-compatible server (`/v1/chat/completions`, streaming). Single stream, greedy (`temperature 0`).
10
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
11
  ```
12
- python3 bench.py --url http://127.0.0.1:8003/v1 --out result.json
13
- python3 bench.py --url ... --windows 32K,224K,512K # long windows (default); skip with --short-only
14
- ```
15
- `bench.py` downloads `short.jsonl`, `code.jsonl`, `long.jsonl` once (revision `v3`) into `~/.cache/llm-serving-bench` (`--cache` or `LLM_SERVING_BENCH_CACHE` to move it), warms up (one short request, one ~4K-token prompt, both untimed), runs everything, writes one JSON and prints one markdown table.
16
 
17
- ## What is in it
18
- | file | what | source (pinned) | licence |
 
 
 
 
 
19
  |---|---|---|---|
20
- | `short.jsonl` | 60 prompts: the first 10 first-turn questions of each of Spec-Bench's 6 tasks (MT-Bench, translation, summarization, QA, math reasoning, RAG). The MT-Bench task is 8 categories x 10 questions; its first 10 are the `writing` ones. Max 256 new tokens. | [hemingkx/Spec-Bench](https://github.com/hemingkx/Spec-Bench) commit `fd2c1cd7d220`, `data/spec_bench/question.jsonl` | Apache-2.0 |
21
- | `code.jsonl` | 20 prompts: HumanEval problems 0-19, "Complete this Python function. Reply with code only." + the prompt. Max 384 new tokens. | [openai/openai_humaneval](https://huggingface.co/datasets/openai/openai_humaneval) rev `7dce6050a7d6d172f3cc5c32aa97f52fa1a2e544` | MIT |
22
- | `long.jsonl` | 1 LongBench v2 question (Code Repository Understanding, `_id` `66fa208bbb02136c067c5fc1`, a 1.9M-character Python repository, mpmath) with its 4 choices and answer. The script cuts the repository from the middle (keep start and end, as LongBench does) to fill each window, using the official prompt template. Max 256 new tokens. | [zai-org/LongBench-v2](https://huggingface.co/datasets/zai-org/LongBench-v2) rev `2b48e494f2c7a2f0af81aae178e05c7e1dde0fe9` | Apache-2.0 (the repository text keeps its own open-source licence) |
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
23
 
24
- Windows: 32K = 32,768 tokens, 224K = 229,376, 512K = 512,000 (the 512K serving profile of ingine, `--max-ctx 512000`). The prompt is cut to window minus 2,048 tokens (tokens per character are measured on the warm-up prompt, so the cut fits any tokenizer). A window larger than the server's context is reported as `does not fit`. The full repository is about 550K tokens, so a 512K window is filled.
 
 
 
25
 
26
- No private data. `build_dataset.py` rebuilds the three files from the pinned sources.
27
 
28
- ## How to read the numbers
29
- - **decode tok/s** (per set): all generated tokens after the first, divided by all decode seconds (token-weighted, so long answers count more). Measured on the stream, after the first token arrives. With speculative decoding on, this is the real serving speed; with it off, the bare model speed. Short sets differ because the drafter predicts some text better (code, translation, summarization) than other text (open writing, math).
30
- - **median TTFT s**: time to first token of a short prompt, mostly prefill + scheduling.
31
- - **long, prefill tok/s**: prompt tokens / time to first token of request 1 (one prompt of the window size, cold).
32
- - **long, decode at depth tok/s**: request 2 continues the conversation (answer + "Explain your answer step by step."). The prompt is the same big prefix, so decode runs with the full window in the KV cache. The follow-up TTFT shows whether the server reuses the prefix.
33
- - **answer**: the long question's answer from request 1 (ok/wrong against the key). It is a sanity check, not an accuracy test.
34
- - Compare only numbers from the same machine, build and clocks. Run each config twice if you need a spread; the script runs each prompt once.
 
1
  ---
2
  license: apache-2.0
3
  pretty_name: llm-serving-bench
4
+ language: [en, de]
5
  task_categories: [text-generation]
6
+ tags: [benchmark, llm-serving, inference, speculative-decoding, long-context, local-llm]
7
+ size_categories: [n<1K]
8
+ configs:
9
+ - config_name: short
10
+ data_files: short.jsonl
11
+ - config_name: code
12
+ data_files: code.jsonl
13
+ - config_name: long
14
+ data_files: long.jsonl
15
  ---
 
16
 
17
+ # llm-serving-bench
18
 
19
+ **A small benchmark for the single-stream serving speed of OpenAI-compatible LLM servers.** It answers the questions you have when you run a model on your own GPU:
20
+
21
+ - How fast does the server write on everyday prompts?
22
+ - How fast does it write code?
23
+ - How fast does it read a long prompt?
24
+ - How fast does it write once the context is deep?
25
+
26
+ It takes about 2 minutes for the short and code sets, plus a few minutes per long window, against any server with a streaming `/v1/chat/completions` endpoint: vLLM, SGLang, llama.cpp, TensorRT-LLM, ingine, etc. Its prompts come from public datasets that are already widely used, so its numbers can be compared.
27
+
28
+ ```bash
29
+ curl -LO https://huggingface.co/datasets/Francesco/llm-serving-bench/resolve/v3/bench.py
30
+ python3 bench.py --url http://127.0.0.1:8003/v1 --out result.json --label "my-gpu"
31
+ python3 bench.py --url ... --short-only # skip the long prompts (about 2 minutes)
32
+ python3 bench.py --url ... --windows 32K,224K # only the long windows your server's context holds
33
  ```
 
 
 
 
34
 
35
+ - **Python standard library only.** The script downloads the three data files once (revision `v3`) into `~/.cache/llm-serving-bench` (move it with `--cache` or `LLM_SERVING_BENCH_CACHE`), so the timed part never touches the network.
36
+ - **Warm-up first:** one short request and one ~4K-token prompt, untimed.
37
+ - **Output:** one JSON with every request, and one markdown table.
38
+
39
+ ## What it measures
40
+
41
+ | set | prompts | what it tells you | metric |
42
  |---|---|---|---|
43
+ | **short** | 60 | everyday writing: chat, translation, summaries, Q&A, math, RAG | decode tok/s, time to first token |
44
+ | **code** | 20 | writing code | decode tok/s, time to first token |
45
+ | **long** | 1 question × 3 windows (32K, 224K, 512K tokens) | reading a long code repository, then writing at that depth | prefill tok/s, time to first token, decode tok/s at depth, the answer |
46
+
47
+ **How each number is measured:**
48
+ - **Decoding:** every request is streamed with `temperature 0`, so two runs or two servers that agree produce the same tokens. Each request is timed on the wire.
49
+ - **Decode tok/s:** tokens after the first ÷ the time from the first to the last streamed token. A set's number is token-weighted, so long answers count more than short ones.
50
+ - **Prefill tok/s:** prompt tokens ÷ time to first token. This is request 1 of the long set.
51
+ - **Decode at depth:** request 2 continues the same conversation ("Explain your answer step by step."). A server that keeps the conversation's cache only reads the new turn, so this times writing with the whole window in context.
52
+ - **Speculative decoding** (drafters, MTP, EAGLE, …) is measured as it is served: on varied, realistic text. That is why the short set is Spec-Bench, the standard benchmark for speculative decoding. Run once with speculation on and once off to see what it buys.
53
+
54
+ ## The data
55
+
56
+ | file | contents | source (pinned) | licence |
57
+ |---|---|---|---|
58
+ | `short.jsonl` | the first 10 first-turn questions of each of Spec-Bench's 6 tasks: multi-turn conversation (MT-Bench), translation (WMT14 DE-EN), summarization (CNN/DM), question answering (Natural Questions), mathematical reasoning (GSM8K), retrieval-augmented generation. At most 256 new tokens. | [hemingkx/Spec-Bench](https://github.com/hemingkx/Spec-Bench) commit `fd2c1cd7d220` | Apache-2.0 |
59
+ | `code.jsonl` | HumanEval problems 0–19 as "Complete this Python function. Reply with code only." plus the function stub. At most 384 new tokens. | [openai/openai_humaneval](https://huggingface.co/datasets/openai/openai_humaneval) rev `7dce6050` | MIT |
60
+ | `long.jsonl` | one LongBench v2 *Code Repository Understanding* question (`66fa208bbb02136c067c5fc1`: a 1.9M-character Python repository, mpmath), with its four choices and the answer. At most 256 new tokens. | [zai-org/LongBench-v2](https://huggingface.co/datasets/zai-org/LongBench-v2) rev `2b48e494` | Apache-2.0 (the repository text keeps its own open-source licence) |
61
+
62
+ **Long windows:** 32K = 32,768 tokens, 224K = 229,376 and 512K = 512,000.
63
+ - **Cut:** the repository is cut from the middle (keep the start and the end, as LongBench does) so that prompt and answer fit the window, with LongBench v2's official prompt template.
64
+ - **Tokens:** the script measures the model's tokens per character on the warm-up prompt (a 12,000-character slice of the same repository), so every model gets prompts that fill its own window.
65
+ - **Windows that don't fit:** a window larger than the server's reported context (`/v1/models` `max_model_len`), or one the server refuses, is reported as `does not fit`.
66
+
67
+ `build_dataset.py` rebuilds the three files from the pinned sources.
68
+
69
+ ## Results
70
+
71
+ RESULTS
72
+
73
+ ## Why it looks like this
74
 
75
+ - **Small on purpose.** It is a speed benchmark, not a quality benchmark: 81 prompts are enough for stable speed numbers, and a full run takes minutes, so you can run it after every change. The long question's answer is reported as a sanity check, not as a score.
76
+ - **Widely used sources.** Spec-Bench is the benchmark speculative-decoding papers report. HumanEval is the most common code prompt set. LongBench v2 is a standard long-context benchmark with real code repositories.
77
+ - **Single stream.** One request at a time: the case of a person or a coding agent on their own GPU. Throughput under many concurrent users is a different benchmark (see vLLM's `benchmark_serving`).
78
+ - **Greedy.** Same tokens on every run, so two builds or two servers can be compared token for token. Sampling at temperature 1 changes speculative decoding's acceptance and adds noise.
79
 
80
+ ## Citation
81
 
82
+ If you use it, please cite the three sources: Spec-Bench (Xia et al., 2024), HumanEval (Chen et al., 2021) and LongBench v2 (Bai et al., 2024).