Skip to content
  • vLLM
  • GPU inference
  • LLM serving
  • Kubernetes
  • GKE
  • KV cache

vLLM memory and capacity on Kubernetes

Why vLLM pods die at startup, how the KV cache fills, and how to tell a Kubernetes OOMKilled from a GPU out of memory. A practical guide to GPU inference and LLM serving on GKE.

This is part 1 of a practical guide to running vLLM on Kubernetes. Part 2 covers latency, routing, and autoscaling. Part 3 covers model behavior, multi-GPU pods, and tool calling over MCP. Related work sits on the projects page.

I ran an internal proof of concept serving Qwen3-32B with vLLM on NVIDIA T4 and A100 GPUs in GKE. It answered questions over a semantic layer through MCP tool calls. The cases below are what to watch for on that kind of service. They are common cases, not a log of failures from that POC.

vLLM’s memory story is simple to state and easy to get wrong. The weights are large and fixed. The KV cache grows with context length and with how many sequences are in flight. Kubernetes then adds a second budget, the container’s host memory, which is not the GPU. Most “it OOMed” reports are one of those three things wearing the wrong name.

What the GPU is actually holding

Two allocations dominate, and they fail at different times.

The weights are loaded once. A checkpoint of this class is on the order of 65 GB before you count a quantized variant, which may be smaller. That cost does not change when a user sends a short question. If the weights do not fit, the process dies while it is still loading, with an empty queue.

The KV cache is the per-token state the attention layers reread on every new token. It scales with the number of layers, the number of key and value heads, the head dimension, the bytes per element, the context length, and the number of sequences that are alive at once. vLLM’s PagedAttention stores that state in fixed-size blocks instead of one contiguous slab per request, which is why a request can be preempted and resumed. It does not make the state free. A long context reserved up front, or many long prompts at once, still has to fit in whatever GPU memory is left after the weights.

That is why startup and steady state are different bugs. At startup vLLM profiles the GPU and reserves a cache large enough for max-model-len. If that reservation fails, you never serve. Under load the same cache is shared across concurrent sequences. A server that booted can still die, or stall, when the live set is bigger than the profile assumed. max-num-seqs only limits the second case.

Continuous batching, which part 2 leans on for latency, also means the GPU stays busy whenever any sequence is running. Memory pressure and “the GPU looks 100% utilized” are not the same chart. Read cache usage and preemptions, not only the NVIDIA utilization gauge.

A useful order when a pod restarts:

  1. Pod events. OOMKilled means host RAM. A CUDA error means the GPU.
  2. Whether the failure is before the first request or after readiness.
  3. max-model-len, gpu-memory-utilization, and max-num-seqs on the command line that actually ran.
  4. The cache gauge on /metrics in the minutes before the restart.

Change one of those, not all of them, and restart. A pod that now boots and then dies at the same concurrency has told you the startup reservation was not the bug.

Out of memory before the first request

Symptom. The pod fails during startup. It has not taken a request. The log is a CUDA out of memory, or vLLM reports that it cannot allocate the KV cache.

Cause. Startup reservation is weights plus a KV cache sized for max-model-len, not for the short prompt you plan to send first. A common case is a 32B model with a 128K context on one GPU. The weights fit, and the cache for 128K does not, so the process exits before the first token. Moving a smaller model, for example an 8B, onto a 24 GB L4 with a long context can crash-loop the same way. The GPU class changes. The arithmetic does not.

Fix. Lower --max-model-len to the context users actually need. 16K is plenty for a lot of question-answering. If the GPU is dedicated to this model, you can raise --gpu-memory-utilization so vLLM is allowed to use more of the device. An FP8 KV cache (--kv-cache-dtype fp8) shrinks the cache itself. Lowering --max-num-seqs does not help here. That flag caps how many sequences run at once. It does not shrink the cache vLLM tries to reserve at boot.

vllm serve Qwen/Qwen3-32B \
  --max-model-len 16384 \
  --gpu-memory-utilization 0.90 \
  --kv-cache-dtype fp8

Use FP8 for the cache only after you have checked quality on your own prompts. Part 1’s quantization section is why.

Healthy at idle, then a restart under load

Symptom. The readiness probe passes. The service looks fine with no traffic, or with a light test. A burst of real questions restarts the pod.

Cause. The idle process only proved that the minimum cache fit. Concurrent requests allocate KV blocks for their full prompts. A common case is a k6 run that passes at 8 concurrent users and fails at 64 once the prompts are long. Monday morning looks the same. Everyone asks at once, and the cache that was comfortable all weekend is suddenly full.

Fix. Lower --max-num-seqs so the worst concurrent set still fits. Leave headroom below the memory fraction you configured. Alert on KV cache usage before it reaches 1. On current vLLM the gauge is vllm:kv_cache_usage_perc (1 means full). Older builds exposed the same idea as vllm:gpu_cache_usage_perc. Scrape /metrics on the version you run and alert on the name that is actually there. The metric list is in the vLLM metrics docs.

Answers that stall when the KV cache fills

Symptom. Answers freeze for a few seconds in the middle of a stream. The pod does not crash. Users notice it most when traffic clumps.

Cause. When the cache is full, vLLM preempts. It pauses in-flight requests and recomputes them later so a new request can proceed. The stream stalls, then continues. That is preemption, not a crash. MCP tool results make it more likely. A large table in the prompt holds far more KV state than a short question.

Fix. Watch the preemption signal next to cache usage. Current builds expose vllm:request_num_preemptions as a histogram of how often requests were preempted. Older dashboards used a counter named vllm:num_preemptions_total. Either way, a climb during the stall window is the confirmation. Then pick one of three levers. Give the cache more room (higher utilization on a dedicated GPU, or more GPUs). Cut concurrency with --max-num-seqs. Or shorten --max-model-len if users do not need the full window. The cheapest structural fix is to trim tool outputs before they enter the prompt. Part 3 covers why the model should not be the thing that compresses those numbers.

Two processes on one GPU

Symptom. A second model on the same device dies as soon as vLLM starts, or two replicas on one node both get slower and then one is killed.

Cause. --gpu-memory-utilization defaults to 0.9. vLLM takes 90% of the GPU for weights and cache, and the other process gets the scraps. Time-slicing does not create a second memory pool. Two vLLM pods scheduled onto one physical GPU still share one device’s memory, and each will try to grab most of it.

Fix. Give each model its own GPU. If you must share, set a lower --gpu-memory-utilization on each process so the fractions add up to less than 1, with room for CUDA’s own allocations. MIG partitions are the hardware version of the same idea. They split the device into isolated slices so one process cannot see the other’s memory. Do not treat time-slicing as isolation.

resources:
  limits:
    nvidia.com/gpu: "1"

One GPU in the limit, and a node selector or GPU sharing policy that keeps a second pod off that device, is the configuration that matches “dedicated GPU per model.”

Cold starts and weight downloads

Symptom. A new replica takes many minutes to serve. A Spot node on GKE is reclaimed, the replacement pod spends that time downloading weights, and the traffic spike is over before the pod is ready.

Cause. A checkpoint on the order of 65 GB, pulled from Hugging Face on every cold start, is a network transfer plus a load into GPU memory. Ten minutes is a normal outcome for that path, not a slow disk. An autoscaler that adds a replica at the peak inherits the same delay. The replica becomes ready after the peak.

Fix. Keep the weights close to the node. A persistent volume, a copy in GCS, an image layer, or a boot disk all beat a fresh download. Keep a minimum number of warm replicas for the traffic you already know about, instead of scaling from zero into a download. Part 2 is where autoscaling metrics belong. The memory point here is that a cold start is a weight-load problem first and a scaler problem second.

OOMKilled is not a GPU out of memory

Symptom. The pod is OOMKilled while weights are loading. Or the GPU log says it is out of memory, and kubectl top still looks calm.

Cause. These are different budgets. OOMKilled means the container’s host memory limit was too low for the load path. The weights are read into CPU memory on the way to the GPU, so a limit under the checkpoint size fails even when the GPU has room. A CUDA out of memory is the GPU budget. kubectl top samples about every 60 seconds, so a short peak during load does not show up in the average.

Fix. Read the exit code and the pod events before you change a flag. If the event is OOMKilled, raise the container memory limit above the model size, with headroom for the loader. A checkpoint around 65 GB does not fit in a container limit well under that size, no matter what --gpu-memory-utilization says. If the event is a CUDA error, you are back in the KV cache sections above. Watch peak memory, not the one-minute average.

Tool results that blow the context window

Symptom. A broad question fails, or gets much slower, after a tool call. A long chat gets slower on every turn even when each new question is short.

Cause. The model context is the whole prompt, not the user’s sentence. A tool that returns thousands of rows can push one request past max-model-len. A chat that resends the full history pays for every previous turn on every new request. Both show up as context errors, as preemptions, or as a slow time to first token.

Fix. Cap and paginate tool results in the semantic layer, which is the system that actually holds the numbers. Summarize or drop old turns before you resend history. Send the model the rows and the instructions it needs for this answer, not the warehouse. Keep the figures in that layer and let the model write the explanation. That split is also how you keep a single tool result from becoming the whole context window. A page of rows plus a pointer to the next page is a much smaller KV allocation than the full result, and the number the user sees still came from the tool.

Quantization that does not match the GPU

Symptom. An FP8 checkpoint uses less memory and runs slower than the FP16 or BF16 build you compared it with. Or a 4-bit model fits, and tool calls start coming back as slightly broken JSON.

Cause. Quantization is a hardware match, not a free shrink. FP8 suits GPUs with native FP8, such as H100 and L4. A100 and T4 do not have native FP8, so an FP8 path there can be emulated and slower than you hoped. A 4-bit AWQ (or similar) checkpoint saves more memory and can also change how reliably the model emits tool-call JSON. The memory win and the format of the tool call are separate tests.

Fix. Pick the checkpoint for the GPU you will actually serve on. If the device is an A100 or a T4, measure the unquantized or the INT8/AWQ option against your prompts instead of assuming FP8 is faster. After any quantization change, rerun the evaluation set, including tool calls if the model is supposed to call MCP tools. A checkpoint that fits and then writes bad JSON is not a win. Part 3 is the parser and template side of that failure.

A sizing pass that does not lie to you

Do this once on the GPU you will actually serve on, with the checkpoint you will actually serve. A number from a different device, or from a short random prompt, does not transfer.

  1. Boot with the max-model-len you intend to ship. If it does not boot, the weights plus the minimum cache do not fit. Shorten the context or change the checkpoint before you tune concurrency.
  2. Send one realistic prompt, including the tool definitions and a large tool result, not a one-line greeting. If that single request fails, concurrency is not the problem.
  3. Raise concurrency with k6 or the equivalent until vllm:kv_cache_usage_perc climbs or requests start to wait. The concurrency just below that knee is the --max-num-seqs to start from. A test that is fine at 8 users and fails at 64 has found a knee. It has not found a universal constant.
  4. Record host memory peak during load, not the kubectl top sample. Set the container limit above that peak.
  5. Kill a pod and time the replacement through to the first token. That number is your cold start. Part 2’s autoscaler cannot beat it.

Write those five results down next to the flags. The next person who raises max-model-len to the model’s full window will otherwise rediscover the startup crash.

The next piece is what happens when the process stays up and the latency does not. Part 2 covers long prompts, prefix caching, routing, and why GPU utilization is the wrong autoscaling signal.

FAQ

Why does vLLM run out of memory at startup?
vLLM reserves GPU memory for the weights and for a KV cache sized from max-model-len before it serves a request. If that reservation does not fit, the process dies with an empty queue. Lower max-model-len to the context users actually need, raise gpu-memory-utilization only when the GPU is dedicated, or use an FP8 KV cache. Lowering max-num-seqs does not help at startup, because that limit applies to concurrent requests, not to the initial reservation.
Why does a vLLM pod pass readiness and then crash under load?
Readiness only proves the process started and the minimum cache fit. Real prompts, especially long tool results, allocate more KV blocks than the idle check. A common case is a load test that looks fine at 8 concurrent users and falls over at 64 once prompts get long. Lower max-num-seqs, leave memory headroom, and alert on vllm:kv_cache_usage_perc before it reaches 1.
What is the difference between Kubernetes OOMKilled and a GPU out of memory in vLLM?
OOMKilled is the container runtime stopping the pod because host memory crossed the limit. A GPU out of memory is CUDA failing inside the process, and the pod may simply error or restart without that exit reason. Check the exit code and pod events. kubectl top samples about every 60 seconds, so it often misses the brief peak while weights load.
How do I stop MCP tool results from exhausting the vLLM KV cache?
Each token in the prompt and the output holds KV state until the request finishes. A tool that returns thousands of rows makes one request far larger than the average you sized for. Cap and paginate tool results in the layer that owns the numbers, and send the model only the rows it needs to explain. Shorter max-model-len and fewer concurrent sequences also give the cache room.
Why is FP8 slower than expected on an A100 or T4?
FP8 is a good fit for GPUs with native FP8, such as H100 and L4. A100 and T4 do not have that, so an FP8 checkpoint there can be slower than the memory savings suggest. A 4-bit checkpoint saves more memory and can also change tool-call JSON. Rerun the evaluation set after any quantization change.
Portrait of Rohith Reddy Kota

Written by Rohith Reddy Kota

Forward Deployed Engineer at Rill Data. I run 2+ PB of ClickHouse, Druid, and DuckDB on Kubernetes for enterprise analytics customers.

Connect
esc
↑ ↓ navigate↵ select