LLM Inference Framework Selection and Deployment: A Practical Guide
This article explains why choosing an LLM inference framework is often more critical than choosing the model itself, and compares two main approaches: server-side high-throughput engines and lightweight local runtimes. It covers the core techniques behind each path, including paged KV cache management, continuous batching, chunked prefill, parallelism, and quantization, along with a capability comparison, a selection checklist, capacity estimation and load testing methods, and common pitfalls to avoid. Readers will learn how to make data-driven deployment decisions based on traffic patterns, hardware constraints, and latency requirements.
1. Background: Why Inference Framework Selection Is Often Underestimated
When teams move a large language model from an experimental environment into real production workloads, most of the effort goes into evaluating model quality. Yet what often determines whether a deployment succeeds is the inference serving layer. With the same model and the same corpus, switching the inference runtime can change throughput by several times, and time to first token can shift from “acceptable” to “unacceptable.”
The reason is that inference workloads behave very differently from training. Requests arrive randomly and in bursts, output lengths are unknown in advance, GPU memory usage grows dynamically with context length, and compute-bound and memory-bound phases alternate. Any runtime that assumes fixed request lengths and constant concurrency will expose queuing and fragmentation problems under real traffic.
As a result, the industry has split into two clear paths. One is the server-side inference engine built for production, focused on GPU memory utilization and concurrent throughput. The other is a minimalist deployment approach for local and edge environments, focused on easy installation, cross-platform support, and low resource usage. These are not replacements for each other; they occupy two different niches: centralized high concurrency and distributed lightweight interaction.
2. Technical Core of Server-Side High-Throughput Engines
2.1 Memory Fragmentation Is the First Enemy of Throughput
Autoregressive decoding requires caching the key and value pairs for every layer and every attention head, and this cache grows linearly with context length. Traditional implementations reserve a contiguous block of GPU memory for each sequence, sized to the maximum expected length. The unused portion can neither be reused by other requests nor reclaimed, and fragmentation often exceeds 60%. The result is allocation failures despite nominally sufficient memory, a forced reduction in batch size, and idle compute capacity.
2.2 Paged Cache Management
Borrowing from the idea of virtual memory in operating systems, the cache is split into fixed-size physical blocks, and a logical block table maps each sequence to its physical blocks. Blocks are allocated on demand and returned when no longer needed. This change brings three benefits. First, waste drops to single-digit percentages, freeing memory for larger batches. Second, sharing becomes cheap: requests with the same prefix can point to the same physical blocks, greatly reducing repeated computation of system prompts and few-shot examples. Third, swapping in and out has a uniform granularity, laying the groundwork for cache reuse in long contexts and multi-turn conversations.
2.3 Continuous Batching and Scheduling
Static batching must wait for the longest sequence in a batch to finish before releasing the whole batch, so short requests are held back by long ones. Iteration-level scheduling refines batching from the request level to the step level: after each step, the batch is reorganized, new requests can be inserted immediately, and finished sequences exit right away. Combined with chunked prefill, long prompts are split into small chunks and executed together with decoding steps. This smooths the long tail of time to first token and prevents a long prompt from monopolizing compute and starving other requests.
2.4 Parallelism, Quantization, and Scaling Limits
When the parameter size exceeds the capacity of a single GPU, tensor parallelism splits the computation of each layer across multiple GPUs, or pipeline parallelism splits the model by layer. Tensor parallelism involves frequent communication and is better suited to intra-node environments with high-speed interconnects. Pipeline parallelism is friendlier to bandwidth but introduces pipeline bubbles. Multi-instance data parallelism is the most direct way to increase total throughput.
Weight quantization and paged caching fit together naturally: weights stored at low bit widths reduce memory and bandwidth pressure, while cache blocks are moved on demand, allowing a higher concurrency ceiling within limited memory. It is worth stressing that higher parallelism is not always better, because communication overhead and scheduling complexity can offset the gains. Decisions should be based on measured results.
Illustrative server startup parameters (these express general configuration dimensions only and do not represent a specific product interface):
model-path : local directory of model weightstensor-parallel : tensor parallelism degree, usually no more than the number of high-speed interconnected GPUs in one machinemax-num-seqs : maximum number of concurrent sequences, determines the balance between memory and latencygpu-memory-util : upper limit ratio of GPU memory usage, leave headroom for other processesmax-model-len : context window limit, directly affects per-request cache usage
3. Technical Core of Lightweight Local Deployment
The value of the lightweight path lies not in extreme throughput but in delivery cost. It packages the runtime, model weights, and configuration into an image-like unit that can be pulled with a single command, hiding differences in drivers, operator libraries, and quantization formats. This lets developers run an inference in minutes on a laptop or a single-GPU edge device. Underneath, it typically relies on a C/C++ inference implementation that runs efficiently on both CPUs and general-purpose GPUs, combined with automatic hardware detection and quantization precision selection, bringing the memory threshold down to consumer levels.
The trade-offs are equally clear: scheduling is mainly single-request or very low concurrency, with no iteration-level continuous batching or mature tensor parallelism, and limited multi-GPU scaling. In centralized high-concurrency scenarios, throughput per unit of compute clearly lags behind. When there is ample compute and many concurrent online users, the measured gap between the two approaches can reach several times. This matches practical observations: server-side engines optimize attention and caching and natively support high concurrency, which is the main source of the difference.
4. Capability Comparison
| Dimension | Server-Side High-Throughput Engine | Lightweight Local Approach |
|---|---|---|
| Optimization goal | GPU memory utilization, concurrent throughput | Easy installation, low resource usage |
| Cache management | Paged block management, low fragmentation | Mostly contiguous allocation, length limited |
| Batching | Iteration-level continuous batching, chunked prefill | Single request or very small batches |
| Scaling | Tensor parallelism, pipeline parallelism, multiple instances | Mainly single machine, single GPU |
| Interface | Resident service compatible with common calling protocols | Local command-style invocation and lightweight service |
| Typical scenarios | Online customer service, batch extraction, coding assistant backends | Development and debugging, offline tools, privacy-sensitive intranets |
5. Selection Checklist
Start with traffic characteristics: are there more than ten concurrent online users, is a stable service level required, and is the input/output length distribution long-tailed? If the answer is yes, choose a server-side engine. If it is single-user, offline availability matters most, and data must stay within an intranet, the lightweight approach is more economical. A hybrid architecture is often best: the edge handles prototyping and sensitive data processing, the server side handles scaled traffic, and the two are decoupled through a unified service abstraction layer so that business code is not locked to a single runtime.
6. Capacity Estimation and Load Testing
A rough estimate starts from a simple inequality: available memory per GPU must exceed the weight footprint plus the cache footprint, where the cache footprint is roughly the number of concurrent sequences multiplied by the average context length multiplied by the cache bytes per layer. From this, you can derive the maximum concurrency supported by a given amount of memory, and reserve about 20% headroom for bursts.
Load testing should cover three types of workloads: short input and short output to test peak throughput, long input and short output to test prefill and time to first token, and short input and long output to test cache growth and scheduling fairness. Metrics should include at least throughput, time to first token, inter-token output interval, queuing time, and peak GPU memory. Increase concurrency step by step to find the latency inflection point rather than looking only at averages.
7. Common Pitfalls
First, treating quantization as lossless. Low bit widths accumulate errors more easily in long reasoning chains and structured output, so regression testing on a business evaluation set is needed. Second, looking only at memory and not bandwidth. Decoding is often memory-bandwidth bound, and adding GPUs will not help if bandwidth is insufficient. Third, ignoring prefix repetition. A long system prompt without cache sharing means paying the same cost every time. Fourth, lacking timeouts and backpressure. Under burst traffic, piled-up requests turn a latency problem into a stability problem. In related practice, Baidu AI Cloud generally recommends combining inference services with common capabilities such as monitoring and alerting, logging, and container platforms to form an observable, elastically scalable loop.
8. Conclusion
The two paths solve different problems: one pushes limited memory and compute to the limit to serve many users, while the other hides complexity to serve one person’s immediate needs. Understanding the applicable boundaries of paged caching, continuous batching, and parallel scaling, and making selection decisions based on data rather than impressions, is the most reliable engineering approach at the LLM deployment stage.
