Kiran Tallapragada

Field notes GPU sizing

Self-hosted AI, layer by layer: what each layer decides and how it fails

Nine layers of a self-hosted model service, from the GPU memory budget to whether anyone can trust the output. For each: what it decides, how its failure looks from outside, the cause in a measured, calculated or production case, the check that separates them, and what the check returns.

“The GPU is too small.” “The model got slower.” “We need a bigger card.”

Each of those can be true. In the cases below, each was the wrong diagnosis. The failure showed up in one layer and was caused in another, and the fix that looked obvious would have cost money without moving the problem.

This is a map of nine layers in a self-hosted model service, from the GPU memory budget at the bottom to whether anyone can trust the output at the top. Each section below says what the layer decides, how its failure reads from outside, the cause in a case I measured, calculated or ran in production, the check that separates the two, and what that check returned. Each section says which. The map comes first, so you can copy it into an incident template.

The map

Layer The failure reads as The cause, in this case The check that separates them
1. Memory budget “24 GB should be plenty” The real budget is about 20.7 GiB Reported GiB × utilisation, before anything else
2. Weight precision “Model too big for this GPU” 16-bit weights leave too little for one request Weights in GiB against the budget, per precision
3. KV cache “It can’t serve two users” KV per token, not parameter count Layers × KV heads × head size × bytes
4. GPU count “Two GPUs, twice the capacity” The second card frees weight memory too Tokens per card, one GPU against two
5. Request slots A server that refuses to start Default slots above the card’s state capacity Slots against per-request state memory
6. Shared GPU Random out-of-memory errors Two processes, no written memory contract Peak of the others, then the server’s share
7. Concurrency “The GPU is slow” Contention past the sweet spot A concurrency sweep: throughput and latency per step
8. Health Everything slow, nothing down The model lost the GPU and ran on the CPU A speed probe against a known baseline
9. Output trust “The model makes mistakes” Mistakes escaped: no check the output had to pass A fixed answer set, and computed numbers

In a review, find the row that matches how the failure looked, and ask for that row’s check before anyone owns the fix. If the check points somewhere else, the fix was going to the wrong layer.

1. Memory budget: the card is smaller than its label

A 24 GB card reports about 22.5 GiB to the driver. vLLM 0.29 to 0.33 takes 92% of that by default (--gpu-memory-utilization 0.92): about 20.7 GiB. On a 48 GB L40S the budget is 41.4 GiB. Every later layer is carved out of this number, so planning from the label overstates capacity before any model is chosen.

The check: reported GiB × utilisation. Then subtract weights and overhead; the KV cache is the remainder.

This layer just moved. vLLM 0.34 (16 Nov 2026) turns on an extensible KV cache by default: it sizes the cache from memory actually free after warm-up, and the utilisation default becomes 1.0. Expect more KV capacity than the figures here, which come from 0.31. The check is the same; the input changed, so the numbers need re-measuring, which is next.

What it returned: on two 24 GB cards from different generations, an A10G and an L4, the KV capacity agreed within 0.4% in every run I measured. Memory size, not generation, decided how much context fit, so memory does not decide between them; speed and price do, and speed is not measured yet. Measured here.

2. Weight precision: fewer bits before less context

Qwen3-8B in 16-bit takes 15.3 GiB of weights. On a 24 GB card that leaves about 3.6 GiB of KV cache, less than one 32K request, and vLLM refuses to start. The obvious fix is to halve the context.

The check: weights in GiB against the budget, for each available precision.

What it returned: the official FP8 build cuts weights to 8.9 GiB and holds 2.8 times as many tokens at the full 32K context. Same card, same model family: two long requests instead of none, without giving up half the context. Check quality on your own task first. Measured here.

3. KV cache: count tokens, not parameters

Users are limited by KV cache per token, which depends on layers and KV heads, not on the parameter count on the label. With a 16-bit cache, Qwen3-4B and Qwen3-8B need the same 144 KiB per token; the 4B model holds more context mainly because its weights are smaller (its runtime overhead is a little lower too). Qwen3-32B needs 256 KiB.

The check: KV bytes per token, from the model’s config:

2 (key + value) × layers × KV heads × head size × bytes per value

What it returned: an 8-bit KV cache measured 2.09× and 2.18× the tokens of a 16-bit one on the 4B and 8B models: slightly more than double, because the cache budget also grew a little. It can change output quality, so test it before relying on it.

4. GPU count: the second card frees more than it adds

This layer and the next two are calculated with gpu-fit, not measured on the hardware.

Qwen3-32B in FP8 on one L40S leaves about 7.2 GiB for the KV cache: roughly 29,000 tokens, less than one 32K request.

The check: tokens per card with one GPU and with two, not total memory.

What it returned: split across two L40S, the weights drop to 16 GiB per card and each card holds half the KV heads: about 190,000 tokens of KV capacity, roughly six times one card. Twice the hardware, about six times the total context across concurrent requests, because the fixed weight cost stopped eating most of the memory. Worked through here.

5. Request slots: the default that stops a server

Hybrid models mix full attention with linear-attention layers that keep a fixed-size state per request. Qwen3.8-27B in FP8 has 64 layers, only 16 of which grow with context, and holds about 134,000 tokens on one L40S. Started with vLLM’s defaults, it refuses to start.

The check: request slots (--max-num-seqs, 256 by default) against how many per-request state slots the card can hold, about 160 here.

What it returned: one flag, --max-num-seqs 32, and the model runs, with four times the context the 32B model gets on the same card.

6. Shared GPU: write the memory contract down

Up to vLLM 0.33, the server reserves total memory × utilisation at startup and refuses to start if that much is not free. If another process on the card holds more than about 8% of it, the server will not start; if that process grows later, one of them runs out of memory mid-request. Rolling deploys, where old and new servers overlap, hit the same wall.

The check: the peak memory of everything else on the card, then give the server what is left. gpu-fit turns that into the highest utilisation vLLM will accept:

gpu-fit Qwen/Qwen3-8B --gpu L40S --reserve-gib 12 --context 16k --concurrency 8 --kv-cache-dtype fp8

What it returned: a starting value (0.72 in this example) that comes from a stated reserve, not from trial and error during an outage. On vLLM 0.34 the contract matters more, not less: its release notes name sharing a GPU as the case for setting the utilisation explicitly.

7. Concurrency: “it fits” is not “it’s fast”

In a production document service I ran, adding parallel work raised throughput, then flattened it, then made each job slower. Past a small number of parallel jobs the GPU was contending, not computing.

The check: a concurrency sweep, throughput and per-request latency at each step, then admit work against vLLM’s own metrics (KV-cache usage, requests waiting). nvidia-smi is not a reliable signal here: vLLM reserves its whole budget at startup, so the card always looks full.

What it returned: a measured operating point instead of a guess. The public sweep on a 48 GB card is my next measurement, so this row carries no number yet.

8. Health: slow is the outage you don’t see

The worst failure I have run into kept every dashboard green. Requests completed, far more slowly. The model had lost the GPU and was running on the CPU, and it took about two days to connect “everything is slow” with the cause.

The check: a fixed tiny prompt every minute, compared with a known tokens-per-second baseline. A model on the CPU fails it immediately. A health check that only asks whether the API answers will never catch this.

What it returned: a failure that took two days to explain gets a check that runs every minute and fails on exactly this symptom. I wrote the probe up as a small open-source tool, gpu-guard: early, tested against simulated servers so far, with real-GPU testing next. Short timeouts help for the same reason: they turn a slow GPU into an error someone notices.

9. Output trust: the layer every other layer serves

The top layer decides whether an output may be relied on. The failure reads as “the model makes mistakes”. Every model makes some; what turns them into failures is that nothing checked the output before it left, so the mistakes escaped.

The check: three of them. A fixed set of real examples with known answers, run before any model or instruction change ships. Every calculated number produced by tested code, never by the model. A schema the output must follow.

What it returned: in the document service, switching from free-text output to a schema deleted a fragile parser, and a smaller model with a schema matched the larger model’s accuracy on that task, using a fraction of the memory. The controls behind this layer are written up in Signing off AI output under audit.

Before the next incident

Take the last problem your team blamed on the GPU, the model or the hardware budget. Find the row that matches how it looked from outside and run that row’s check. If the check finds a different cause, the fix was about to go to the wrong layer.

How these numbers were made

Layers 1 to 3 are measured on vLLM 0.31 (the memory defaults changed in 0.34, see layer 1): AWS g5 (A10G) and g6 (L4) instances, raw data and script in gpu-fit’s bench/ folder. Layers 4 to 6 are calculated with gpu-fit, which mirrors vLLM’s memory budget and is calibrated against those runs; treat them as planning estimates and confirm on your own hardware. Layers 7 to 9 come from running a document service in production and carry no measured figures here unless stated. Public models only.