Training & Inference

GPU Inference Optimization: Diagnosing Throughput Bottlenecks in Allocation, Memory, Queueing and Network

GPU inference optimization starts with a measurement problem. A GPU at near-100% utilization can deliver a fraction of its peak tokens per second.

Utilization counts the time a GPU spends busy, which says little about useful work. Run four checks in order to find where the time goes: allocation, KV cache memory (the GPU memory that holds each request's context), queueing and network.

TL;DR: Fix a model placed on the wrong GPU before you tune the rest of the stack. Then track Model Bandwidth Utilization (MBU), the share of memory bandwidth a workload uses, because token generation speed depends on memory bandwidth more than on compute.

How to measure inference throughput before the four checks

Throughput at the serving layer counts tokens per second across active requests. Per-request latency measures the wait for one request's response.

Healthy latency with low throughput usually means a shortage of concurrent requests. High throughput with poor latency usually points to queueing.

Model FLOPs Utilization (MFU) measures the share of the GPU's arithmetic a workload uses. Model Bandwidth Utilization (MBU) measures the share of its memory bandwidth.

The decode phase generates output one token at a time and waits on memory bandwidth, so MBU is the more useful signal for serving.

In one training run described in Zettabyte's MFU and MBU analysis, the GPU read 100% utilization at about 20% MFU. Tuning raised MFU to about 38%, and the utilization graph stayed near 100%.

Treat that run as a training example of the gap between a busy GPU and useful work. Training bottlenecks have different causes and need a separate diagnosis.

Step 1: Check GPU allocation and parallelism settings

Start by confirming the model runs on hardware that fits its size. Two allocation problems produce a busy GPU with slow output.

GMI Cloud's inference optimization guide covers the first problem. Google's documentation for its Kubernetes service covers the second.

  1. Model-to-GPU mismatch: A large-context model on a low-memory GPU leaves little room for the KV cache and forces small batches. GMI Cloud recommends routing lightweight embedding models to dense-throughput GPUs and large-context LLMs to high-memory GPUs. On a mixed fleet where requests land wherever capacity is free, make routing your first fix.
  2. Parallelism default: vLLM, an open-source serving engine, splits each model layer across GPUs by default when its Kubernetes pod (a group of containers scheduled together) has more than one GPU, according to the Google Cloud GKE inference documentation. This split, called tensor parallelism, follows the pod's GPU count and may not match the model's needs.

Compare the parallelism setting your engine started with against the model's size. Move on to memory once the model fits in its GPUs' memory and the parallelism setting matches that size.

If allocation was wrong, fix it and take a new measurement before the memory check.

Step 2: Diagnose memory pressure from the KV cache

Check whether the KV cache fits in GPU memory next to the model weights at your real batch sizes. Each decode step generates one output token and waits on memory bandwidth more than on compute, according to the NVIDIA Developer Blog's inference optimization analysis.

A GPU reads as busy during that wait. Size the cache with this formula from the NVIDIA analysis:

batch_size × seq_len × 2 × num_layers × hidden_size × precision_bytes

For Llama 2 7B at 16-bit precision (FP16), batch size 1 and a 4,096-token sequence, the cache comes to about 2GB. Multiply by your real batch size and context length, and compare the result with the GPU memory (HBM) left after the model weights.

A KV cache that silently caps the batch size creates a throughput ceiling that's hard to trace in the metrics.

MBU shows whether memory is the constraint. Databricks' LLM inference benchmarks measured about 60% MBU on two H100-80GB GPUs at batch size 1, and MBU fell at larger batch sizes.

That figure comes from one benchmark, so use it as a reference point. Low MBU at high utilization can mean a fragmented cache or a cache too small for large batches.

Four levers free or stretch KV cache memory:

  1. PagedAttention: Engines such as vLLM store the KV cache in fixed-size blocks spread across memory, which cuts fragmentation and allows larger batches. Support depends on your serving engine.
  2. FP8 KV cache quantization: vLLM's --kv-cache-dtype fp8_e5m2 flag stores the cache in 8-bit numbers, which shrinks it and can lower latency at large batch sizes. The GKE documentation notes that this quantization lowers accuracy.
  3. Context length cap: vLLM's --max-model-len flag limits the combined prompt and output length for each request. Gemma 7B's default 8,192-token context exceeds one NVIDIA L4 GPU's memory, and a cap under 640 tokens lets it run on one L4.
  4. Weight quantization: Storing model weights at lower precision frees GPU memory for the cache. The model quantization guide compares post-training quantization (PTQ) with quantization-aware training (QAT).

AI agents that call tools raise a separate question, KV cache tiering (moving cache between GPU memory and slower storage), covered in KV cache management for AI agents.

Move on to queueing when the cache at your target batch fits in free GPU memory and MBU holds near your measured baseline.

Step 3: Find queueing and batching bottlenecks that cap throughput

Spare GPU memory raises throughput once batches grow to use the space. GMI Cloud's guide lists five batching failure modes:

  1. Mismatched sequence lengths: One long sequence in a batch holds up the step for the other requests in the batch.
  2. Microbatches too small to saturate the GPU: Small batches waste part of the GPU's capacity.
  3. Batch timeouts set too long: The engine waits to fill a batch as requests sit in the queue.
  4. Similar workloads routed to different GPUs: Load spreads across devices that each run below capacity.
  5. A framework without dynamic batching: The engine can't add arriving requests to a running batch.

Compare queue depth with the speed of active requests. Look at the scheduler when requests pile up in the queue as active ones finish at normal speed.

An empty queue with low throughput means too little demand to fill the batches.

In-flight batching, described in the NVIDIA analysis, removes finished sequences and admits new requests without waiting for the longest sequence in the batch. It raises GPU utilization for workloads whose outputs vary in length.

Priority-based scheduling, which GMI Cloud describes, gives interactive requests GPU access ahead of background batch jobs. Queue time is one cause of slow time to first token, the wait for a request's first output token.

Move on to the network check when queue depth grows under bursts and drains at idle, and active requests keep their normal per-request speed.

Step 4: Rule out network limits in multi-GPU inference

The fourth check measures traffic between GPUs and between servers. A tensor-parallel deployment on a slow interconnect can show healthy per-GPU utilization and poor throughput across the deployment, because each decode step waits on communication between devices.

GMI Cloud lists three placement levers that cut that communication:

  1. Node affinity: Long-running workloads stay on the same servers.
  2. Colocated storage: Model files and other assets sit on storage near the GPUs.
  3. Node clustering: Grouping servers cuts cross-device communication.

Measure how much of each decode step goes to communication between devices. Network card (NIC) counters show the share that crosses servers.

Tensor parallelism across servers over a slow network gives the clearest case for moving the work onto one server. Single-GPU deployments can skip this check.

Stop adjusting placement once moving GPUs or storage closer together stops shrinking the communication share.

Worked example: diagnosing a two-GPU vLLM deployment with the four checks

The scenario below is illustrative, with figures worked from the formula above. A two-GPU vLLM deployment serving a 7B-class model reports 95%+ utilization and half the expected tokens per second.

Allocation. The engine started with tensor parallelism across both GPUs, vLLM's default when a pod has more than one GPU. The model fits on one GPU, so the split may add communication with little gain.

Set one GPU per replica and take a new measurement. If per-GPU throughput rises, allocation caused part of the loss.

Memory. Take one GPU at batch 16 with 2,048-token sequences and Llama 2 7B's dimensions (32 layers, hidden size 4,096, FP16): 16 × 2,048 × 2 × 32 × 4,096 × 2 bytes. That comes to about 17GB (16 GiB) on top of the weights.

Suppose the engine's running batch stays below the configured size and MBU reads low, which points at KV cache capacity. Turn on FP8 KV cache quantization and check output quality afterward, since it costs some accuracy.

If the running batch grows and MBU rises, memory caused part of the loss.

Queueing. Suppose the metrics endpoint shows several requests waiting as active ones finish at normal step time. The batch timeout is set long, so the engine holds requests to fill batches.

Shorten the timeout, and turn on in-flight batching where the engine offers that feature. Then check that per-request speed stayed at its earlier level.

Network. With tensor parallelism removed, inter-GPU traffic leaves the serving path. The remaining NIC traffic is storage and client traffic, which rules out placement.

Three causes cut throughput in this scenario, and each one showed up after the earlier fix.

What to monitor after fixing GPU inference throughput

Two signals catch regressions early:

  1. MBU against your own baseline: A drop shows that a model change, a quantization change, a longer context or a traffic shift has brought back KV cache memory pressure.
  2. Queue depth under normal load: A rising queue shows that demand has outgrown your batching settings.

Run the four checks again after a change to the model, its quantization, the parallelism setting or the traffic mix. A fixed deployment can drift back toward its old bottleneck.

For fleets too large to check placement by hand, zWARE tracks GPU, NIC, power and system health in granular detail and matches workloads to hardware based on real-time system state. It's one way to run the fourth check across a fleet.

LLM inference cost optimization covers the next lever, cost, once throughput reaches the hardware's limit.

GPU inference optimization FAQ

Does near-100% GPU utilization mean inference isn't bottlenecked?

Near-100% utilization doesn't rule out a bottleneck. Utilization counts busy time, and MBU and MFU measure the useful work within that busy time.

Decode waits on memory bandwidth, so a GPU reads as busy during those waits.

Which check comes first when diagnosing low inference throughput?

Start with allocation. A model on the wrong GPU or a wrong parallelism setting can skew each measurement after it, so confirm both before checking memory, queueing and network.