All Blogs
Oct 29, 2026
Technology Trends

How One Engineering Team Cut LLM Inference Latency by 60% Using vLLM

Eight seconds. That’s how long users were waiting for a single query response on a production RAG pipeline — on an A100 GPU sitting at 38% utilization.

The fix wasn’t more hardware. It was switching from a naive Hugging Face inference loop to vLLM — a change that took one week of engineering work and brought p50 latency from 8.2 seconds down to 3.1. If you’ve been exploring Python LLM inference optimization with vLLM, this is what it looks like in practice: the exact configuration flags, what broke, and what the cost math looked like on the other side. Four ML engineers, a LlamaIndex-based document Q&A product on Llama 3 8B, roughly 500 concurrent daily users at peak. That’s the setup.


The Starting Point: A Hugging Face Inference Loop That Couldn’t Scale

The team’s original inference handler looked like this:

from transformers import AutoModelForCausalLM, AutoTokenizer
import torch

model = AutoModelForCausalLM.from_pretrained("meta-llama/Meta-Llama-3-8B-Instruct")
tokenizer = AutoTokenizer.from_pretrained("meta-llama/Meta-Llama-3-8B-Instruct")
model = model.to("cuda")

def generate_response(prompt: str) -> str:
    inputs = tokenizer(prompt, return_tensors="pt").to("cuda")
    with torch.no_grad():
        output = model.generate(**inputs, max_new_tokens=512)
    return tokenizer.decode(output[0], skip_special_tokens=True)

Simple. Clean. And completely unfit for concurrent production traffic.

Each call blocked the GPU until completion. No batching, no KV cache sharing across requests, no mechanism for interleaving token generation across in-flight queries. When 10 users hit the endpoint simultaneously, 9 of them were sitting in a Python queue.

What the Profiling Actually Showed

Running nvidia-smi dmon -s u during a load test told the whole story:

MetricValue
GPU utilization (avg)38%
p50 latency8.2s
p95 latency14.7s
p99 latency22.1s
Throughput at 50 concurrent users1.8 req/s

GPU utilization at 38% is genuinely painful when you’re paying for an A100. The hardware wasn’t overwhelmed — it was idle. Not because there was nothing to do, but because the server could only process one request at a time.

Why They Started with Ollama (And Why It Wasn’t Enough)

Early in development, the team used Ollama for Python local LLM development, and honestly, it’s a great fit for that phase. Spinning up ollama run llama3 is fast, the API is clean, and for a solo developer iterating on prompts there’s not much that beats it. But Ollama is designed for ergonomics, not for multi-user production throughput. When they tried deploying it to handle real user load, response times climbed and the single-process model hit a wall almost immediately.

So they went looking for something built for scale.


Why vLLM Won the Evaluation

The shortlist was TGI (Hugging Face’s Text Generation Inference), NVIDIA Triton Inference Server, and vLLM. They spent about a week benchmarking all three.

vLLM is an open-source LLM inference engine that implements PagedAttention — a memory management technique borrowed from OS virtual memory — to serve dramatically more concurrent requests on the same hardware without rewriting your application layer. That distinction matters, because it’s what separates it from the alternatives.

ToolProduction ReadyOpenAI API CompatibleLlamaIndex SupportSetup Complexity
TGI (HuggingFace)YesPartialLimited docsModerate
Triton Inference ServerYesNoManual wiringHigh
vLLMYesYesNativeLow

TGI was a genuine contender — mature, production-tested. But the integration story with their existing Python stack was messier than expected, and the LlamaIndex compatibility documentation was thin. Triton got ruled out early; the configuration overhead for a team that’s not primarily infrastructure-focused was too steep.

Two things sealed the decision for vLLM.

PagedAttention. Standard transformers inference allocates KV cache memory upfront in contiguous blocks. When sequence lengths vary — and in a RAG pipeline, they always do — you get significant fragmentation. vLLM treats KV cache like virtual memory pages, allocating in fixed-size blocks and reusing them across requests. The result is dramatically better memory efficiency and the ability to serve more concurrent requests on the same hardware.

And the OpenAI-compatible API. The team’s application layer was already written against an OpenAI-style endpoint. Switching inference backends meant changing two lines of configuration, not rewriting request handling.


Optimizing Python LLM Inference with vLLM: The Migration

Standing Up the vLLM Server

The production launch command ended up here:

vllm serve meta-llama/Meta-Llama-3-8B-Instruct \
  --tensor-parallel-size 1 \
  --max-model-len 8192 \
  --gpu-memory-utilization 0.90 \
  --max-num-seqs 64 \
  --block-size 16

Each flag does real work:

  • --max-model-len 8192: Sets the maximum context window. The team hit OOM errors early because their RAG contexts were long. They had to profile actual prompt lengths in production traffic before setting this correctly.
  • --gpu-memory-utilization 0.90: Tells vLLM what fraction of GPU memory to reserve for the KV cache. The default is already 0.90, but being explicit forces you to think about it.
  • --max-num-seqs 64: Maximum sequences processed concurrently. Too low leaves throughput on the table; too high risks OOM under burst load. Getting this wrong in either direction costs you.
  • --block-size 16: KV cache page size. The default works for most workloads — they didn’t touch it.

KV Cache Configuration: Before vs. After

ParameterHuggingFace (before)vLLM (after)Effect
BatchingNone (sequential)Continuous4x throughput
KV cacheContiguous allocationPaged (block-size 16)~40% memory savings
Max concurrent seqs164Eliminated request queuing
GPU utilization (measured)38%82%Same hardware, more work

Rewiring the LlamaIndex RAG Pipeline

Here’s where the OpenAI-compatible API saved hours of work. The before state:

from llama_index.llms.huggingface import HuggingFaceLLM

llm = HuggingFaceLLM(
    model_name="meta-llama/Meta-Llama-3-8B-Instruct",
    tokenizer_name="meta-llama/Meta-Llama-3-8B-Instruct",
    device_map="cuda",
)

After, pointing the Python RAG application using LlamaIndex at the vLLM endpoint:

from llama_index.llms.openai_like import OpenAILike

llm = OpenAILike(
    model="meta-llama/Meta-Llama-3-8B-Instruct",
    api_base="http://localhost:8000/v1",
    api_key="EMPTY",
    is_chat_model=True,
)

That’s the entire application-layer change. Streaming responses and async retriever calls worked without modification — the vLLM endpoint handles them identically to how OpenAI’s API does.

What Broke on the First Try

Two things went wrong immediately.

First: OOM errors on long contexts. RAG pipelines retrieve multiple chunks, which means prompts get long fast. Their initial --max-model-len setting didn’t account for p95 context length. The fix was to profile actual prompt lengths from production traffic first, then set the flag accordingly. They also trimmed retrieved chunks from 512 to 384 tokens to stay within budget.

Second was AWQ quantization. They tried it to push latency lower — and it worked, dropping p50 another 0.4 seconds — but on several domain-specific query types, answer quality degraded noticeably. Full precision runs in production now; the quantized model stays on standby for high-traffic periods.


The Results: Latency, Throughput, and Cost

MetricHuggingFace LoopvLLMChange
p50 latency8.2s3.1s-62%
p95 latency14.7s5.3s-64%
p99 latency22.1s8.9s-60%
Throughput (50 concurrent)1.8 req/s7.4 req/s+311%
GPU utilization38%82%+116%

The throughput number at 50 concurrent users is what made the business case. At $2.50/GPU-hour on an A100, the team was spending roughly $60/day to handle peak load. After the migration, the same workload ran on the same hardware — with headroom to 3x their user base before needing to scale out.

Estimated monthly savings from deferred infrastructure spend: around $1,400. The one-week engineering investment paid back in the first month.


Lessons Learned: When This Approach Makes Sense

What Made the Migration Low-Risk

The rollback plan was simple: the original Hugging Face server stayed deployed behind a feature flag. If vLLM caused problems, flipping the flag reverted everything. They ran both in parallel for 48 hours, routing 10% of traffic to vLLM, before the full cutover.

That’s the right way to do this. Don’t cut over cold.

vLLM Is Not Always the Answer

Here’s where I’d push back on some of the hype: vLLM’s advantages are real at scale, but they’re not free. For single-developer workflows, Python local LLM development with Ollama is still faster to iterate with. The operational overhead of managing a vLLM server — monitoring, flag tuning, OOM diagnosis — isn’t worth it when you’re the only user.

Use Ollama locally, deploy vLLM in production. That split works well.

For sub-3B models at low concurrency, the continuous batching overhead can actually hurt latency compared to a simple Hugging Face loop. Profile your specific workload before committing.

What They’d Do Differently

Profile KV cache pressure before anything else. Most of their early OOM errors traced back to underestimating how much context the RAG pipeline was generating per request. Running vllm bench against a representative sample of production prompts first would have saved most of their debugging time.

Also: tune --max-num-seqs before touching --gpu-memory-utilization. The number of concurrent sequences has a bigger practical impact on throughput than fine-tuning memory allocation percentages. Start there.


Frequently Asked Questions

Does vLLM work with models other than Llama?

Yes. vLLM supports a broad range of architectures including Mistral, Mixtral, Qwen, Gemma, Phi, and others — the full list is in the vLLM documentation and grows with each release. The OpenAI-compatible API surface stays consistent regardless of the model you’re serving, so switching models doesn’t require changes to your application layer.

Can I run Python LLM inference optimization with vLLM on a single consumer GPU?

You can, with some caveats. --tensor-parallel-size 1 (the default) runs on a single GPU. For 7B–8B models, you’ll want at least 24GB VRAM — an RTX 4090 or A10G works reasonably well. Multi-GPU tensor parallelism is available with --tensor-parallel-size N for larger models. Consumer GPUs will see throughput gains from continuous batching, but the improvement is less pronounced than on datacenter cards due to memory bandwidth differences.

How does vLLM compare to just running more Hugging Face inference workers horizontally?

Horizontal scaling works, but it’s expensive. Each additional Hugging Face worker requires its own GPU with model weights loaded into memory. vLLM extracts dramatically more throughput from a single GPU before you need to scale out at all. In this team’s case, one vLLM instance on an A100 matched the throughput of roughly four Hugging Face workers — at a quarter of the GPU cost.

Is vLLM stable enough for production use?

As of late 2025, vLLM is widely deployed in production across major AI companies. It’s not without rough edges — OOM behavior under unexpected burst load, occasional compatibility gaps with the newest model architectures — but it’s stable for production inference workloads. One practical note: pin to a specific release version in your deployment rather than tracking main. The project moves fast, and version-to-version behavior can shift without warning.


The Migration Was Worth It

Three things drove the 60% latency reduction: PagedAttention eliminated KV cache fragmentation, continuous batching pushed GPU utilization past 80%, and the OpenAI-compatible API kept application changes to a handful of lines. This wasn’t a rewrite. It was a targeted infrastructure swap with a clear measurement plan and a rollback path that made it low-stakes to try.

If your inference latency is hurting and your GPU sits below 60% utilization, you’re probably in the same position this team was in. Run vllm bench against a sample of your real production prompts — not synthetic benchmarks, your actual traffic. The gap between what you’re seeing now and what’s possible will make the decision easy.

Upgrade from Hiring Developers to Deploying an AI-Augmented Engineering Team.

Tell us about your product, platform, or business software requirement. We will suggest the right team structure, roadmap, and engagement model within 48 hours.