11 · Benchmark inference serving
Replay the same helpdesk burst on one T4 and measure what batching and weight compression do to the queue.
- Part 4
- Operate and release
- Model
Qwen2.5-1.5B-Instruct- Data
- Fixed synthetic inference workload
- Hardware
- Tesla T4 and CPU, in Google Colab
Four tickets arrive together
A dispatcher opens the morning queue. The first ticket is a short pump lookup. The next asks for fan F-250’s priority and carries a longer list of maintenance notes. Two other requests arrive with them. The same GPU can take the tickets one by one or dispatch all four together. Which choice lets the dispatcher see the first digit sooner, and which clears the burst faster?

“What is the priority of F-250?”
Check when F-250 can begin
With serial dispatch, the first ticket must finish before F-250 starts. In the joint batch F-250 starts with the other tickets, and every prompt is padded to the longest prompt in the group.
Change one fact. Keep the four requests, arrival time and order fixed. Change only how many the GPU serves together.
| Dispatch | What could happen to F-250? |
|---|---|
| One request at a time | The pump ticket starts immediately. F-250 waits for it to finish. |
| One batch of four | F-250 starts with the pump ticket. The short requests are padded to the longest prompt. |
Batching doubled FP16 throughput at the same four-request load
Warm throughput and end-to-end tail at the host
1| Format | Batch | Requests/s | p95 total, ms |
|---|---|---|---|
| FP16 | 1 | 4.26 | 1065 |
| FP16 | 4 | 9.23 | 519 |
| NF4 | 1 | 2.71 | 1698 |
| NF4 | 4 | 4.94 | 1451 |
Separate arrivals from dispatch
Concurrency caps the number of requests admitted together. Batch size caps the number passed to the decoder in one dispatch. With concurrency four and batch size one, four tickets arrive together and the GPU decodes them in four successive calls. At batch size four, one call handles the same tickets. The next wave arrives only after the current one finishes.
This benchmark uses a closed-loop workload. MLPerf separates its single-stream scenario, in which one query follows the previous completion, from server and interactive scenarios with Poisson arrivals and scenario-specific latency constraints. Choose an arrival process that represents the live desk before applying a notebook throughput number to capacity planning. MLCommons inference rules, scenarios and run procedure
# Keep the arrival wave fixed while varying the GPU dispatch size.
for offset in range(0, len(items), concurrency):
wave = items[offset : offset + concurrency]
yield [wave[i : i + batch_size] for i in range(0, len(wave), batch_size)]The timers start at wave admission for both first-token and total latency. Dispatch wait ends when the request’s group starts. Time to first token ends when the first token IDs reach Python. Total time ends after the fixed continuation has been decoded to text.
F-250 traded dispatch wait for a longer prefill batch
F-250 in the opening four-request wave, FP16
2| Batch | Dispatch wait, ms | First token, ms | Total, ms |
|---|---|---|---|
| 1 | 203 | 255 | 443 |
| 4 | <1 | 235 | 410 |
F-250 waited 203 ms in the serial replay and less than 1 ms in the joint batch. Its first digit arrived 20 ms sooner in the batch, even though serving the group increased the time from dispatch to first token. DistServe likewise reports throughput and first-token objectives separately. Its published results come from a system that disaggregates prefill and decode. Both run on one T4 here. DistServe, §6
Compare the slow end of the same waves
An average response time can hide the operator who waits behind several long requests. Compare the same arrival pattern and measure the tail as well as the average.
The experiment calculates the 95th percentile over total request times and subtracts serial p95 from matched-batch p95. To estimate uncertainty, it resamples whole waves in pairs, because requests that arrived together shared both queue and dispatch conditions.
Larger batches reduced most paired latency tails
Matched-batch p95 minus serial p95, within each load and storage format
3| Format / load | Δ ms | 95% interval | Paired waves |
|---|---|---|---|
| FP16 / 2 | −193 | [−278, −115] | 50 |
| FP16 / 4 | −546 | [−702, −389] | 25 |
| NF4 / 2 | −253 | [−408, −125] | 50 |
| NF4 / 4 | −247 | [−644, 174] | 25 |
All four point estimates favour batching. The interval for NF4 at load four crosses zero. Under FP16, the median of a single burst would conceal the largest wait, so review the short and long slices separately.
Short tickets waited behind long ones when dispatched singly
FP16 at load four. Each length slice contains fifty requests.
4| Batch / prompt | p95 first, ms | p95 total, ms |
|---|---|---|
| 1 / short | 913 | 1175 |
| 1 / long | 627 | 862 |
| 4 / short | 237 | 519 |
| 4 / long | 237 | 519 |
With four tickets dispatched singly in FP16, short tickets had a worse p95 than long tickets in this particular mix. The replay admits bursts of alternating short and long requests, so queue position affects both scores. To separate queue position from length, predict what happens after shuffling that order, then compare the dispatch receipts.
Follow the memory
Left padding aligns the last real prompt token in each row so the decoder can select the first continuation token together. Each mixed batch consumes dense positions for its longest prompt. Across the warm FP16 replay at load four, the same 21,800 prompt tokens occupied 36,500 dense positions in the batched setting.
The vLLM PagedAttention authors describe how their cache manager allocates blocks and changes which requests can share the device. The notebook uses dense batches with a different scheduler, so it measures its own dense positions instead of assuming paged-cache behaviour. PagedAttention, §§3–4
NF4 cut peak allocation while padding still consumed positions
Warm allocator peak and dense positions at load four
5| Format / batch | Peak MiB | Logical tokens | Dense positions |
|---|---|---|---|
| FP16 / 1 | 2987 | 21,800 | 21,800 |
| FP16 / 4 | 3088 | 21,800 | 36,500 |
| NF4 / 1 | 1221 | 21,800 | 21,800 |
| NF4 / 4 | 1302 | 21,800 | 36,500 |
NF4 compresses the stored weights and dequantises them for computation. In this benchmark its smaller allocation came with slower execution at matched settings. The QLoRA authors describe block-wise NF4 storage and a higher-precision compute type, with a separate adapter-training evaluation. That storage and compute distinction explains why an NF4 memory win need not become a throughput win. QLoRA, §§3–4
Read the returned digit and its continuation
Compare the opening F-250 request at the same concurrency with both FP16 dispatch sizes. The first digit is correct either way. The saved continuation is a useful counterexample to treating the first-token probe as a complete production reply.
load-001 · F-250 · long priority request in the opening burst
- Expected first digit
- 3
- FP16 batch 1 raw decode
- 3 Human:
- FP16 batch 4 raw decode
- 3 Human:
The first digit passes in both traces. The fixed six-token continuation includes a speaker marker, so the export does not show a response consisting of only one digit.
Both weight formats kept the same first digits on the probe
One-request probe and single warm replay, where load and batch are both one
6| Format | Load, s | Exact probe | Warm rps |
|---|---|---|---|
| FP16 | 17.34 | 12/12 | 4.39 |
| NF4 | 12.32 | 12/12 | 2.58 |
The walkthrough used a small exact-digit probe to check that changing the storage format did not disturb this task. The first-token capture passes all requests at these warm settings. Full-answer quality, network delivery and decoder stop behaviour require their own checks. NVIDIA’s benchmark walkthrough likewise fixes the input mix and output budget so comparisons are reproducible, and its streaming measurements cover a different client path. TensorRT-LLM performance benchmarking walkthrough
What to keep
| If the desk needs… | Start with… | Check before changing it |
|---|---|---|
| Faster clearing of simultaneous requests | A matched FP16 batch | Batch-four p95 total fell to 519 ms at load four. Measure whether isolated requests would wait for a batch to fill in your serving system. |
| Low first-token latency when quiet | A single FP16 dispatch | At load one its warm p95 first token was 58 ms. Increase load separately from batch size. |
| More GPU memory headroom | NF4 | The warm batch-four peak was 1,302 MiB versus 3,088 MiB for FP16, at 4.94 versus 9.23 requests/s. Re-run the digit probe and complete response checks. |
Next to try, not tested here
- Admit requests on a fixed external arrival schedule. Predict where queue tails rise before raising the rate.
- Group similar prompt lengths. Predict which of the recorded short and long slices benefits when less padding is needed.
- Add a one-digit stopping rule. Predict whether payload compliance changes independently of first-token accuracy.
How it was built
| Item | Setting |
|---|---|
| Model | Qwen2.5-1.5B-Instruct, both formats at 989aa7980e4cf806f80c7fef2b1adb7bc71aa306 |
| Hardware | One Tesla T4, CUDA 13.0 |
| Runtime | Python 3.13.16, PyTorch 2.14.1+cu130, Transformers 4.51.3, bitsandbytes 0.49.0 |
| Requests | Synthetic helpdesk priority questions, 100 per warm setting, equally split by prompt length |
| Load and schedule | Concurrency 1, 2 and 4. Dispatch singly or in matched batches. Same request order. |
| Decode | Greedy, fixed six-token continuation, first raw digit scored |
| Tail interval | 1,500 paired wave resamples. Seed 11. |
| Timing | Prewarm replay kept separate from warm figures. GPU allocation comes from PyTorch. |
Time and cost The measurement block took 319.48 s. Full notebook execution on the T4 took 336.60 s. FP16 model load took 17.34 s and NF4 load took 12.32 s. These receipts measure elapsed time. Colab compute-unit charging is separate.
Run it yourself
Open the notebook from the lesson header or download the executed export below. “Where does F-250 wait?” reconstructs the opening burst. The warm replay records the latency and memory comparisons. The paired tail and precision sections print the interval and digit-probe checks.
- Fix concurrency at four and change only the batch size from one to four. Predict the direction of throughput and p95 dispatch wait before inspecting the summary.
- Hold load four and batch four fixed. Change FP16 to NF4 and predict the memory and throughput trade-off.
- Keep FP16 batch size four and reorder the same prompts by length. Predict the difference in dense positions and which short requests move to a different wave.
Next, route and cache requests before they reach the GPU.
How is this page?
Last updated on