Large-Scale LLM Inference Deployment: A Practical Guide
This guide walks through the practical decisions behind deploying large language model inference at scale. It covers defining the objective across throughput, latency, and quality; profiling traffic before choosing an architecture; selecting tensor, pipeline, and data parallelism; using continuous batching and chunked prefill at the scheduling layer; managing KV cache and quantization to raise concurrency limits; and building elasticity, observability, and capacity governance. It closes with a recommended rollout path and common anti-patterns to avoid.
1. Defining the Problem: Two Curves, Capability and Cost
The model itself sets the upper bound on capability, but what users actually experience is how many usable results come back per unit of cost. So the objective function for large-scale inference deployment is not the lowest possible single-point latency. It is maximizing effective throughput while holding tail latency steady, under given constraints on GPU memory, bandwidth, and budget.
Three categories of metrics have to be constrained at the same time: throughput (output tokens per second), latency (time to first token and time per token), and quality (whether quantization and parallelism introduce accuracy regressions). These three pull against each other, and optimizing any single point can simply shift the pressure somewhere else.
2. Profile the Load First: Don’t Pick an Architecture Without Data
The first thing to do before launch is quantify the request distribution. At minimum, that means four things: the input length distribution, the output length distribution, the shape of peak concurrency, and the ratio of streaming to non-streaming requests.
Profile example (illustrative, not measured data)Input length: P50 512 / P95 4096Output length: P50 256 / P95 2048Peak concurrency: 6x the daily average, sustained for 10 minutesStreaming share: 80%
The profile directly determines the parallelism strategy. Long inputs are compute-intensive, so compute capacity and memory bandwidth matter more. Long outputs are memory-access-intensive, and the KV cache becomes the main bottleneck. Bursty peaks mean you have to keep elastic headroom rather than provision for the average.
3. Compute Tiering and Choosing a Parallelism Strategy
When a single GPU cannot hold the weights, the common approach is to start with tensor parallelism to split individual layers across GPUs, then use pipeline parallelism to split layers across nodes, with data parallelism for scaling out replicas horizontally. The practical order is to prefer tensor parallelism within a single machine to reduce cross-node communication, and introduce pipeline parallelism only across nodes, because inter-node bandwidth is typically an order of magnitude lower than intra-node interconnect.
More parallelism is not always better. The finer the split, the higher the share of communication, and at small batch sizes the workload is dragged down noticeably by memory access and synchronization overhead. A reasonable approach is to prepare two or three parallelism templates for different model sizes and switch between them according to traffic tiers.
4. The Scheduling Layer: Turning Waiting into a Reusable Resource
Static batching makes short requests wait behind long ones, and GPU utilization stays low over time. Continuous batching (iteration-level scheduling) immediately reclaims the slots of finished sequences after each decoding step and fills them with new requests. It is the most direct lever for raising throughput.
Paired with chunked prefill, which splits the prefill of a long input into small chunks interleaved with decoding, you can significantly flatten the spikes in time to first token and keep one long request from blocking the whole batch.
# Pseudocode: continuous batching main loopwhile engine.running:batch = scheduler.pop_ready() # ready requests from the waiting queueoutputs = model.forward(batch) # one forward pass covers multiple sequencesfor seq, tok in zip(batch, outputs):if tok.is_eos: scheduler.finish(seq)else: scheduler.requeue(seq) # requeue unfinished sequences immediatelyscheduler.admit(waiting_pool) # backfill to keep the batch level up
5. GPU Memory and Cache: The Real Bottleneck on Concurrency
KV cache usage grows linearly with “concurrency x context length,” which makes it the primary factor limiting concurrency. Available measures include paged cache management to reduce fragmentation, prefix caching to reuse identical system prompts and few-shot examples, and swapping the cache of inactive sequences out to host memory or an object storage tier.
Quantization is the other main thread: weight quantization reduces memory and bandwidth pressure, while cache quantization pays off more clearly in long-context scenarios. In practice, accuracy regressions must be validated against a business evaluation set, not judged by throughput numbers alone.
Speculative decoding fits scenarios with long outputs and latency sensitivity, verifying multiple tokens at once using a small draft model or a self-drafting approach. When the acceptance rate is too low, it adds overhead instead, so whether to enable it should be decided by load testing per scenario.
6. Elasticity, Observability, and Capacity Governance
When traffic has clear peaks and troughs, inference services should be containerized and wired into autoscaling, scaling on custom metrics such as queue length and cache hit rate rather than CPU alone. Slow cold starts can be mitigated by keeping pre-warmed resident replicas and caching model weights close to where they are needed.
Observability should cover at least four layers: the request layer (latency percentiles, error rate), the engine layer (batch level, cache hits, swap-out volume), the hardware layer (GPU memory, bandwidth, temperature), and the cost layer (cost per token). Without engine-layer metrics, performance problems are nearly impossible to locate.
Capacity load testing should use stepped load increases with explicit service level objectives, for example percentile ceilings for time to first token and time per token separately, and from those you can work backward to a safe concurrency level and redundancy ratio.
7. Rollout Path and Common Anti-Patterns
The recommended path: first build the load profile and evaluation set, then get a single-replica baseline working, then introduce continuous batching and prefix caching, and finally layer on quantization, autoscaling, and multiple parallelism templates.
Common anti-patterns include blindly stacking parallelism until communication drowns out computation; looking only at average latency and ignoring tail latency; skipping quality regression after quantization; provisioning capacity for average traffic; and lacking engine-layer metrics, so troubleshooting comes down to guessing. In a combination of general-purpose capabilities on a cloud platform such as Baidu AI Cloud, the container platform, object storage, log service, and monitoring and alerting can respectively handle deployment, weight distribution, trace collection, and metric alerting, leaving teams to focus their effort on scheduling and caching strategy itself.
