LLM Deployment: How AI Infrastructure Determines Success or Failure
Once a large language model is trained, the real challenge lies in inference. Unlike the one-time cost of training, inference expenses scale continuously with user requests. This article explores why inference costs grow, how inference workloads differ from training, and key infrastructure strategies—including elastic scaling, VRAM management, and batching optimization—required to ensure stable and economical LLM services. It also provides a practical pre-deployment checklist for engineering teams.
After a large language model (LLM) completes training, the real test for engineering teams is inference. While training is a one-time investment, inference continuously generates costs with every user request. Many teams only discover high online latency, low resource utilization, and unpredictable costs after their model meets performance targets. Whether inference can run stably and economically depends heavily on the underlying AI infrastructure, including compute scheduling, VRAM management, network, and storage. This article breaks down the topic across three dimensions: cost, load characteristics, and infrastructure strategies.
1. Why Inference Costs Continue to Grow
Training costs are typically concentrated in the model development phase; once weights are fixed, the expenditure does not repeat. Inference costs, however, are directly correlated with service request volume. Every input token in a request must be computed by the model, and every output token must be generated step-by-step. Both processes consume GPU compute time, VRAM, and bandwidth. The higher the request volume, the higher the total cost.
Therefore, when planning budgets, enterprises cannot look solely at one-time training fees; they must also estimate the long-term expenditure of inference. The cost per single token can be estimated using the following rough formula:
Single Token Cost ≈ GPU Hourly Rate ÷ Effective Output Token Throughput per Hour × Utilization Correction Factor
Throughput should be measured under real request length distributions; the ideal values provided by vendors are for reference only. The utilization correction factor reflects the proportion of GPU idle time. If GPUs remain idle for extended periods during traffic valleys, the actual single token cost will be significantly higher than the result calculated at full load.
Monthly total cost can be estimated using “Daily Average Requests × Average Input/Output Tokens × Single Token Cost,” plus storage, network, and operational overheads. When measuring, the scope should be clearly defined—for example, whether it includes the consumption of pre-warmed instances, backup capacity, and failed retries.
2. Key Differences Between Inference and Training Workloads
Training can be performed offline, processing data in fixed batches, and can tolerate longer runtimes. As long as the final model precision meets the standard, efficiency fluctuations during training have limited impact.
Inference, on the other hand, handles real-time requests and must simultaneously meet response speed, throughput, and stability goals. The following three issues are most common:
- Request Volume Fluctuations: Different businesses have vastly different peak-to-valley ratios. Sectors like education, e-commerce, and content recommendation may experience clear time-based and event-based traffic spikes. The specific peak-to-valley ratio should be determined based on your own historical QPS data, rather than blindly applying others’ empirical figures.
- Latency Sensitivity: Conversational and customer service applications are highly sensitive to Time-To-First-Token (TTFT) and overall response time. Evaluations should focus on P95 or P99 latency rather than just the average, because tail latency better reflects the real user experience during peak hours.
- VRAM and Compute Contention: During the generation (decode) phase, the computation per step is relatively small and is often limited by VRAM bandwidth, causing GPU compute power to idle. Long-context inputs can significantly increase KV Cache usage. If not managed properly, this can lead to Out of Memory (OOM) errors or a drop in concurrency.
3. Three Infrastructure Strategies
3.1 Elastic Scaling and GPU Partitioning
Facing fluctuating workloads, a fixed number of GPU instances usually causes two types of waste: queueing timeouts during peaks and resource idling during valleys. Elastic scaling can automatically adjust the number of replicas based on GPU utilization, queue length, or QPS, but the following conditions must be considered.
First, scaling up is not instantaneous. Loading model weights, starting containers, and warming up VRAM all take time. If each scale-up requires pulling large weights from a remote source, the cold start delay might exceed the duration of the traffic spike. A common practice is to cache model images in advance, retain a small number of warm standby replicas, and set the scaling threshold before reaching the capacity limit.
Second, GPU partitioning requires choosing the right method. NVIDIA MIG can partition supported GPUs into hardware-isolated instances with good isolation, but the partitioning specifications are fixed and only apply to specific models. Time-slicing allows multiple processes to share the same GPU, offering more flexible resource utilization, but performance interference between different services is harder to control, potentially impacting tail latency. When choosing, the business requirements for isolation and latency stability should be clarified first.
Third, burst traffic requires queueing and rate limiting. Request queues and traffic shaping can prevent instantaneous floods from crashing the service. The queue length threshold should be set based on acceptable wait times. When the threshold is exceeded, a clear degradation or queueing message should be returned to prevent requests from waiting indefinitely.
3.2 VRAM Management and Storage Tiering
KV Cache is one of the primary consumers of inference VRAM. It stores computed attention keys and values to avoid redundant calculations. Its management mainly occurs at the VRAM and memory levels, and multi-GPU inference also relies on high-speed interconnects to coordinate data exchange. Distributed storage is primarily used for model file and weight distribution, which is a different issue from the online read/write of KV Cache; the two should be considered separately.
PagedAttention allocates KV Cache in fixed-size blocks, reducing VRAM fragmentation and allowing more concurrent requests within the same VRAM. This method is particularly effective in scenarios with high concurrency and varied request lengths. However, it does not bring benefits under all conditions. When the number of requests is small or sequences are short, the scheduling overhead of block management might offset some of the gains, requiring empirical testing to confirm.
Prefix Caching is suitable for scenarios where multiple requests share the same system prompt or document prefix, such as customer service knowledge base Q&A. If the prefix repetition rate between requests is very low, the cache hit rate will also be low, yielding limited benefits. Real prefix hit rates should be analyzed before going live.
KV Cache quantization can reduce VRAM usage but introduces a certain loss of precision, which especially needs validation in long-text tasks. It is recommended to compare answer quality before and after quantization using an evaluation set similar to your business before deployment, and continuously monitor metrics like VRAM fragmentation rate, OOM occurrences, and cache hit rate.
For multi-node, multi-GPU inference, internode communication overhead affects latency. If a model needs to be partitioned across nodes, a high-bandwidth, low-latency interconnect network (such as InfiniBand or RoCE) helps reduce communication waiting. Whether the network has become a bottleneck should be judged by the proportion of communication time to total processing time.
3.3 Software-Hardware Co-design and Batching Optimization
Common measures at the inference engine level include operator fusion, model quantization, and dynamic batching. Operator fusion reduces kernel call counts and intermediate result read/writes. Quantization methods like INT8 and FP8 can reduce VRAM usage and increase throughput, but they require accompanying precision regression testing to ensure the output quality of critical tasks does not degrade significantly.
Continuous Batching merges the computation of different requests for execution, generally improving GPU utilization. However, the larger the batch, the longer an individual request might wait, causing tail latency to rise. The batch size should be determined based on the P95 or P99 latency target in the SLA, rather than solely pursuing maximum throughput.
Heterogeneous compute scheduling also requires clear constraints. Different models of accelerator cards may vary in VRAM capacity, compute power, and driver versions. Deploying the same model on different hardware can result in significant performance gaps. The scheduling strategy should record the hardware specifications suitable for each model type and complete compatibility verification before release.
Optimization effects should be compared under fixed conditions. Testing requires fixing the model version, quantization precision, batch size, input/output length distribution, and concurrency level, while simultaneously recording throughput, P95 latency, VRAM usage, and answer quality. Reporting the improvement of a single metric alone can easily lead to one-sided conclusions.
4. Pre-Deployment Checklist
- Build a cost model, estimating monthly expenses based on single token cost, replica count, and utilization rate, and regularly calibrate it against real bills.
- Collect historical QPS, request length distribution, and latency data to determine peak-to-valley ratios, rather than relying on empirical values.
- Set SLAs for each service category, including P95 latency, availability, and acceptable queue times, and use these to determine scaling thresholds and batch sizes.
- Conduct stress tests on target hardware, recording throughput, VRAM usage, and OOM conditions to clarify the applicable boundaries of each optimization measure.
- Perform regression evaluations on optimizations like quantization, caching, and batching to confirm that output quality meets business requirements.
5. Conclusion
Inference is the stage that most directly impacts user experience and operational costs after LLM training is completed. The role of infrastructure in this process is reflected across multiple levels: elastic resources, VRAM management, network interconnects, and inference engine optimization. All these measures need to be evaluated against specific models and business metrics; there are no universal parameters applicable to all scenarios. Teams should first establish a measurable metrics system, choose optimization paths based on test results, and gradually build controllable inference service capabilities.
