Scenario
Uniform prompt lengths that hid the stall
RolesInference EngineeringAI Evaluation and Reliability
- Engine
- vLLM 0.31.0 against SGLang 0.5.22
- Model
- Qwen/Qwen3-8B
- Hardware
- one L4 with 24 GB of memory
Situation
A team that serves Qwen/Qwen3-8B on L4 cards runs an engine evaluation before a contract renewal. The load test is the benchmark client's default shape: 64 prompts with 16 users at once, every prompt 512 tokens and every answer 128 tokens. Engine A reads a P99 inter-token gap of 502 ms and a median first-token wait of 1,499 ms. Engine B reads 81 ms and 1,775 ms. The output is the same, 181.7 against 182.3 tokens per second. The evaluation calls engine A's stream "unusable" and schedules a migration to engine B.
A support engineer points out that production prompts run from a few tokens to several thousand, and that nobody has seen a 500 ms gap in production on engine A. The team repeats the test with the client's length ratio at 0.5 and at 0, where lengths vary, and the two engines change places on the stream metric. You are asked which result is the one to act on.
Questions
- Explain, from the length ratio definition, what identical lengths at 16 users do to the arrival pattern.
- Read the five log lines. What happened in the second before the first line, and what did the scheduler do in the next two?
- Why does the engine that keeps the stream smooth in waves lose that advantage when lengths vary?
- The mixed-length runs sent fewer input tokens. What else differs between the two shapes, and what can you still compare?
- One SGLang flag cut its mixed-length tail almost in half. What did it cost, and when would you turn it on?
- Decide the renewal: which result, which flag, and which test you put into the contract.
Commit to a cause after each listing. Write it down before you read the next one.
Evidence
the waves workload on the L4 by length ratio, both engines
Read the P99 ITL column at ratio 1, then at ratio 0.
### L4, waves: 64 prompts at 16 users, by length ratio (1.0 means equal lengths)
| Ratio | Config | Output tok/s (min to max) | Median TTFT | Median TPOT | P99 ITL (min to max) | Median SM clock |
|---|---|---|---|---|---|---|
| 0 | `vllm` | 174.4 (164.1 to 195.0) | 284 ms | 75.0 ms | 202 (180 to 215) ms | 1,493 MHz |
| 0 | `sglang` | 158.2 (146.7 to 176.9) | 283 ms | 86.7 ms | 302 (287 to 305) ms | 1,485 MHz |
| 0.5 | `vllm` | 169.6 (165.2 to 173.4) | 353 ms | 81.4 ms | 191 (189 to 219) ms | 1,455 MHz |
| 0.5 | `sglang` | 159.6 (155.8 to 162.0) | 325 ms | 87.8 ms | 363 (360 to 370) ms | 1,470 MHz |
| 1 | `vllm` | 181.7 (181.7 to 182.8) | 1,499 ms | 76.8 ms | 502 (500 to 503) ms | 1,410 MHz |
| 1 | `sglang` | 182.3 (181.5 to 182.7) | 1,775 ms | 74.7 ms | 81 (79 to 81) ms | 1,440 MHz |Source: manuals/vllm-101/sections/r-7-lab-notes.md, lines 98-107
how the length ratio sets the prompt and output lengths
At 1.0 every request has the same two lengths.
- **Waves.** The waves workload sends 64 prompts at 16 users. The length ratio sets how far the prompt and output lengths can vary. At 1.0 every request has 512 prompt and 128 output tokens. At 0 each length is drawn at random from 1 token up to that size.Source: manuals/vllm-101/sections/r-7-lab-notes.md, lines 11-11
total input tokens sent at each ratio, seed 1
Mixed lengths send fewer tokens than fixed lengths.
ratio 1.0, seed 1: Total input tokens: 32768
ratio 0.5, seed 1: Total input tokens: 24504
ratio 0.0, seed 1: Total input tokens: 17870 Source: manuals/sglang-101/capture/gpu/out-l4/waves-default-input-tokens.txt
five consecutive scheduler lines from a run at ratio 1.0
Count the running requests in the first line, then watch the two prefill batches and the decode that follows.
[2026-10-17 15:54:33] Prefill batch, #new-seq: 8, #new-token: 4096, #cached-token: 1, token usage: 0.34, #running-req: 1, #queue-req: 0, #pending-token: 513, cuda graph: True, input throughput (token/s): 3509.80
[2026-10-17 15:54:34] Prefill batch, #new-seq: 8, #new-token: 3583, #cached-token: 0, token usage: 0.34, #running-req: 8, #queue-req: 0, #pending-token: 0, cuda graph: True, input throughput (token/s): 3503.78
[2026-10-17 15:54:35] Decode batch, #running-req: 16, #token: 8240, token usage: 0.34, cuda graph: True, gen throughput (token/s): 2.62, #queue-req: 0
[2026-10-17 15:54:37] Decode batch, #running-req: 16, #token: 8880, token usage: 0.37, cuda graph: True, gen throughput (token/s): 231.07, #queue-req: 0
[2026-10-17 15:54:40] Decode batch, #running-req: 16, #token: 9520, token usage: 0.40, cuda graph: True, gen throughput (token/s): 229.85, #queue-req: 0Source: manuals/sglang-101/capture/gpu/out-l4/server-waves-default.log
how the SGLang manual reads the two traffic shapes
The last paragraph gives the mechanism.
**We measured** a different winner for each traffic shape. With fixed lengths, the two engines tied on throughput. They made the same trade as at a full pool. The vLLM server gave the first token sooner, 1,499 against 1,775 ms, outside the seed spread. SGLang kept the stream smooth, with a P99 ITL of 81 against 502 ms.
With mixed lengths, vLLM led. At a ratio of 0.5 it gave 169.6 against 159.6 tok/s, 6 percent more and outside the seed spread. Its median time per token was 81.4 against 87.8 ms, and its P99 ITL was 191 against 363 ms. At 0.0 the throughput ranges overlapped, and vLLM still had the lower time per token and the lower P99 ITL. Every median clock was 1,410 MHz or higher.
Our reading: when new prompts arrive one by one, each prefill shares a step with the running decodes. The vLLM server split that work so that the stream stalled less.Source: manuals/sglang-101/sections/5-3-reading-other-peoples-benchmarks.md, lines 270-274
SGLang with the mixed chunk against vLLM, by ratio
Read the three P99 ITL values on each row, then the cost at fixed lengths.
| Length ratio | Output tok/s, SGLang mixed chunk / vLLM | Median TPOT, SGLang mixed chunk / vLLM | P99 ITL, SGLang default / mixed chunk / vLLM |
|---|---|---|---|
| 1.0, fixed lengths | 182.3 / 181.7 | 73.1 / 76.8 ms | 81 / 203 / 502 ms |
| 0.5, mixed | 171.8 / 169.6 | 80.8 / 81.4 ms | 363 / 193 / 191 ms |
| 0.0, mixed | 171.9 / 174.4 | 76.8 / 75.0 ms | 302 / 196 / 202 ms |
**We measured** that the mixed chunk closed the gap. With mixed lengths, SGLang now tied vLLM on throughput, time per token, and P99 ITL, and every seed range overlapped. Against SGLang without the flag, the P99 ITL fell from 363 to 193 ms at 0.5 and from 302 to 196 ms at 0.0. The output rose by about 8 percent.
The flag had a cost with fixed lengths. The median P99 ITL rose from 81 to 203 ms, and the three seeds spread from 83 to 349 ms. When a whole wave arrives together, the prefills now share steps with the decodes, so the stream loses the clean gaps that it had before. The vLLM server stayed worse there, at 502 ms.Source: manuals/sglang-101/sections/5-3-reading-other-peoples-benchmarks.md, lines 289-297
the caveats of the ratio test and the rule for using it
The last paragraph says which ratio to use for what.
**We measured** a first token 6.9 times slower with fixed lengths on BF16, and 11.8 times slower on FP8. The FP8 runs at the two ratios had median clocks of 1,185 and 2,040 MHz. So part of the FP8 factor is the clock. Mixed lengths sent fewer tokens. In seed 1 they sent 17,870 input tokens at a ratio of 0.0, against 32,768 at 1.0. So part of the gap is less work.
The cache can explain another part. In each seed, the run at 1.0 came first and started with an empty cache. The runs at 0.5 and 0.0 came after it. Each of their prompts is the first part of a prompt from the run at 1.0. The BF16 pool of 24,094 tokens held only part of the 32,768 tokens of that run. The FP8 pool of 142,369 tokens could hold all of them.
Less work and the cache do not explain the other half of the result. With mixed lengths, P99 ITL rose from 82 to 300 ms. New prompts arrived one by one, and each prefill stopped the running decodes. With fixed lengths, prefill happened only between waves.
The GB10 gave the same shape with Qwen3-30B-A3B, three seeds per point. With fixed lengths, the BF16 median TTFT was 1,650 ms and P99 ITL 169 ms. With mixed lengths, they were 320 ms and 230 ms. FP8 went from 1,050 ms and 92 ms to 188 ms and 127 ms. Two GPUs and two models show the same trade, so on both of our machines it came from the workload, not from the hardware.
The two settings measure two different servers. Fixed lengths measure bursts: a slow first token and smooth tokens after it. Mixed lengths measure steady traffic: a fast first token and stalls in the stream. Keep `--random-range-ratio 1.0` when you compare two builds, because it repeats exactly. Before you set a latency target from it, run your real length distribution too.Source: manuals/sglang-101/sections/5-1-sglang-benchmark-serving.md, lines 247-255
The answer
Show the walkthrough
- Read what the ratio does. At a ratio of 1.0 every request has 512 prompt tokens and 128 output tokens. At 0, each length is drawn at random from 1 token up to that size. With identical lengths at a fixed user count, all 16 requests start together, finish together, and their replacements arrive together. The traffic comes in waves. With mixed lengths, requests end at different times and new prompts arrive one by one.
- See the wave in the log. In the first line only one request is running, so fifteen had just finished at once. The scheduler prefilled their replacements in two batches, 4096 and then 3583 new tokens, with no decode in between. Then all 16 decoded together: the generation throughput reads 2.62 tokens per second on the step that carried the prefill, then 231.07 and 229.85 on the steps after it. Prefill happened only between waves, so the decode steps had clean gaps and the first token of a whole wave waited for two full prefill batches.
- Read the table at ratio 1. The engines tie on output, 181.7 against 182.3. vLLM gives the first token sooner, 1,499 against 1,775 ms, and SGLang keeps the stream smooth, with a P99 ITL of 81 against 502 ms. That is the same choice the two engines make at a full pool: one admits the new prompts into the running steps, the other finishes the wave's prefill first.
- Read the table at ratios 0.5 and 0. With mixed lengths vLLM led. At 0.5 it gave 169.6 against 159.6 tokens per second, a median TPOT of 81.4 against 87.8 ms and a P99 ITL of 191 against 363 ms. At 0 the P99 ITL was 202 against 302 ms and the first token 284 against 283 ms. The SGLang manual's reading: when new prompts arrive one by one, each prefill shares a step with the running decodes, and vLLM split that work so the stream stalled less. The vLLM manual describes the mechanism as the batch token budget: in each step the running streams get their next token first, and a waiting prompt fills the rest.
- Account for the confounds. Mixed lengths sent fewer tokens: 32768 input tokens at 1.0 in seed 1, 24504 at 0.5 and 17870 at 0. The runs at 0.5 and 0 also came after the run at 1.0 on the same server, so part of their first-token gain can be the cache. The SGLang manual says that less work and the cache do not explain the stream: with mixed lengths its P99 ITL rose from 82 to 300 ms because each prefill stopped the running decodes. So compare the shape of each row and the ranking inside a row, not the absolute throughput across rows.
- Read the mixed-chunk test. With
--enable-mixed-chunk, SGLang puts the running decodes into the prefill batch. On mixed lengths it then tied vLLM: the P99 ITL fell from 363 to 193 ms at 0.5 and from 302 to 196 ms at 0, with every seed range overlapping, and the output rose by about 8 percent. On fixed lengths the flag cost: the P99 ITL rose from 81 to 203 ms, with seeds from 83 to 349 ms, while vLLM stayed at 502. The log shows one prefill of 514 tokens with 15 requests decoding in the same batch. - Decide what each setting measures. The SGLang manual states it: fixed lengths measure bursts, a slow first token and smooth tokens after it; mixed lengths measure steady traffic, a fast first token and stalls in the stream. Keep the ratio at 1.0 to compare two builds, because it repeats exactly. Run your real length distribution before you set a latency target.
Show the resolution
The migration decision rested on a traffic shape that production never produces. Identical lengths at a fixed user count synchronize the requests into waves, and in waves engine A's choice to admit new prompts into running steps costs a 502 ms tail that engine B avoids by prefilling between waves. With the lengths production has, engine A had the lower tail, 191 against 363 ms at 0.5 and 202 against 302 at 0, the same or better first token, and more output. On the support engineer's evidence, the 500 ms gap belongs to the test.
The renewal keeps engine A. If the team prefers engine B for other reasons, --enable-mixed-chunk removes its mixed-length disadvantage at a cost in bursts, 81 to 203 ms, so the choice depends on whether production arrives in bursts or steadily. The contract test changes: sample the real length distribution from production logs, run it as the acceptance test, and keep the fixed-length run only as the repeatable build-to-build check. Record the clock on both; every median clock in the mixed-length pairs was 1,410 MHz or higher, which is why those rows are comparable.
Show the wrong turns
“A 502 ms tail is a scheduler bug in engine A.”
The same engine read 202 ms at a ratio of 0 and 191 at 0.5. The tail came from 16 prefills landing in the same steps, which the test created and production does not.
“Identical lengths are the fairest test, because nothing varies.”
They are the most repeatable, not the most realistic. They measure bursts, and the SGLang manual says to use them for build comparisons, not for latency targets.
“Raise the token budget so prefills finish sooner.”
On the DGX Spark, a budget of 16,384 tokens raised the P99 ITL from 574 to 798 ms at a low rate, and the gain in the first token did not clear the seed spread. The budget trades the two latencies; it does not remove the stall.
“Compare throughput, the engines tie, so it does not matter.”
The tie on output hid a 502 against 81 ms tail in one shape and a 363 against 191 ms tail in the other. Users feel the tail.
“Turn on the mixed chunk everywhere on engine B.”
On fixed-length bursts it raised the P99 ITL from 81 to 203 ms with seeds up to 349. It fixes steady traffic and hurts bursts, so measure your traffic shape first.
Show the general rule
A load test with one prompt length tests one point of the length distribution, and at a fixed user count it also synchronizes the requests, so it measures a burst that steady traffic never produces. The ranking of two schedulers can flip between those shapes. Sample the real distribution of lengths for every latency target, keep the fixed-length run for repeatability, and read the tail next to the median in both.
Taught in
The vLLM manual holds the waves tables in the lab notes and the budget mechanism in the token budget page, the SGLang manual reads the pair on waves and tests the ratio in its benchmark page, and the load testing lesson names the prompt-uniformity trap.