Single GPU Inference Arithmetic: Part 2 - Benchmarking
22 Nov 2026
Last time, we created idealized hardware estimates of Qwen3.5-4B running on an H100 SXM, but what are the actual numbers?
We can use an inference provider and see. The way these things work is via an API you can give them some workload with some specified parameters, mostly around the GPU you want and the number of those, and then your workload itself is generally powered by some inference engine (more on this later).
In our case, this looks something like this. One GPU, Qwen3.5-4B, BF16 weights, ~2048-token initial prompt, and vLLM as the engine.
# Pseudocode - Modal provides the hardware.
@modal.function(gpu="H100")
def benchmark():
# vLLM loads and runs the model.
engine = vllm.load(
model="Qwen/Qwen3.5-4B",
dtype="bfloat16",
tensor_parallel_size=1,
enable_prefix_caching=False,
) prompt = tokenize(text)
prompt = repeat_and_trim(prompt, length=2048) warm_up(engine) return measure(
engine,
prompt_token_ids=prompt,
output_tokens=256,
temperature=0,
ignore_eos=True,
repetitions=10,
)
From part 1, the idealized numbers were:
- Prefill: ~15.3 ms
- Decode: ~2.54 ms/token at a context length of 2,048
- Decode speed: ~394 tokens/s
The actual numbers, taking the median across ten measured runs after two warm-ups, were:
- Time to first token: 34.88 ms
- Decode: 4.12 ms/token
- Decode speed: 242.6 tokens/s
Time to first token (TTFT) includes producing the first output token and can include engine overhead, depending on the timing boundary. The idealized prefill estimate covers the prompt computation.
This comparison isn’t super apples-to-apples for two reasons.
- Our idealized estimate didn’t model the details of vLLM’s implementation, like cache management and kernel fusion.
- We assumed peak compute throughput, peak memory bandwidth, and perfect overlap between computation and memory. Real execution can’t do this at all points.
Measured decode took 1.62× the idealized estimate. Measured TTFT was 2.28× the idealized prefill time, though the two cover different work. The way I think about it is that when doing any sort of tracing and estimation work, the goal is to get within the order of magnitude of reality, or else something is really wrong either with your assumption or with your workload. In our case, we are for sure quite close, so we will leave it there!
vLLM
I sort of glossed over my choice of using vLLM as the inference engine. Since we use one GPU with one single request, we don’t exercise continuous batching or partitioning across GPUs. vLLM handles request batching and scheduling on one GPU and can distribute inference across multiple GPUs.
Within a single GPU, it also helps with local optimized model implementation - efficient KV cache management (paged attention), choosing the correct kernels for our matmuls, CUDA graphs (replayed GPU operations, lower CPU overhead). This is what is useful in our case.
All we have to really do is just give vLLM the GPU we’re using, the # of GPUs, and the model. That’s it!
One Layer Down
Because we lose most of the benefits of vLLM, we can go one “layer” down and implement our model as a Hugging Face Transformers model running directly on PyTorch. Essentially, Hugging Face has an open-source PyTorch implementation of Qwen, which we will just use directly.
We obviously lose some of vLLM’s benefits. But let’s try it and get the timings anyways. This pseudocode doesn’t include some optimizations I ended up including. Specifically, I preallocated a fixed-size cache and used torch.compile and CUDA graph replay for both prefill and decode. The compiler builds an optimized version of the tensor computation, potentially fusing operations into fewer kernels. CUDA graphs let us replay the GPU work with less CPU launch overhead. We compiled prefill and decode separately, since they process different input shapes.
# Simplified pseudocode - static cache, compilation and CUDA graphs omitted.
@modal.function(gpu="H100")
def benchmark():
model = transformers.load(
model="Qwen/Qwen3.5-4B",
revision=SAME_CHECKPOINT,
dtype=torch.bfloat16,
device="cuda",
)
model.eval() prompt = tokenize(text)
prompt = repeat_and_trim(prompt, length=2048)
prompt = move_to_gpu(prompt) def generate():
# Prefill produces the first output token.
output = model(
input_ids=prompt,
use_cache=True,
logits_to_keep=1,
)
state = output.cache
token = argmax(output.last_token_logits)
record_first_token() # Subsequent tokens require decode steps.
for _ in range(255):
output = model(
input_ids=token,
cache=state,
use_cache=True,
# Supply the appropriate positions and masks.
)
state = output.cache
token = argmax(output.last_token_logits)
record_next_token() with torch.inference_mode():
warm_up(generate, repetitions=2) return measure_gpu_aware(
generate,
repetitions=10,
)
Taking the median across ten measured requests after two warm-ups, we get:
- Time to first token: 76.19 ms
- Decode: 7.02 ms/token, or about 142.5 tokens/s
Decode takes about 70% longer per token than vLLM’s 4.12 ms/token. Not bad.
TTFT is about 2.18× vLLM’s 34.88 ms. Also not bad, but still worse. vLLM was faster on both metrics for this workload and these configurations.

In Part 3, we’ll look at the economics behind all this.