Last reviewed: 2026-11 · Prerequisites: Prefill & decode, the decode roofline example

Before a launch someone asks: if time to first token (TTFT) must stay under 1 second at P99, how many requests per second can one GPU take? Peak tokens per second does not answer that. The wait for the first token has three parts: queueing for a free slot, the request's own prefill, and the extra time spent sharing each step with other requests.

This page puts the earlier stops into one worked example. First, the roofline gives how long one decode step and one prefill take. Next, those times give the most requests per second the GPU can finish when it is always busy. Last, adding queueing shows where TTFT P99 crosses the line. Every number comes from published specs and is an upper bound, not a measurement; the plan for measuring it is at the end.

The setup

Item Value Source
GPU RTX 4090, 24 GB GDDR6X, 1008 GB/s memory bandwidth Ada architecture whitepaper V2.02, Table 2
Peak compute FP16 Tensor Core, FP32 accumulate, dense: 165.2 TFLOPS Same
Model Qwen3-4B: 4.0B parameters, 3.6B without the embedding; 36 layers, 8 KV heads, head dimension 128 Model card, config
Weights 4-bit GGUF file Qwen3-4B-Q4_K_M.gguf, 2,497,280,256 bytes, about 2.5 GB Qwen3-4B-GGUF
KV cache FP16, $2\times36\times8\times128\times2=147456$ bytes per token, or 144 KiB Computed from the two rows above
Requests 512 input tokens, exactly 128 output tokens Teaching assumption
Two settings At most 2 or 8 requests decode together: the number of slots, such as --parallel in llama.cpp server Teaching assumption

A consumer card is used because the plan is to measure on one later. With an H100 and a 7B model the method is the same; see the roofline. This card's ridge point is $165.2\times10^{12}/(1008\times10^{9})\approx164$ FLOP/byte: an operation has to do more than 164 operations per byte read from memory before compute becomes the limit.

One decode step: requests share one read of the weights

In one decode step every request that is producing output moves forward by one token. The weights are read once however many requests there are; each request also reads its own KV. With $B$ requests decoding together and an average context $L$ of 576 (512 input tokens plus half the output), a lower bound for one step is:

$$ T_{\rm step}(B)\approx\max\!\left(\frac{2NB}{P},\ \frac{W+B\,L\,b_{\rm kv}}{\mathrm{BW}}\right). $$

$N$ is the parameter count, $P$ the peak compute, $W$ the bytes of weights, $b_{\rm kv}$ the KV bytes per token, and $\mathrm{BW}$ the memory bandwidth. The attention arithmetic over 576 positions is about 0.34 GFLOP, small next to the roughly 8 GFLOP of matrix multiplies per token, so it is left out here.

$B$ Step lower bound Tokens/s per request Tokens/s total
1 2.56 ms 390 390
2 2.65 ms 378 756
8 3.15 ms 317 2,538
16 3.83 ms 261 4,182
32 5.17 ms 193 6,185

At $B=1$ a step reads about 2.58 GB and does about 8 GFLOP: about 3 FLOP per byte, far below 164. Going from 1 to 8 requests makes each request only about a fifth slower, while total throughput grows 6.5 times, because the only extra reading is about 85 MB of KV per request. Even at $B=32$ the arithmetic takes 1.6 ms against 5.2 ms of reading, so bandwidth still sets the pace.

Decode is slow because of reading, not arithmetic: extra requests reuse the same read of the weights, so total throughput rises fast while each request slows only a little.

Those 2.5 GB of weights and the KV bytes are exactly what quantization shrinks; see quantization.

Prefill: 512 positions in one go

Prefill sends all 512 input positions through the matrix multiplies together. Each position costs about $2\times3.6\times10^{9}$ FLOP (the embedding is a lookup, and the vocabulary projection runs only for the last position), about $3.7\times10^{12}$ FLOP in all, so at least 22.3 ms at peak, while reading the weights once takes only 2.5 ms. At about 1,480 FLOP per byte it sits far to the right of the ridge point and is limited by compute.

So on an idle GPU, TTFT cannot go below these twenty-odd milliseconds plus tokenization and the network. The catch is that prefill also occupies the whole GPU. Without chunked prefill, the requests already producing output wait during a newcomer's 22 ms, and their users see a pause between tokens. For how long inputs are split and mixed with decode in one step, see how one request runs.

How many requests per second at full load?

Add up the GPU time one request uses: its own prefill, plus its share of the 128 decode steps. When every slot is always busy:

$$ t_{\rm req}(B)\approx t_{\rm prefill}+\frac{128\,T_{\rm step}(B)}{B},\qquad \lambda_{\max}=\frac{1}{t_{\rm req}(B)}. $$

$B$ Decode share Prefill Per request Most per second Prefill fraction
2 169.3 ms 22.3 ms 191.7 ms 5.2 12%
8 50.4 ms 22.3 ms 72.7 ms 13.7 31%
16 30.6 ms 22.3 ms 52.9 ms 18.9 42%
32 20.7 ms 22.3 ms 43.0 ms 23.3 52%

The larger $B$ is, the cheaper decode becomes per request, and prefill grows from about an eighth of the cost to half. Raising $B$ further buys less and less capacity because prefill has become the bottleneck. Chunked prefill and running prefill and decode on different GPUs both deal with this part; see multi-GPU deployment.

Memory is not the limit here. At $B=32$, with 640 tokens per request, the KV adds up to about 3.0 GB; with 2.5 GB of weights that is far from 24 GB. With inputs of several thousand tokens, KV capacity may be what runs out first; see the KV memory budget.

Add queueing: where does TTFT cross the line?

The ceiling above leaves no slack for queueing. Requests arrive at random times, and the closer the load gets to the ceiling, the more easily a queue builds up; see queues and failures. The short program below simulates this. Requests arrive as a Poisson process. In each step the engine moves waiting requests into free slots and runs their prefill, while every running request advances by one token; each step takes the lower bound from above.

import random

BW = 1008e9                     # RTX 4090 memory bandwidth, bytes/s
PEAK = 165.2e12                 # FP16 Tensor, FP32 accumulate, dense, FLOP/s
WEIGHTS = 2_497_280_256         # Qwen3-4B-Q4_K_M.gguf, bytes
PARAMS, NON_EMB = 4.0e9, 3.6e9  # all parameters / without the embedding table
KV_TOKEN = 2 * 36 * 8 * 128 * 2  # K and V, layers, KV heads, head dim, FP16 bytes
N_IN, N_OUT = 512, 128


def step_s(batch, prefill=0, context=N_IN + N_OUT // 2):
    """Lower bound for one engine step: `batch` requests decode one token
    each, and `prefill` prompt positions are computed in the same step."""
    flops = 2 * PARAMS * batch + 2 * NON_EMB * prefill
    moved = WEIGHTS + batch * context * KV_TOKEN
    return max(flops / PEAK, moved / BW)


def ceiling(slots):
    """Requests per second when every slot is always busy."""
    return 1 / (step_s(0, N_IN) + N_OUT * step_s(slots) / slots)


def ttft_p99(rate, slots, n=3000, seed=0):
    """Poisson arrivals; each step admits waiting requests into free slots,
    runs their prefill with one decode token for every running request."""
    rng, t, arrivals = random.Random(seed), 0.0, []
    for _ in range(n):
        t += rng.expovariate(rate)
        arrivals.append(t)
    now, i, waiting, running, ttft = 0.0, 0, [], [], []
    while i < n or waiting or running:
        while i < n and arrivals[i] <= now:
            waiting.append(arrivals[i])
            i += 1
        if not waiting and not running:
            now = arrivals[i]
            continue
        new = [waiting.pop(0) for _ in range(min(len(waiting), slots - len(running)))]
        now += step_s(len(running), N_IN * len(new))
        running = [k + 1 for k in running if k + 1 < N_OUT] + [1] * len(new)
        ttft += [now - a for a in new]
    ttft = sorted(ttft[n // 10:])
    return ttft[int(0.99 * (len(ttft) - 1))]


for b in (1, 2, 8, 16, 32):
    s = step_s(b)
    print(f"B={b:2}: step {s * 1e3:.2f} ms, {1 / s:.0f} tok/s each, {b / s:.0f} tok/s total")
print(f"prefill of {N_IN} positions: {step_s(0, N_IN) * 1e3:.1f} ms")
for slots, rates in ((2, (2, 3, 3.5, 4, 4.5)), (8, (6, 10, 12, 12.5, 13))):
    p99 = ", ".join(f"{r}: {ttft_p99(r, slots):.2f} s" for r in rates)
    print(f"{slots} slots: ceiling {ceiling(slots):.1f} req/s; TTFT p99 by rate -> {p99}")

With seed 0 and the first 10% of requests dropped, 2 slots give a P99 of 0.96 s at 3.5 requests per second and already 1.25 s at 4; 8 slots give 0.90 s at 12.5 and 1.25 s at 13. Over five seeds, bisection finds the arrival rate where P99 reaches 1 second:

Slots Full-load ceiling Most with P99 < 1 s (5 seeds) Share of ceiling
2 5.2 req/s 3.1–3.7 req/s 60%–71%
8 13.7 req/s 11.3–12.8 req/s 82%–93%

Why can 8 slots use about nine tenths of their ceiling while 2 slots use only about two thirds? With 2 slots a request holds its slot for about 0.36 s. When both are busy, a newcomer has to wait for one of them to finish, and because arrivals are random this happens often, long before the GPU is fully busy. With 8 slots a newcomer nearly always finds a free one and waits at most one step; a queue forms only close to the ceiling. It works like checkout lanes: at the same utilization, eight cashiers sharing one line keep people waiting less than two.

The price is slower output for each user: each request drops from 378 to 317 tokens per second, about 16% slower. With more requests running together, prefills also cut in more often, so output pauses more. In this model, holding the 1-second P99 target, 8 slots take about 3.5 times as many requests as 2 slots, so 8 is the choice. If per-user output speed matters more, as with long generations, that 16% belongs in the decision.

Size capacity by where the TTFT curve starts to climb steeply, not by full-load throughput; the fewer the slots, the further that point sits below full load.

Where can these estimates go wrong?

  • Peaks are not reached. Real kernels use only part of the bandwidth and compute, 4-bit weights also need dequantizing, and prefill usually falls even further short of Tensor Core peak. Real capacity will be lower than the tables; whether the ratio between the two settings holds needs a measurement.
  • Lengths are fixed. Real requests vary in length, and long inputs bring longer pauses and a heavier tail.
  • Overheads are left out. Tokenization, the chat template, HTTP, sampling and CPU scheduling are not counted, and engines cap the tokens per step, so a long input may be split across several steps.
  • Arrivals are Poisson. Real traffic comes in bursts, which makes P99 worse at the same average rate.
  • P99 itself is noisy. Each point rests on about 2,700 samples, and a different seed moves the crossing rate by more than a tenth. A decision based on a measured P99 needs repeated runs too.

Next: measure it on the same RTX 4090

This is the plan; it has not been run. llama.cpp server runs the same 4-bit model once with --parallel 2 and once with --parallel 8. Requests come from a fixed seed, each with a different prefix so nothing hits the cache, with input lengths matched to this page and exactly 128 output tokens. Arrivals follow a Poisson process at increasing rates. Each request records its TTFT, the prefill time the server reports, the difference between the two (the queueing), and its decode speed; every 0.5 seconds the server's counters show how many requests are running and how many are waiting.

Three predictions to check:

  1. Moving from 2 slots to 8 makes each request's decode only 10–20% slower;
  2. Under the P99 < 1 s target, 8 slots take far more requests;
  3. 2 slots cross the line first because of queueing, with the waiting count rising early; 8 slots cross only close to their ceiling.

The results will come with software versions, the driver and the request conditions. Where they disagree with the estimates here, the write-up will say which part of the time was off.