- vLLM
- Tool calling
- MCP
- Kubernetes
- GKE
- LLM serving
vLLM model behavior, multi-GPU serving, and tool calling
Why vLLM tool calling breaks after a model swap, how a small /dev/shm hangs tensor parallel in Kubernetes, and how to judge an LLM serving proof of concept against a p95 latency target.
This is part 3 of a practical guide to running vLLM on Kubernetes. Part 1 covers memory and the KV cache. Part 2 covers latency, routing, and autoscaling. Related work sits on the projects page.
I ran an internal proof of concept that served Qwen3-32B with vLLM on NVIDIA T4 and A100 GPUs in GKE, answering questions over a semantic layer through MCP tool calls. The cases here are what to watch for when the model has to call tools and when the server spans more than one GPU. They are common cases, not a diary of that POC.
A server that stays up can still be wrong. The usual shape is “it answers, but it does not call the tool” or “it started on the workstation and hangs in the pod.” Both are configuration. Read the symptom before you add hardware.
Read the response before you resize the GPU
A broken tool call and an undersized GPU do not look alike, and the expensive mistake is to treat the first as the second.
If the HTTP body has a tool_calls array, the parser ran. A wrong argument, a bad metric name, or a huge result is then an application problem. Cap the result, fix the tool schema, or fix the prompt. More GPUs will not change the JSON.
If the body has no tool_calls and the text contains a function-shaped string, the parser did not accept what the model wrote. Read the flags. --enable-auto-tool-choice and --tool-call-parser are the first two. The chat template is the third. This is the model-swap failure below.
If the process never binds the port, or the log is a CUDA out of memory during load, you are in part 1. Memory, context length, and tensor-parallel size. Adding a parser flag will not allocate a KV cache.
If the process is alive, the port is open, and startup never finishes on two GPUs, you are in the /dev/shm section. NCCL is waiting. The log is quiet unless NCCL_DEBUG=INFO is set.
Write that branch down in the runbook. “Works but the tool is not called” is configuration. “Crashes or will not start” is resources. “Hangs only inside the pod” is something the container took away.
Tool calls that come back as text
Symptom. The assistant used to call MCP tools. After a model change, or on a fresh Qwen deploy, it writes the call as prose. Sometimes the prose contains JSON. The tool server sees no request.
Cause. vLLM does not treat every JSON-looking span as a tool call. A tool-call parser for the model family extracts the call from the text. If tool choice is off, the model may still write a call-shaped string and vLLM will return it as content. If the parser is for a different family, vLLM does not recognize the new format. A common case is Qwen on the hermes parser, then a swap to Llama with that parser left in place. Llama’s JSON never becomes a tool_calls entry. The tool calling guide lists --enable-auto-tool-choice and --tool-call-parser as the pair you set.
Fix. Turn auto tool choice on, and set the parser that matches the model. Hermes for Qwen-style tool calls. llama3_json for Llama 3, usually with the Llama tool chat template, because the model also has to be shown tools in the format it was trained on.
vllm serve Qwen/Qwen3-32B \
--enable-auto-tool-choice \
--tool-call-parser hermes
vllm serve meta-llama/Llama-3.1-8B-Instruct \
--enable-auto-tool-choice \
--tool-call-parser llama3_json \
--chat-template examples/tool_chat_template_llama3.1_json.jinja
How to spot it. The HTTP response has no tool_calls field, and the message text contains something shaped like a function call. Then read the server flags. A model swap is not only a weights change. The parser, the chat template, the GPU count, and the evaluation set all move with it. Run that set before the swap is the default.
One more check belongs on the same list and does not explain this symptom. A larger model may need more GPUs so the KV cache still fits. That shows up as a startup failure, which is part 1. “It answers in plain text” is the parser.
Chat templates and stop tokens
Symptom. The model rambles past the answer, repeats itself, or gets worse after a fine-tune with no change in the data.
Cause. The chat template and the stop tokens tell the model where a turn ends. The wrong template means it never sees the end it was trained to expect. A LoRA trained with a different template than the one vLLM serves is the same bug in disguise. Quality drops and the logs look healthy.
Fix. Use the model’s own chat template and generation config. If you fine-tune, keep the training template and the serving template identical. Do not assume the server default matches the checkpoint.
Structured outputs and latency
Symptom. Forcing every answer into a JSON schema adds latency on each request. Or the schema is ignored, or the request fails, after a backend change.
Cause. Guided decoding constrains tokens so the output stays inside the schema. That costs time per token. A schema with features the decoding backend does not implement is skipped or rejected. Nested types and open maps are the usual offenders.
Fix. Keep schemas flat. A handful of required fields beats a document that mirrors your whole API. Use a guided-decoding backend you have actually timed, and test the schema before you depend on it. xgrammar is one backend people reach for when the default feels slow. Measure it on your schema. Do not adopt it from a slogan.
Numbers that drift away from the tool result
Symptom. The tool returns an exact figure and the sentence rounds it, retypes it, or invents a comparison.
Cause. The model is a writer sitting on top of the tool. If the prompt says “explain this,” it will explain, including arithmetic it should not do. A common case is a tool result of 1284503 rendered as “about 1.3 million,” or a growth rate the model computed from two numbers it half-remembered. The semantic layer already knows both numbers.
Fix. Insert figures from the tool output into the reply, and check every number in the final text against that output. Compute comparisons, percentages, and period-over-period changes in the semantic layer. The model picks the query and writes the explanation. It does not calculate, and it does not retype the figure. That split is what makes an MCP tool the source of the number instead of a hint the model is free to paraphrase.
Answers that change between runs
Symptom. An evaluation set scores differently on each run, even at temperature 0. A user asks twice and gets two explanations.
Cause. Batching changes which operations run together, and floating point addition is not identical across those groupings. Temperature 0 removes sampling noise. It does not remove that. The user-facing version is two explanations for one question, which reads as the system not knowing the number.
Fix. Score evaluations over several runs and track a pass rate, not a single score. Set seeds where the stack honors them. Keep the numbers themselves deterministic by reading them from the semantic layer, so the sentence can vary a little and the figure cannot.
Tensor parallel that hangs in the pod
Symptom. The same tensor-parallel command runs on a bare-metal box and hangs at startup in Kubernetes. No Python exception. The GPUs look busy talking, or they look idle. A second variant fails immediately because the parallel size does not divide the model’s attention heads.
Cause. NCCL uses /dev/shm for GPU-to-GPU setup. Bare metal gives that mount a lot of space. A container often gives it about 64 MB. NCCL never finishes, so the process sits there. The head-count failure is different and louder. --tensor-parallel-size has to divide the number of attention heads. Sizes that usually fit are 2, 4, and 8. An odd size the model cannot split refuses to start, which at least gives you an error.
Fix. Mount memory-backed storage at /dev/shm, a few gigabytes, not the default 64 MB. Request all of the GPUs in one pod so they schedule on one node and can use NVLink if the node has it.
spec:
containers:
- name: vllm
env:
- name: NCCL_DEBUG
value: INFO
volumeMounts:
- name: shm
mountPath: /dev/shm
resources:
limits:
nvidia.com/gpu: "2"
volumes:
- name: shm
emptyDir:
medium: Memory
sizeLimit: 8Gi
NCCL_DEBUG=INFO prints the step it is stuck on. nvidia-smi inside the pod confirms both devices are visible. If it still hangs, look at whether peer-to-peer access is allowed on that node. Put the shared-memory volume in the chart you reuse, so the next service does not rediscover a 64 MB mount.
8Gi in that manifest is one reading of “a few gigabytes.” Size it for the NCCL buffers you actually need, and remember it counts against node memory.
Splitting a model across nodes
Symptom. A model that does not fit on one node is spread across two GKE nodes and throughput collapses. Or a model that does fit on one node is split anyway, to use spare GPUs, and gets slower.
Cause. Tensor parallel assumes fast GPU-to-GPU links. Across ordinary VPC networking those links are not NVLink. Every layer waits on the network. Splitting a model that already fit is pure overhead.
Fix. Keep tensor parallel inside one node, on NVLink when you have it. If you must cross nodes, pipeline parallel is the split that sends less per step. A fast interconnect such as InfiniBand is what makes cross-node tensor parallel reasonable. Without it, prefer a smaller checkpoint on one node, or a hosted API for the overflow, over a quiet cluster that is slow.
Upgrades, drivers, adapters, and Spot
Symptom. A new vLLM image is slower, or pods fail after a node pool rolls. A per-customer LoRA will not load. A Spot node disappears at the peak.
Cause. Upgrades change defaults and sometimes remove flags. The image and the node driver are a pair. A newer CUDA in the image than the GKE GPU driver will not start. A LoRA whose rank is above the server’s configured maximum is rejected. Many adapters at once also cut throughput, and a cold adapter adds latency on first use. Spot capacity is preemptible by design. A region with no free GPUs of the type you pinned does not become free because the scaler asked.
Fix. Pin the image. Canary one replica. Rerun the benchmark from part 2 before the rest of the pool moves. Upgrade the driver and the image together. For adapters, set the maximum LoRA count and rank to what you will actually load, merge the busiest adapter into the base model if it is always on, and measure throughput with adapters attached. For capacity, spread the base load across zones on on-demand nodes, and keep a hosted API as a fallback when the GPU type is short. Spot is a cost tool for the portion of the pool you can lose.
A proof of concept benchmark is not a latency target
Symptom. A proof of concept quoted a high request rate. Later, on real questions, the same model serves far fewer requests before latency is unacceptable. A common sketch of that gap is about 40 requests a second on the benchmark and about 4 once the prompts look like production. People treat the first number as a promise.
Cause. Three mismatches stack. The prompts in the benchmark were short, and real requests carry tool definitions, tool results, and history, so they are several times longer. Repeated benchmark prompts hit the prefix cache and look cheaper than a user who sends a new prefix. The headline number was peak throughput, which is the region where latency is already poor. None of that requires a bug in vLLM. It requires the test to be a different workload than the one being sold.
Fix. Agree the success criteria before the test. At Rill, proofs of concept start from criteria agreed with the customer up front, and there have been 200+ of those POCs. An inference test deserves the same shape. Replay a sample of real requests. Measure p95 time to first token and time per output token. The number you keep is how many requests you can serve while that p95 stays inside the target, not the maximum rate at which latency has already collapsed. If an earlier benchmark did not match the traffic, say so, and rerun it on the real prompts with the other party watching. Then the options are concrete. Trim prompts and cache the static tool definitions. Cap concurrency per GPU. Add GPUs. Try a smaller model. Each option has a cost, and the new number is one both sides measured.
A short release checklist
Use this when the weights change, the flags change, or the chart changes. It is the same shape as any other upgrade. Pin the thing you are changing, try it on one replica, and measure before the rest of the pool follows.
- Parser and template match the model family. A Qwen checkpoint keeps
hermesuntil you have a reason to change it. A Llama checkpoint does not inherit that parser. - One request returns a real
tool_callsentry, and the MCP server logs the call. Plain text that looks like JSON is a failed check. - Every number in a sample answer matches the tool result. Comparisons were computed in the semantic layer.
- Startup on the real pod, with the
/dev/shmvolume, reaches ready. A workstation success does not count. - p95 time to first token on a replay of real prompts is inside the target you wrote down. Peak requests per second is not a substitute.
- The canary replica has run long enough to show
vllm:kv_cache_usage_percandvllm:num_requests_waitingon the dashboard from part 2.
If any line fails, the rollout stops. Adding GPUs is a response to a full cache or a long queue, not to a parser mismatch.
Part 1 is where a too-long prompt becomes an out of memory instead of a slow p95. Part 1. Part 2 is the autoscaler and the routing that decide whether that p95 is even measured on the replica with room. Part 2.
FAQ
- Why did tool calling stop working after switching models in vLLM?
- vLLM turns the model text into a tool call with a parser for that model family. Qwen tool calls are commonly read with --tool-call-parser hermes. Llama 3 JSON needs llama3_json, and often a chat template that describes tools the way that model was trained. If the flags stay on the previous family, the response has no tool_calls field and the JSON sits in the message as plain text. The MCP server is never called. Change the parser and the template, then rerun the evaluation set before the swap is live.
- Which vLLM flags enable tool calling for Qwen?
- Two flags. --enable-auto-tool-choice lets the model decide when to call a tool. --tool-call-parser hermes matches the tool-call format Qwen models commonly emit. The chat template has to understand tool messages as well. Hermes-style templates in the tokenizer config usually do. The flag reference is the vLLM tool-calling guide. Retest after any model change, because the parser is not a property of the server in the abstract.
- Why does vLLM tensor parallel hang in a Kubernetes pod?
- NCCL moves data between GPUs and uses /dev/shm. On bare metal that mount is large. In a container it is often about 64 MB, so NCCL setup never finishes and the process sits there with no Python traceback. Mount an emptyDir with medium Memory and a size limit of a few gigabytes at /dev/shm. Request every GPU in the same pod, for example nvidia.com/gpu: "2", so they land on one node. Set NCCL_DEBUG=INFO if you need the log line that shows the hang.
- How should an LLM proof of concept report latency?
- Agree the success criteria before the test, on the traffic you will actually serve, against a p95 latency target. Peak requests per second on short prompts is a different measurement. A common gap is a short-prompt run near 40 requests a second that falls to about 4 once prompts include tool definitions, tool results, and history. Replay a sample of real requests and report p95 time to first token and time per output token. Say so if the first benchmark did not match production traffic.
- Why does the model change a number that the tool already returned?
- The tool result is the source of the figure. The model is writing prose around it, and it will round, retype, or recompute if you let it. A tool that returns 1284503 can become "about 1.3 million" in the sentence, or a growth rate the model invented. Insert the number from the tool output, check every number in the answer against that output, and compute comparisons in the semantic layer. The model picks the query and writes the explanation.
