LLM Inference and AI Infrastructure: Why Serving Matters More Than Training

    This article explains why LLM inference, not training, is the real production bottleneck and how AI infrastructure must be designed around it. It covers the cost shift from one-time training to continuous inference spend, user-facing latency metrics such as TTFT and TPOT, the dynamic workloads that inference must handle, and key techniques including continuous batching, paged KV cache, prefix reuse, KV cache quantization, and elastic capacity planning. It also outlines a practical optimization order and explains how Baidu AI Cloud can serve as a supporting platform.

    1. The Misread Barrier: The Real Test Starts After Training

    Moving a large model into production often runs into the same awkward situation: the metrics look great and the demo is impressive, but the moment real traffic arrives, things fall apart. Latency spikes at peak hours, the daily compute bill blows past budget, and concurrency triggers queues and timeouts. The result is a model that is impressive to look at but too expensive to actually use.

    The root cause is not model accuracy. It is the infrastructure. Training answers whether a model can be built; inference answers whether that model can be served reliably, cheaply, and continuously. Training is a one-time engineering effort. Inference is a long-term operational commitment.

    2. Cost Structure: One-Time Investment vs. Continuous Burn

    Training spending looks like a pulse on the timeline: data preparation, cluster occupancy, and repeated tuning. Once the run finishes, the cost is fixed and does not grow with usage.

    Inference spending is a continuous stream. Every request and every output token consumes compute and GPU memory in real time, so cost grows linearly—or even super-linearly—with call volume. A distribution commonly observed in the industry is that over a lifecycle of roughly one year, inference accounts for about 70%–90% of total cost, while training accounts for only 10%–30%. A leading lab reportedly spent tens of millions of dollars to train a model with hundreds of billions of parameters, while post-launch daily inference costs can reach millions of dollars—enough to match the entire training investment in less than a month.

    The conclusion is straightforward: optimizing training saves money once; optimizing inference saves money every day. This is why investment in AI infrastructure is shifting from “stacking more training clusters” to “building an efficient inference foundation.”

    3. User Experience Is a Hard Constraint: Latency Maps Directly to Retention

    Inference is the only stage that faces end users directly, so its performance is perceived immediately. Common rules of thumb: in customer service scenarios, a peak-hour response above 300 ms noticeably reduces conversion; on mobile, a local conversational response above 1 second causes a sharp drop in retention.

    Two frequently confused metrics need to be separated:

    • Time to first token (TTFT): determines whether the experience feels responsive. It is affected by input length, queue wait time, and prefill efficiency.
    • Time per output token (TPOT) and total completion time: determine whether the output reads smoothly. They are affected by decode-phase bandwidth and batching strategy.

    Optimizing only one of these often makes the other worse. That trade-off is exactly what makes inference engineering more complex than training.

    4. Training and Inference Optimize Different Objectives

    Training pursues the upper bound of accuracy and can tolerate high compute consumption and long runtimes: a thousand-GPU cluster running for weeks, offline data processing, and no concurrent requests. As long as the final metrics are met, the result can be reused by every subsequent inference call.

    Inference pursues a three-way balance among efficiency, cost, and stability, and it must handle three kinds of dynamism that do not exist during training:

    1. Request dynamism: input length distributions have long tails and arrivals are bursty, so they cannot be pre-scheduled offline.
    2. Resource dynamism: GPU memory, bandwidth, and compute compete with one another, and members within a batch affect each other’s latency.
    3. Traffic dynamism: day/night cycles and event-driven peaks fluctuate heavily, so fixed capacity is either wasted or overloaded.

    5. Three Inference Challenges and How Infrastructure Responds

    5.1 Throughput vs. Latency: Continuous Batching and Paged Memory

    Static batching makes short requests wait for long ones and amplifies the long tail. The common industry approach is continuous batching (dynamically swapping requests in and out at the decode-step level) combined with paged KV cache management to reduce memory fragmentation, plus chunked prefill to keep long inputs from blocking decode. A sketch of the logic:

    1. # Pseudocode: continuous batching scheduler skeleton
    2. while engine.running:
    3. batch = scheduler.pop_ready() # dynamically admit new requests
    4. logits = model.forward(batch) # one forward pass serves many requests
    5. for req, token in zip(batch, logits):
    6. if req.finished():
    7. scheduler.evict(req) # free KV pages as soon as done
    8. kv_pool.free(req.pages)
    9. else:
    10. kv_pool.append(req, token)
    11. metrics.observe(ttft=req.first_delay, tpot=req.step_delay)

    5.2 The Memory Wall: KV Cache Is the Main Consumer

    In long-context scenarios, the KV cache often exceeds the weights themselves. Combinable techniques include KV cache quantization, cross-request prefix reuse (system prompts, templates, and few-shot examples sharing one cache), sensible partitioning across tensor and pipeline parallelism, and speculative decoding that uses a small draft model to cut decode steps. In engineering, measure first and then choose—avoid paying complexity costs for bottlenecks that do not exist.

    5.3 Stability and Elasticity: Capacity Planning Must Target Peaks

    Inference services need multi-level buffering and graceful degradation: rate limiting and priority queues at the ingress layer, message queues to smooth spikes for asynchronous jobs, stateless replicas on a container platform that auto-scale by metrics, cold data and model files pulled on demand from object storage, and logging plus monitoring with alerts to locate long-tail requests across the full path. Multi-replica canary releases and fast rollback are the baseline for controlling change risk.

    6. A Practical Optimization Order

    1. Build observability first: collect TTFT, TPOT, queue length, memory usage, and cache hit rate. No measurement, no optimization.
    2. Then govern requests: assign priority and timeout budgets per business, and deploy long-text and short-QA workloads in separate pools.
    3. Then tune batching and caching: enable continuous batching, prefix reuse, and KV quantization.
    4. Finally add elasticity and cost tiers: small models as fallback, escalation to large models when needed, and scale-down during idle periods.

    The general capabilities that Baidu AI Cloud provides for model serving and containerized deployment can act as the foundation for the approaches above; specific parameters and quotas should be validated against your actual environment.

    7. Conclusion

    Training sets the model’s ceiling; inference sets the business’s floor. Design infrastructure with inference as a first-class citizen—measurable, elastic, and degradable—and a large model truly moves from demo to production.