← Writing

Running LLM inference on customer GPUs — an on-prem serving field guide

Yunseop Im · Software engineer · M.S. CS, Georgia Tech · 2026 · ~25 min read

Contents 1. Why "just call the API" fails in enterprise 2. The serving stack: vLLM and SGLang under the hood 3. Hardware reality: fitting the model into GPUs you didn't choose 4. Guided decoding: making structured output actually reliable 5. Prefix caching: the feature that decides RAG economics 6. Quality as a regression surface 7. Operations you didn't sign up for 8. When on-prem doesn't make sense

1. Why "just call the API" fails in enterprise

Every AI feature demo eventually hits the same wall. The product works against OpenAI or Gemini, the demo lands, and then the customer's security review arrives: regulated records, unreleased IP, customer data under residency constraints — none of it can be sent to a third-party endpoint. Not "shouldn't," can't. The data residency constraint is contractual, sometimes regulatory, and non-negotiable.

At that point "add an LLM feature" silently becomes "operate an LLM inference service." You now own:

This guide is what that ownership actually looks like in production — the mechanisms that matter, the configuration that decides whether it works, and the places where the cloud-API intuition actively misleads you.

2. The serving stack: vLLM and SGLang under the hood

Both vLLM and SGLang expose an OpenAI-compatible API, so at the application layer they look interchangeable. They aren't — the differences are in how they manage the two scarcest resources in inference: GPU memory and attention computation.

Continuous batching: the baseline everyone has

Naive inference processes one request at a time — generate all tokens for request A, then request B. GPU utilization collapses because generation is memory-bandwidth-bound: you're shuffling weights for a handful of tokens at a time. Continuous (iteration-level) batching re-schedules at every decode step: finished requests leave the batch, new requests join mid-flight, and the GPU stays saturated as long as the queue is non-empty.

This is table stakes in both engines — it's why a single A100-class card can serve dozens of concurrent users instead of one. If a serving stack doesn't do this, it's a demo engine, not a production engine.

PagedAttention (vLLM): memory management for the KV cache

The KV cache — stored attention keys and values for every generated token — grows linearly with sequence length and is the dominant memory consumer during serving. vLLM's core contribution is PagedAttention: it manages the KV cache the way an OS manages virtual memory. Cache blocks are fixed-size pages that can be non-contiguous in physical memory, allocated on demand, and freed the moment a sequence finishes.

The naive alternative — pre-allocating a contiguous buffer sized for the model's maximum context per request — wastes 60–80% of KV memory on real-world traffic where most sequences are far shorter than the max. Paging turns that waste into usable batch capacity, which is why vLLM's throughput numbers became the reference point the whole field measured against.

RadixAttention (SGLang): prefix caching as a first-class structure

SGLang attacks the same problem from a different angle. Its RadixAttention stores the KV cache in a radix tree keyed by token prefixes: when a new request arrives, the engine finds the longest cached prefix and reuses its KV state instead of recomputing it.

Why this matters enormously for RAG and agent workloads: every request in a retrieval system shares a long, identical prefix — system prompt, tool definitions, few-shot examples — before the retrieved context diverges. With RadixAttention, that shared prefix is computed once and reused across thousands of requests. On our workloads, prefix caching routinely cuts time-to-first-token and prefill cost by an order of magnitude for the shared portion of the prompt. It's the difference between RAG being economically viable on-prem and being a latency/cost disaster.

vLLM has since added its own automatic prefix caching that achieves similar effects, so the practical takeaway is: check that prefix caching is enabled and verify it's actually hitting — a misconfigured cache silently falls back to full prefill on every request, and nothing errors.

The decision

vLLMSGLang
Memory modelPagedAttention — paged KV blocksRadixAttention — prefix tree reuse
Prefix reuseAutomatic prefix caching (v1)Radix tree, per-request longest-match
Structured outputxgrammar / outlines / guidance / lm-format-enforcerxgrammar backend, OpenAI response_format
DistributedTP/PP/DP, well-troddenTP/DP/EP, strong on large clusters
EcosystemLargest — most examples, quantization coverageFast-moving; strong on agentic/RAG patterns

In practice: for a first deployment, pick whichever your team can operate — both are OpenAI-compatible, so the application doesn't care. For RAG-heavy workloads, SGLang's radix caching is the more interesting bet; for maximum quantization flexibility and community support, vLLM is the safer default.

3. Hardware reality: fitting the model into GPUs you didn't choose

Cloud inference assumes you pick the hardware. On-prem inverts that: the customer already owns the GPUs — last year's purchase, a mixed fleet, whatever was cheapest at procurement time. Your serving configuration has to degrade gracefully across SKUs you didn't select.

The memory budget equation

What actually has to fit in VRAM:

VRAM required ≈ model weights + KV cache + activation overhead

Weights are the easy part — a 8B model at FP16 is ~16GB, at 4-bit AWQ ~5GB. The KV cache is the variable that bites you: it scales with batch size × context length. A 32k-token context at batch 32 across a 70B model can easily exceed the weights themselves. This is why "the model fits" is never the right question — "the model plus realistic KV cache at our target concurrency fits" is.

Quantization: not optional, the baseline

On customer hardware, quantization stops being an optimization and becomes a launch requirement. The practical options, in order of maturity:

The failure mode to avoid: discovering at deployment that the model fits in weights but OOMs the moment real traffic creates KV pressure. Benchmark with your context lengths and your batch sizes, not the model card's headline numbers.

Multi-GPU serving

When one card isn't enough, tensor parallelism (--tp N) splits each layer across N GPUs. It works, but it demands fast interconnect — NVLink within a node is fine, PCIe-only multi-GPU setups will bottleneck at the all-reduce operations. A realistic rule: prefer a smaller quantized model on one GPU over a bigger model stretched across a slow interconnect. Latency under TP scales with communication, and for interactive workloads TTFT matters more than peak throughput.

4. Guided decoding: making structured output actually reliable

This is the section most "LLM feature" writeups skip, and it's where production systems live or die. In a document-grounded product, the model must return not just text but citations tied to retrieved sources, fields that fit a schema, output that downstream code can consume without a parser that apologizes.

"Prompt the model to return JSON" gives you JSON-shaped text most of the time. Production needs a guarantee. That's what guided decoding provides: constraints applied during generation, at the token level, so invalid output is never produced rather than filtered afterward.

How it works mechanically

At each decode step, the engine computes logits over the vocabulary, then a structured-output backend masks out every token that would violate the constraint. The model literally cannot emit a token that breaks the schema. vLLM supports several backends — xgrammar (the default and fastest, compiles JSON schema/regex/EBNF to a pushdown automaton), outlines, guidance, and lm-format-enforcer — and the backend handles JSON schema, regex, context-free grammars, and enum choices.

What this looks like in code

Against a vLLM or SGLang OpenAI-compatible endpoint, constrained generation is just a request parameter — no post-processing needed:

response = client.chat.completions.create(
    model="customer-model",
    messages=[{"role": "user", "content": prompt}],
    temperature=0,
    response_format={
        "type": "json_schema",
        "json_schema": {
            "name": "grounded_answer",
            "schema": {
                "type": "object",
                "properties": {
                    "answer": {"type": "string"},
                    "citations": {
                        "type": "array",
                        "items": {
                            "type": "object",
                            "properties": {
                                "doc_id": {"type": "string"},
                                "quote": {"type": "string"}
                            },
                            "required": ["doc_id", "quote"]
                        }
                    },
                    "confidence": {"type": "number"}
                },
                "required": ["answer", "citations", "confidence"]
            },
            "strict": True
        }
    }
)

The strict: true flag matters: it makes the backend enforce the schema as a hard constraint rather than a suggestion. For citation grounding specifically, we constrain the model to emit doc_id references from the retrieved set — the citation isn't the model's memory of a source, it's a pointer the grammar forced it to populate. That converts "the model usually cites correctly" into "the model structurally cannot cite a document that wasn't in context" — a much stronger property for a high-stakes domain where a fabricated reference is a real-world error.

vLLM's Python API exposes the same machinery more directly via StructuredOutputsParams — choice, regex, JSON schema, or raw grammar — which is useful when you want constraints that don't map cleanly onto OpenAI's response_format (e.g., a custom EBNF grammar for a domain-specific citation format).

The caveat nobody mentions

Guided decoding has a cost: constrained tokens can fight the model's learned distribution, occasionally producing lower-quality text inside the valid structure. And overly complex schemas increase compile/masking overhead per step. The practical guidance: constrain the shape (JSON schema, required fields, enums) aggressively, but leave the content of string fields free — don't grammar-constrain natural language answers unless you have a measured reason to.

5. Prefix caching: the feature that decides RAG economics

Retrieval-augmented generation has a structural inefficiency: the system prompt, tool definitions, domain instructions, and few-shot examples are identical across every request — often 2–8k tokens — while only the retrieved documents and user query differ. Naive serving recomputes the KV state for that shared prefix on every single request.

Prefix caching eliminates this. The engine caches KV state keyed by token prefix; identical prefixes hit the cache and skip prefill entirely. On workloads where the shared prefix dominates prompt length — which describes nearly every production RAG deployment — this is the single highest-leverage serving feature you can enable.

Making it actually work

RadixAttention (SGLang) does longest-prefix matching in a radix tree, so it handles partial prefix overlap — two requests sharing the first 4k of a 6k-token prefix still reuse 4k. vLLM's automatic prefix caching works at block granularity with similar effect. For multi-tenant RAG where different tenants share the system prompt but diverge on retrieved content, this partial-match capability is what makes tenant isolation and cache efficiency compatible rather than opposed.

6. Quality as a regression surface

Here's the asymmetry that catches teams: a cloud model improves silently underneath you; your on-prem model is frozen at whatever checkpoint you deployed. Every config change — quantization level, guided-decoding grammar, temperature, context-length truncation — is a potential quality regression that no provider will warn you about.

The working setup:

7. Operations you didn't sign up for

The cloud API hid an operational surface that on-prem hands back to you:

8. When on-prem doesn't make sense

The contrarian section, because the honest answer matters more than the elegant one. On-prem LLM serving is the right answer when data residency is a hard constraint — regulated industries, defense-adjacent work, IP-sensitive customer data. It's the wrong answer when:

The teams that make on-prem work treat it like the infrastructure it is — with the same operational rigor as the databases and queues around it. The leverage isn't in model selection; it's in the unglamorous layers: serving configuration, prefix-cache economics, structured output guarantees, and knowing when to say "I don't know."

Related: Per-tenant RAG isolation · The production AI open-source stack · Running autonomous AI agents safely · profile
Sources: vLLM documentation · SGLang repository · Efficient Memory Management for LLM Serving with PagedAttention (vLLM paper) · SGLang RadixAttention / unified cache