Key Bottlenecks in LLM Inference Performance and Optimization Practices

    As large language models move from demos to production, inference—not training—has become the core of the compute race. This article explains what actually governs inference performance, why it differs from training, and how to tune for it. It covers the metrics that matter (throughput, TTFT, TPOT), the two distinct phases of inference (compute-bound prefill and memory-bandwidth-bound decode), and four hardware factors: memory capacity and bandwidth, precision formats, inter-chip interconnect (scale-up vs. scale-out), and rack-level architecture. It also offers guidance on reading performance benchmarks, proven software optimizations such as continuous batching, paged KV cache, quantization, parallelism strategies, and speculative decoding, plus scenario-based hardware selection and practical engineering advice for running inference on the cloud.

    1. Why Inference Performance Has Become Central to the Compute Race

    As large language models move from demos into production, the dominant workload is no longer a single question-answer exchange. It is online serving with high concurrency, long contexts, and stable latency. Compared with training, inference workloads are more fragmented and continuous, and they place very different demands on a system’s memory bandwidth, memory access efficiency, and response latency. Many teams run into the same confusion: on the same accelerator cards, training jobs fly, but the moment they go live for inference, throughput stalls and latency jitters. The reason is that what determines inference performance is not the same as what determines training performance.

    Understanding these factors helps you avoid “spec-sheet numbers that look great but never get fully used” when buying hardware, and it helps you make the right trade-offs at the software layer.

    2. First, Define Which Metrics Inference Performance Actually Means

    Before arguing about whether performance is “high” or “low,” you need a common unit of measurement. The industry generally tracks three metrics:

    • Throughput (Tokens/s): the total number of tokens the system can generate per unit of time; it sets the upper limit on concurrency the service can handle.
    • TTFT (Time To First Token): the time from when a request is issued to when the first token is emitted; it directly shapes the user’s sense of waiting.
    • TPOT (Time Per Output Token): the average time to produce each additional token during generation; it determines whether the “typewriter effect” feels smooth.

    One point deserves special attention: high single-card throughput does not necessarily mean a good end-to-end experience. Inference has two phases—prefill (processing the input; compute-intensive) and decode (generating token by token; memory-access-intensive)—and their bottlenecks are completely different. Prefill is hungry for compute; decode is hungry for bandwidth. Many optimizations work precisely because they target the specific bottleneck of one of these phases.

    3. The Four Hardware Factors That Determine Inference Performance

    3.1 Memory Capacity and Bandwidth: The First Bottleneck in Decode

    During decode, generating each token requires reading the model weights from memory in full almost every time. This means memory bandwidth directly determines the theoretical upper limit of decode speed. A simplified estimation model illustrates this relationship:

    1. def theoretical_decode_tokens_per_sec(model_bytes, mem_bandwidth_bps, batch_size=1):
    2. """
    3. Estimate the theoretical upper limit of single-request decode throughput.
    4. model_bytes: size of model weights in bytes
    5. mem_bandwidth_bps: memory bandwidth in bytes/second
    6. Assumes weights are read once in full; ignores KV cache read overhead.
    7. """
    8. tokens_per_sec = mem_bandwidth_bps / model_bytes
    9. return tokens_per_sec * batch_size

    For this reason, with a new generation of accelerators built around high-bandwidth memory (HBM), the bandwidth specification often deserves more attention than the raw compute number. Memory capacity, meanwhile, determines how large a model you can fit, how long a context you can support, and how large a batch you can run; together, the two set the ceiling on throughput.

    3.2 Compute Precision Formats: Balancing Accuracy and Efficiency

    Different precision formats serve different scenarios, and they form a clear, well-understood spectrum:

    • FP64/FP32 (double/single precision): aimed at scientific computing and high-fidelity simulation; indispensable for numerical stability, but costly per unit of compute.
    • TF32/FP16/BF16 (half precision and above): balance accuracy and efficiency, and serve as the main formats for large-model training and inference.
    • FP8/INT8 and lower-bit quantization: trade controlled accuracy loss for multiples of throughput and bandwidth savings—a key lever for reducing the cost of online inference.

    Which precision to choose depends on whether the task is “compute it accurately” or “run it fast.” Scientific computing needs hardware-level double-precision support, while conversational inference cares more about high throughput at low precision.

    3.3 Inter-Chip Interconnect Bandwidth: The Division of Labor Between Scale-Up and Scale-Out

    A single large model often will not fit on one card and requires multiple cards working together. There are two kinds of interconnect here:

    • Scale-up: high-speed interconnect among multiple cards within a single machine or rack, used for tensor parallelism and expert parallelism—scenarios where activations or intermediate results must be exchanged frequently during computation.
    • Scale-out: interconnect among nodes over standard networks, used for pipeline parallelism and distributed serving—scenarios that are relatively insensitive to latency.

    The more generous the scale-up bandwidth, the lower the share of communication overhead when you split work across cards, and the less likely large-scale tensor parallelism is to be bottlenecked by the interconnect.

    3.4 Rack-Level Architecture: Scheduling Many Cards as One Machine

    As model size and concurrency climb further, the system boundary expands from a “single machine” to an “entire rack.” Rack-level design uses large aggregate memory capacity, high aggregate bandwidth, and ultra-high intra-rack interconnect to combine dozens of accelerators into a single, logically massive compute unit. The value of this approach lies in reducing cross-rack communication, improving effective compute per watt, and providing a stable hardware foundation for large-scale parallel inference and training. When evaluating such solutions, focus on three things—aggregate memory capacity, aggregate bandwidth, and intra-rack interconnect bandwidth—rather than single-card specifications.

    4. How to Interpret Performance Benchmarks Scientifically

    The industry often refers to publicly available standardized inference benchmarks—a widely recognized class of general-purpose evaluation methods—that measure the end-to-end performance of different hardware and software stacks using the same model and the same workload. When reading such data, stick to three principles:

    1. Look at test conditions, not a single number: offline throughput, online concurrency, input/output lengths, and batch size all differ, and conclusions can vary dramatically as a result.
    2. Distinguish single-card from full-rack results: single-card data reflects component capability, while full-rack data reflects system-level coordination; the two cannot be compared directly.
    3. Beware the “best-case scenario” trap: vendor-quoted figures are usually peaks under a specific model, whereas production runs mixed workloads—benchmark against your actual business.

    5. Software-Layer Optimization: Making Hardware Deliver Its Performance

    Hardware only sets the ceiling; whether you can approach it depends on the software optimizations inside the inference engine. The following practices are widely accepted as best-in-class:

    5.1 Continuous Batching

    Traditional static batching requires all requests in a batch to start and finish at the same time, so short requests wait for long ones and the GPU sits idle. Continuous batching schedules dynamically at the token level: as soon as one request finishes, a new one is inserted immediately, significantly improving GPU utilization:

    1. # Continuous batching scheduler (pseudocode)
    2. def scheduler(running_queue, waiting_queue, max_batch_tokens):
    3. while True:
    4. batch = []
    5. token_budget = max_batch_tokens
    6. # Fill incrementally until the per-iteration token budget is reached
    7. for seq in list(running_queue):
    8. if token_budget <= 0:
    9. break
    10. batch.append(seq)
    11. token_budget -= seq.tokens_this_step
    12. # Move finished sequences out to free slots for new requests
    13. for seq in batch:
    14. if seq.is_finished():
    15. running_queue.remove(seq)
    16. for req in waiting_queue:
    17. if token_budget > 0 and len(batch) < MAX_BATCH_SIZE:
    18. seq = admit(req)
    19. running_queue.append(seq)
    20. batch.append(seq)
    21. token_budget -= seq.tokens_this_step
    22. yield step_forward(batch) # Run one forward pass

    5.2 Paged KV Cache Management

    In long-context inference, the KV cache consumes a large amount of memory, and its dynamically changing length easily causes memory fragmentation. Borrowing the idea of “paging” from operating systems, dividing the KV cache into fixed-size blocks allocated on demand can greatly reduce memory waste, thereby supporting larger batches and longer contexts under the same amount of memory.

    5.3 Quantization and Low-Precision Inference

    Quantizing weights from FP16 to INT8/FP8 reduces both memory footprint and memory-access overhead. Combined with a mixed-precision strategy for sensitive layers, this can multiply decode throughput with almost no loss in quality.

    5.4 Combining Parallelism Strategies

    Based on the model architecture and hardware topology, combine tensor parallelism (suitable for high-bandwidth intra-machine interconnect), pipeline parallelism (suitable across nodes), and expert parallelism (suitable for sparse MoE models), and align the parallelism partitioning with the available interconnect bandwidth so that communication does not become the bottleneck.

    5.5 Speculative Decoding

    Use a small “draft model” to quickly guess several candidate tokens, then have the large model verify them all in parallel in a single pass. This reduces the number of forward passes through the large model while keeping the output distribution unchanged, thereby lowering TPOT.

    6. Selecting by Scenario: There Is No Best Card, Only the Most Suitable One

    Hardware selection should return to the fundamentals of the business rather than blindly chasing the top of the range:

    • Online large-model inference: prioritize memory bandwidth, low-precision compute, and memory capacity, aiming for high throughput and low latency.
    • Scientific computing and sovereign-scale simulation: double-precision compute and numerical stability are decisive; hardware-level FP64 support is required.
    • Cost-sensitive large-scale deployment: with core compute, bandwidth, and interconnect capabilities held equal, choose the specification with a better cost-per-unit to control total cost of ownership.
    • Training and large-scale parallelism: focus on scale-up interconnect bandwidth and rack-level aggregate capability.

    7. Engineering Advice for Running in the Cloud

    Most enterprises do not need to build their own full-rack clusters when deploying inference; using general-purpose cloud compute resources is often more efficient. A robust engineering path looks like this:

    • Run inference services on a container platform to enable elastic scaling and rapid releases;
    • Use monitoring and alerting services to continuously collect throughput, latency, and GPU utilization, and establish an observable capacity baseline;
    • Host model weights and datasets in object storage, and use a logging service for request-level tracing;
    • Dynamically choose instance specifications and batch parameters based on benchmark results.

    Cloud providers such as Baidu AI Cloud typically offer the general cloud service categories above. Developers can build elastic, observable inference services on top of these general capabilities without being locked into a specific hardware form factor.

    8. Summary

    Inference performance is not determined by any single parameter. It is the combined product of memory bandwidth, precision format, interconnect bandwidth, and system-level architecture, multiplied by the effects of software optimizations such as continuous batching, KV cache management, quantization, and parallelism strategies. Only by understanding the distinct bottlenecks of the prefill and decode phases, sticking to scientific benchmark-interpretation principles, and selecting and tuning for your business scenario can you truly turn hardware specifications into usable online throughput and user experience. As the compute race grows ever more intense, building this methodology of “spot the bottleneck, tune effectively, select wisely” is more valuable in the long run than chasing a single peak number.