AI Systems · Infrastructure

LLM Inference and Serving Systems

LLM serving architecture: continuous batching, paged KV cache, quantization, prefix caching, autoscaling, failure modes, evals, and when not to self-host.

Read time
16 min
Level
Advanced
Updated
2026-08-25
Components
Continuous batcher · Paged KV cache · Quantization layer
The short answer

An LLM inference serving system is the runtime that turns GPU (or other accelerator) capacity into token throughput and latency SLOs: a scheduler that continuously batches in-flight generations, a paged KV-cache so memory is not wasted on padding, optional quantization, prefix caching for repeated prompts, and autoscaling on queue depth rather than CPU. Model weights are the easy part; the serving stack is what makes a private deployment usable.

Key takeaways

  • 01

    Continuous batching, not static batches, is what makes interactive serving efficient: sequences join and leave the batch as they finish.

  • 02

    KV-cache memory, not FLOPs, is usually the binding constraint; paged attention and cache-aware scheduling are the levers.

  • 03

    Quantization (FP8, INT8, AWQ/GPTQ-class INT4) is a measured trade: run the eval suite at the serving dtype, not at the training dtype.

  • 04

    Autoscale on queue time and KV-cache occupancy, not on GPU utilization — a full GPU can still be latency-starved.

  • 05

    Pin model and engine versions; silent engine upgrades change tokenizer behavior, stop sequences, and structured-output reliability.

01

What an inference stack actually is

A serving stack is a request scheduler plus a model runtime. The scheduler owns admission, prefill vs decode, preemption, and fairness. The runtime owns kernels, KV-cache layout, tensor or pipeline parallelism, and sampling. In front sits a gateway: auth, request schema, streaming SSE/gRPC, timeout, and a load-shedding policy. Beside it sits a cache for prefixes and, optionally, a draft model for speculative decoding. Observability is not optional: queue time, prefill ms, time-to-first-token, tokens/s, KV occupancy, and abort rate.

Engines in this class — vLLM, TensorRT-LLM, TGI, SGLang, and vendor runtimes — differ in kernels and features, not in the architecture. If you cannot name where prefill, decode, KV pages, and the queue live in your deployment, you do not have a serving system yet; you have a Python script holding a GPU.

02

Data flow: prefill, decode, cache

A request arrives with prompt tokens, sampling params, and optional logit bias or grammar. Prefill runs the prompt through the model once and materializes KV pages. Decode then emits one token (or a speculative block) at a time, appending to those pages. Continuous batching mixes prefills and decodes from many requests in the same step so a finished sequence’s slots are reused immediately. Streaming tokens leave the gateway as they are produced; the client does not wait for EOS.

Prefix / prompt caching reuses KV pages when many requests share a long system prompt or a RAG prefix. It is the single largest win for agent and RAG workloads whose prompts are 80% identical. It is also a correctness hazard if two “same” prefixes differ by a tokenizer version or a trailing space — hash the exact token ids, not the string.

  • Admit → tokenize → (prefix cache hit?) → prefill → decode loop → EOS/abort
  • Continuous batch: sequences enter and exit every step
  • KV pages allocated on demand; preemption when occupancy hits the cap
  • Prefix cache keyed on token ids plus model/engine version
  • Stream tokens; never buffer the full completion for interactive SLOs
03

KV cache, quantization, and parallelism

During decode, each live sequence holds a KV cache that grows with context length. That memory, not matrix multiplies, is why a GPU “at 100%” still queues. Paged KV layout (the idea behind PagedAttention and its descendants) allocates cache in blocks so you do not reserve max-length padding for every request. The scheduler must know occupancy: admit a new prefill only if pages will exist for the promised max tokens, or preempt the lowest-priority decode.

Quantization shrinks weights and sometimes KV. FP8 and INT8 are the usual production starting points on modern accelerators; 4-bit is a memory play that needs the eval suite at that dtype. Tensor parallelism splits layers across GPUs for large models; pipeline parallelism is for models that do not fit even split. Do not combine speculative decoding, aggressive quantization, and a new engine version in one change — you will not know which broke stop sequences.

04

Autoscaling, routing, and multi-model

Scale replicas on queueing delay and KV occupancy, with a floor that covers cold-start. GPU utilization is a trailing indicator and will tell you to scale down while p95 TTFT is already red. Keep a warm pool; model load plus CUDA graph capture is minutes, not seconds. Route short-context cheap models and long-context or high-quality models to different pools so a 128k RAG job cannot starve interactive chat.

Multi-LoRA serving belongs here when you have many adapters on one base: load adapters on demand, cap concurrent adapters by VRAM, and pin which adapter id a request may use. Merge-on-deploy is simpler if you have one adapter and a stable base. Either way the gateway, not the client, chooses the adapter.

05

Failure modes

Head-of-line blocking: a few long prefills occupy the batch and interactive TTFT explodes. OOM from KV growth mid-decode, especially with unbounded max_tokens. Tokenizer mismatch between training, eval, and serve. Prefix-cache collisions or stale pages after a prompt template change. Structured-output grammars that deadlock the sampler. Load shedding that returns 200 with an empty stream. An autoscaler that chases GPU% and flaps.

Silent quality drift is the failure evals exist for. An engine upgrade that changes sampling defaults, a switch from FP16 to INT4, or a stop-token bug that truncates JSON will not page you. Pin engine, image, model hash, tokenizer, and dtype. Canary a replica on the golden set before the rest of the fleet moves.

  • Long prefills starving decode (need prefill caps / chunked prefill)
  • KV OOM and unplanned preemption
  • Tokenizer or stop-sequence mismatch
  • Quantization accepted without the eval suite at that dtype
  • Autoscaling on GPU% instead of queue time
06

Evals, and when not to self-host

Serving evals are two suites. Quality: the same golden set you run for prompts, at the production dtype, engine, and sampling params — including JSON/schema tasks. Performance: TTFT p50/p95, inter-token latency, throughput at a stated concurrency, abort rate, and KV occupancy under a replay of production traces. A tokens/s number from a single long generation is marketing, not capacity planning.

Do not self-host if your volume does not fill a GPU, if you cannot staff on-call for engines, or if a provider’s zero-retention endpoint already meets residency. Do self-host when data cannot leave the VPC, when you need a pinned engine for regulated evals, or when prefix-heavy agent traffic makes a dedicated fleet cheaper than token APIs. The architecture above is what you operate in that case — not “run vLLM and hope.”

Frequently asked questions

What is an LLM serving system?

It is the stack that schedules inference on accelerators: continuous batching of many in-flight generations, paged KV-cache management, optional quantization and prefix caching, a streaming gateway, and autoscaling on queue depth. Weights on disk are not a serving system. The stack’s job is to meet a time-to-first-token SLO at a stated concurrency without corrupting sampling or schemas.

What is continuous batching?

Continuous batching lets sequences join and leave the GPU batch every decode step instead of waiting for a fixed group to finish. Finished requests free KV pages immediately; new prefills fill those slots. That is how interactive serving stays efficient under mixed prompt lengths. Static batches either pad wastefully or hold short replies hostage to the longest sequence.

Why does KV cache matter more than FLOPs?

Decode is often memory-bandwidth bound, and each live request stores keys and values for every layer and every token of context. When pages run out, the engine preempts or OOMs regardless of unused compute. Paged KV, admission control on promised max tokens, and prefix caching are the controls. Watch KV occupancy next to GPU utilization.

Is quantization safe in production?

It is safe only after you run the production eval suite at the serving dtype and engine, including structured-output and tool-argument cases. FP8 and INT8 are the usual first step on current hardware. 4-bit saves more memory and more often shifts stop behavior, rare-token spelling, and JSON validity. Do not promote a quantized replica because a chat demo looked fine.

When should we not self-host inference?

Skip self-hosting when traffic will not fill a GPU, when you cannot on-call an engine, or when a provider endpoint already meets residency and retention requirements. Self-host when data must stay in-VPC, when you must pin engine and tokenizer versions for regulated evals, or when shared prefixes make a dedicated fleet cheaper. Half-operated GPUs fail as silent quality bugs, not as clean outages.

Keep reading

ArchitectureMulti-Agent Orchestration SystemsQualityLLM Evaluation Systems (Evals)TrainingRL Environments for Agent TrainingArchitectureAgent Memory SystemsArchitectureAgentic RAG SystemsArchitectureComputer-Use Agent SystemsArchitectureFunction-Calling and Tool-Use SystemsArchitectureGraphRAG SystemsArchitectureHuman-in-the-Loop AI SystemsArchitectureHybrid Retrieval and Re-ranking SystemsQualityLLM Guardrail SystemsInfrastructureLLM Observability and TracingInfrastructureMCP Tool Gateway SystemsArchitectureModel Routing and Fallback SystemsTrainingPEFT and Fine-Tuning PipelinesArchitecturePermissioned Retrieval SystemsQualityPrompt Injection Defense SystemsArchitectureRAG ArchitectureArchitectureRealtime Voice AI SystemsQualityAI Red-Teaming SystemsArchitectureStructured Generation SystemsTrainingSynthetic Data Generation Systems

Building one of these systems?

We help teams design, build, and validate production AI systems — orchestration, evals, and training environments included.

FAQ

Working with us

How soon can AI systems work start?

Typically within a week or two of a scope being agreed. The first delivery is deliberately a small batch so you can check the output against your expectations before volume ramps.

What do you need from our team?

One process owner who knows the workflow, one engineer with access to the systems involved, and a weekly 45-minute review. No standing committee, and no requirement for an ML specialist on your side.

Who owns the output and the data?

You do. Datasets, labels, weights, evaluation suites and runbooks are yours and are handed over at the end. Your data trains your models only, with zero-retention provider settings by default.

Can you scale volume up quickly if we need it?

Yes, and the quality bar holds because the rubric and gold set are already agreed by that point. Ramping is a staffing question, not a re-scoping one, so it usually takes days rather than a new engagement.

We already have a vendor for this. Why switch?

Often you should not. The cases where teams move to us are when they cannot get a quality number out of their current vendor, or when the work is delivered as an opaque batch with no trace of how disagreements were resolved.

What happens after the engagement ends?

We stay on-call for 30 days at no extra cost, then move to an optional support retainer. Most teams also keep a quarterly evaluation review with us to catch drift early.

Copyright © 2026
ReinforcedX, Inc.
All rights reserved