$13.80 of GPU time · a practical exercise from Chapter 4 of Inference Engineering

I'm currently reading Inference Engineering by Philip Kiely (Baseten, 2026), and I'm doing every chapter hands-on, not just reading it. This post is the practical exercise for Chapter 4 (Software): I took an open model, served it myself on a rented
H100 with vLLM, and measured what actually happens when real users hit it.

All the code, raw data and notes are on GitHub:
github.com/iKnowJavaScript/road-to-inference-mastery

First, what is inference engineering?

There are two big steps in the life of a generative AI model.

Step one is training. This is the research side: you take a huge amount of data and compute and learn the model's weights, the billions of numbers that make the model what it is. That's
what labs like OpenAI, Anthropic, Meta or Qwen do.

Step two is inference. Once the weights exist, someone has to actually serve the model to users. Inference engineering is about finding the best and most efficient way to do that, so it
meets the business need (fast enough, cheap enough, able to handle enough users) without losing the quality of the weights you worked so hard to train.

There are several techniques for this. The main ones:

  • Batching. Serve many users' requests together in the same pass through the GPU, instead of one at a time. The GPU has to read the whole model from memory for every token anyway, so sharing that read across many users makes each one almost free.
  • Quantization. Store the weights in fewer bits (e.g. 8-bit or 4-bit instead of 16-bit). The model gets smaller and faster, and if it's done carefully, quality barely changes.
  • KV caching. While generating, the model keeps intermediate results (keys and values) for every token it has already seen, so it doesn't recompute them for every new token. Managing this cache well is a big part of serving.
  • Parallelism. Split one model across several GPUs (by layers, by tensors, or by experts) when it's too big or too slow for one.
  • Disaggregation. Run the two phases of inference, prefill (reading the prompt) and decode (writing the answer), on separate GPUs, because they stress the hardware in different ways.

This exercise only harnesses batching. vLLM always uses a KV cache, and I measured how much of it I used, but batching is the one technique I deliberately turned up and down. The others come in the next chapters.

Why I did this

In August I benchmarked this same model, Qwen3-8B, through OpenRouter, a shared API. The first run said time to first token(TTFT) was 19 seconds. For an 8-billion-parameter model that's crazy, and I had no way to know why. With a shared API you only see your side. You can't tell if the GPU was busy working, if your request was waiting in a queue, or something else.

So I decided to serve it myself and look at it from both sides.

I wrote my predictions down first

Before renting anything, I committed a file of predictions to git, worked out from the maths in earlier chapters. Once it's committed, I can't quietly change my answers after seeing the results.

The main prediction: one user on an H100 can get at most 205 tokens per second from this model.
The reason is that generating text (decode) is memory-bound: for every single token the GPU has to stream all ~16 GB of weights from its memory into its compute cores. 16.4 GB ÷ 3.35 TB/s
≈ 4.9 ms per token, so ~205 tokens/sec, no matter how fast the compute is.

The setup

  • 1× H100 SXM 80GB on RunPod at $4.40/hour. I had planned with $2.90/hour, but that was a different provider's price. So my first wrong prediction happened before I generated a single token.
  • vLLM 0.34.0, bf16 weights, 4,096-token context, a server batch limit of 64 requests.
  • Two scripts running at the same time: one acting as the users (sending requests and timing every token), and one watching the server's own metrics (how many requests are in the batch, how many are waiting, how full the memory is).

The results

Same model, my own GPU vs a shared API

On my own H100, one user got 149 tokens/sec and the first token in 36 ms. That's 73% of the theoretical maximum, which is normal for real hardware. Through OpenRouter the same model gave
21 tokens/sec and took almost a second to start.

Then I added more and more users:

Adding users to one H100

The raw output

This is batching, and it's the main lesson of the exercise.

From 1 user to 64 users, the server's total output went up 40×, but each user only got 18% slower. The GPU reads the model once per step whether 1 person is using it or 64, so the extra
users ride along almost for free. That's why batching is the economics of serving, not just a nice-to-have.

At 128 users, the wait for the first token jumped from 0.14 s to 1.65 s, but the speed per user didn't change at all. The server metrics showed why: 64 requests running, 64 waiting. The batch
was full, so half the requests sat in a queue. Once a request got in, it was just as fast as before. About 91% of that wait was queueing, not computing. This is exactly what I couldn't
see through a shared API. On my own server, I can see it clearly.

So what was OpenRouter hiding?

Not what I thought. When I went back to my August data, I found that Qwen3 is a reasoning model.
It "thinks" before it answers, and OpenRouter sends that thinking in a separate field that my script wasn't counting. So the 19 seconds was mostly the model thinking, not a queue. When I counted the thinking, the first token came in 1.3 s. With thinking turned off, 0.9 s.

That's still much slower than my H100, both to start and per token (46 ms between tokens vs 7 ms).
Part of it is the distance from Lagos to their servers. The rest I can only guess: bigger batches, cheaper GPUs, compressed weights, their own queue. And that's the point: on my own server I can
explain every millisecond. On theirs, I can only guess.

Where I was wrong

Predicted vs measured

This was the most useful part:

  • I said batch 32 would be compute-bound. It's memory-bound. My own spreadsheet from the previous chapter said so, and I still got it wrong.
  • I said the memory for the KV cache would be 85% full. It peaked at 4.1%. I assumed every request would use the full 4,096 tokens. vLLM only reserves memory for tokens actually used, and my requests were around 250 tokens. My per-token maths was exactly right though: 144 KiB per token, the same number vLLM reported.
  • I predicted $0.17 per million tokens. It was $0.32. Partly the higher hourly price, partly running below the theoretical speed. With 64 users it drops to $0.21. Keeping the GPU busy is what makes it cheap.

What it cost

What Lab 04 cost

Things that wasted my time (so they don't waste yours)

  • pip install vllm on the default PyTorch image fails because of a package Ubuntu installed. Use a virtual environment.
  • Node 18 turns localhost into an IPv6 address, but vLLM only listens on IPv4. curl works, every Node request fails. Use 127.0.0.1.
  • The server's own latency percentiles are estimates from histogram buckets. vLLM reported a p95 time-to-first-token higher than what my client measured, which is impossible. Use the server's averages and the client's percentiles.

What's next

Chapter 5: prefix caching, routing requests to the GPU that already has their data cached, and running prefill and decode on separate GPUs. Same rule: predictions first.

Code, data and notes:
github.com/iKnowJavaScript/road-to-inference-mastery· this lab is in
labs/lab-04-vllm.