Systematic Approach and Practices for Identifying LLM Inference Performance Bottlenecks
This article explores common misconceptions in LLM inference performance optimization, such as relying solely on GPU utilization. It introduces a systematic methodology to define performance metrics and presents a seven-layer bottleneck analysis model covering hardware, kernel, memory, scheduling, parallelism, speculative decoding, and application layers. Additionally, it provides a practical decision path and a symptom-based troubleshooting table to help developers accurately locate and resolve inference performance issues.
1. Why High GPU Utilization Does Not Mean Good Inference Performance
One of the most common pitfalls in optimizing Large Language Model (LLM) inference performance is treating GPU utilization as the sole performance metric.
Monitoring dashboards might show GPU utilization exceeding 90%, yet the Time to First Token (TTFT) remains high, and generation speed sees no significant improvement. This happens because GPU utilization typically only indicates whether the device executed a task during a statistical cycle, without explaining:
- Whether compute units are continuously fully loaded;
- Whether matrix compute units are adequately utilized;
- Whether memory bandwidth has become a limiting factor;
- Whether there are significant gaps between kernel launches;
- Whether the GPU is waiting for CPU scheduling, data transfers, or communication;
- Whether the current task involves only a few threads due to an undersized batch.
Therefore, performance analysis must evolve from “is the device busy” to “which layer in the request path is waiting for what.”
A complete inference request typically goes through the following path:
Request intake-> Text processing and tokenization-> Request queuing-> Batch assembly-> Prefill phase-> KV Cache allocation-> Decode loop-> Multi-GPU communication-> Result post-processing-> Streaming response
Any blockage in this chain will affect the final latency or throughput. The correct optimization approach is not to tweak parameters blindly, but to establish observability first and then locate bottlenecks through controlled experiments.
2. Unify Performance Metrics and Problem Definitions First
Before starting the analysis, clarify what type of problem you are dealing with. Different goals correspond to entirely different bottlenecks.
2.1 Time to First Token (TTFT)
TTFT usually includes queuing, input processing, prefill computation, KV Cache establishment, and initial scheduling. It is primarily influenced by:
- Input context length;
- Request queuing time;
- Prefill batch size;
- Tokenization and protocol processing overhead;
- Whether compute resources are occupied by long requests;
- Whether the scheduler supports fine-grained splitting;
- Whether multi-GPU communication occurs on the critical path.
If TTFT is high but subsequent generation speed is normal, focus on request queuing, prefill, and scheduling, rather than blindly optimizing Decode kernels.
2.2 Per-Token Latency
Per-token latency refers to the average time required to generate each new token during the decode phase. It is typically related to:
- Decode phase batch size;
- KV Cache read volume;
- Attention implementation method;
- Memory bandwidth;
- Multi-GPU synchronization;
- Kernel launch count;
- Whether dynamic batching changes frequently.
High per-token latency often indicates that the Decode phase is affected by memory access, communication, or scheduling, rather than insufficient compute power.
2.3 Throughput
Throughput can be measured by request count, total token count, or output token count. Different definitions yield different conclusions. For example, increasing concurrency might boost total token throughput while simultaneously degrading individual request latency.
It is recommended to record at least the following metrics:
Input token throughputOutput token throughputTotal token throughputRequest throughputAverage latencyP50, P90, P99 latencyTime to First Token (TTFT)Per-token intervalQueuing timePrefill timeDecode time
Looking only at averages is insufficient. In online services, tail latency often reflects scheduling and resource contention issues better than average latency.
3. Establish a Seven-Layer Bottleneck Analysis Model
3.1 Hardware Layer: Confirm Device Suitability for the Workload
Hardware analysis should not look at utilization alone, but simultaneously monitor four types of metrics.
Compute Utilization
Observe whether both general compute units and matrix compute units are effectively utilized. If matrix unit utilization is very low while general unit utilization is high, potential issues include:
- Input dimensions not aligning with hardware requirements;
- Batch size too small;
- Operators not using efficient matrix paths;
- Data types not using low-precision formats suitable for inference;
- Computation fragmented by numerous small kernels.
Memory Bandwidth
The Decode phase typically repeatedly reads model weights and KV Cache. When compute unit utilization is low but memory bandwidth is near its limit, the problem is likely bandwidth-bound rather than compute-bound.
Increasing compute capacity will not improve performance here. Prioritize:
- Using lower-precision data representations;
- Reducing KV Cache footprint;
- Optimizing tensor layouts;
- Increasing effective batch size;
- Reducing unnecessary data transfers.
Memory Capacity and Fragmentation
Insufficient memory not only causes request failures but can also trigger frequent cache evictions, request preemption, batch size reduction, and performance jitter. Monitor:
- Allocated memory;
- Reserved memory;
- KV Cache usage rate;
- Number of free cache blocks;
- Cache eviction count;
- Proportion of long requests;
- Presence of fragmentation.
Host-Side Resources
The CPU does not “just receive requests.” Tokenization, scheduling, sequence management, communication preparation, and result processing can all consume CPU resources. If CPU threads are saturated, the GPU may experience intermittent idle periods.
Check:
- Scheduler thread CPU usage;
- Number of tokenization threads;
- Inter-process communication latency;
- Host-to-device data transfers;
- NUMA cross-node access;
- Overhead from network and logging threads.
3.2 Kernel Layer: Focus on Operator Gaps and Execution Fragmentation
The inference process consists of numerous kernels. Even if each kernel is fast, intervals between kernels can cause significant losses.
Watch for:
- Excessive number of kernels;
- Individual kernels with extremely short duration but frequent launches;
- Unfused similar operators;
- Excessive synchronization between attention, normalization, and activation operations;
- Frequent shape changes caused by different requests;
- Inability to reuse CUDA Graphs or similar graph execution mechanisms.
Attention Backend Selection
Attention computation is usually the core of inference performance. Different input lengths, batch sizes, data types, and hardware architectures suit different implementation paths.
Do not assume “one backend is always the fastest.” Benchmark:
- Prefill and Decode separately;
- Short context and long context separately;
- Small batch and large batch separately;
- Fixed length and dynamic length separately;
- Different data types separately.
Graph Execution and Compilation Optimization
Graph execution reduces repeated scheduling overhead but usually requires input shapes and execution paths to have some stability. If request lengths, batches, or branches change too frequently, you might encounter:
- Low graph cache hit rate;
- Frequent re-capturing;
- Compilation time shifting to online requests;
- Increased dynamic shape processing costs.
Therefore, the prerequisite for graph execution optimization is not “flipping a switch,” but confirming whether the business traffic has sufficient shape stability.
3.3 Memory Layer: KV Cache is the Core Resource
Three common KV Cache issues include insufficient capacity, low access efficiency, and eviction jitter.
Insufficient Capacity
As context length and concurrency rise simultaneously, KV Cache consumption grows rapidly. A rough formula to estimate single-request cache requirements:
KV Cache capacity≈ layers × sequence length × KV heads × head dimension × 2 × bytes per data type
The “2” represents Key and Value. Different model structures will adjust this formula, but this estimate is sufficient to identify the source of memory pressure.
Low Access Efficiency
KV Cache is not just about “fitting it in,” but also about read efficiency. If the layout is unsuitable for continuous access, the Decode phase may experience numerous non-coalesced accesses, degrading bandwidth utilization.
Focus on:
- Reasonableness of cache block size;
- Frequent sequence migration;
- Discrete access caused by different requests;
- Whether quantized cache layout matches compute kernels;
- Increased invalid reads due to mixing long and short requests.
Eviction Jitter
When cache space is tight, the system may frequently evict old requests, reallocate cache, or pause sequences. This causes noticeable tail latency.
Record:
Cache allocation failure countCache eviction countRequest preemption countRecomputation countCache hit rateCache growth curve per request
If these metrics degrade rapidly as concurrency rises, address memory management first instead of continuing to increase concurrency limits.
3.4 Scheduling Layer: CPU Scheduling Can Be an Invisible Bottleneck
Continuous batching improves GPU utilization but also increases scheduling complexity. The scheduler must handle within each iteration cycle:
- New request admission;
- Completed request exit;
- Sequence state updates;
- Token budget allocation;
- KV Cache allocation and release;
- Batch reassembly;
- Preemption and resumption;
- Multi-GPU task coordination.
If this work is done serially by a single Python thread or a single event loop, it can be impacted by interpreter locks, object management, and frequent memory allocations.
Typical symptoms include:
- Periodic gaps between GPU kernels;
- Throughput stagnation after concurrency increases;
- CPU usage nearing capacity;
- Sudden tail latency spikes as request volume increases;
- Frequent batch size changes.
During analysis, timestamp the request lifecycle to distinguish between “waiting for scheduling” and “waiting for GPU.” If requests spend a long time in the queue, optimizing operators won’t fix the problem.
3.5 Parallelism Layer: More Parallelism Isn’t Always Better
Common parallelism methods include tensor parallelism, pipeline parallelism, expert parallelism, and data parallelism. Choosing a strategy requires considering model size, memory capacity, communication topology, and request patterns.
Tensor Parallelism
Tensor parallelism splits a single layer’s computation across multiple devices but requires collective communication between or within layers. When per-token computation is small, communication overhead may dominate.
Pipeline Parallelism
Pipeline parallelism suits scenarios where the model is too large for a single GPU, but introduces inter-stage waiting and bubbles. In low-concurrency, short-request scenarios, pipeline efficiency may be low.
Expert Parallelism
Sparse expert models need to exchange tokens across devices. If network bandwidth, topology, or load balancing is insufficient, communication may become the primary bottleneck.
Data Parallelism
Data parallelism reduces per-request communication but requires higher concurrency to amortize replica costs. For low-traffic services, it may reduce resource utilization.
To determine if the parallelism strategy is reasonable, measure separately:
Compute timeCommunication timeSynchronization wait timeInter-device data transfer volumeLoad variance across devices
If some devices are clearly idle while others are continuously busy, the issue might not be insufficient total compute power, but load imbalance.
3.6 Speculative Decoding Layer: Gains Depend on Acceptance Rate
Speculative decoding uses a lighter model to propose multiple candidate tokens, which the target model then verifies, reducing the number of times the target model generates tokens sequentially.
It is not effective in all scenarios; gains depend on:
- Distribution similarity between draft and target models;
- Candidate token acceptance rate;
- Whether the verification batch is large enough;
- Compute overhead of the draft model itself;
- Request output length;
- Whether the scheduler can efficiently manage multi-token verification.
If the acceptance rate is low, the speculative process may add extra overhead. During evaluation, do not just look at final throughput; record:
Average candidate lengthAverage accepted lengthAcceptance rateDraft model latencyVerification latencyActual tokens produced per round
3.7 Application Layer: I/O Patterns Determine Underlying Performance
Many performance issues are not caused by the framework itself, but by business traffic patterns. For example:
- Extremely long input contexts;
- Highly unstable output lengths;
- A few ultra-long requests occupying large amounts of cache;
- Repeated prefixes carried in every request;
- Overly frequent streaming responses;
- Excessive logging and serialization overhead;
- Improper client connection management.
Therefore, performance testing must closely mimic real traffic, covering at least five patterns: short requests, long requests, mixed requests, burst concurrency, and stable high concurrency.
4. Decision Path from Symptoms to Tools
Troubleshoot in the following order:
Step 1: Confirm if the issue is Latency or Throughput
If TTFT is high, prioritize queuing, tokenization, prefill, and scheduling.
If per-token latency is high, prioritize decode, KV Cache, bandwidth, and communication.
If throughput is low, prioritize batch formation, compute utilization, memory bandwidth, and parallelism strategy.
Step 2: Review End-to-End Time Breakdown
Break down the request time into:
Intake timeQueuing timeInput processing timePrefill timeDecode timePost-processing timeTransfer time
Without a time breakdown, you cannot determine the optimization direction.
Step 3: Collect Device-Level Metrics
Observe compute units, matrix compute units, memory bandwidth, memory capacity, host CPU, and inter-device communication simultaneously. A single metric cannot explain a complex inference system.
Step 4: Capture Timelines
Use general GPU timeline analyzers and application-level tracing mechanisms to check:
- When CPU threads launch kernels;
- Whether the GPU has gaps;
- Whether there is synchronization between kernels;
- Whether communication blocks computation;
- Whether graph execution hits;
- Which operators consume the most time.
Step 5: Conduct Single-Variable Experiments
Change only one factor at a time, such as:
- Fixing input length;
- Fixing output length;
- Fixing concurrency;
- Disabling or enabling graph execution;
- Changing the attention implementation;
- Adjusting batch token budget;
- Changing cache capacity;
- Changing parallelism scale.
Record version, model, data type, hardware, input distribution, and results for each experiment to avoid drawing incorrect conclusions due to environmental changes.
5. Recommended Performance Analysis Table
| Symptom | Priority Check | Potential Causes |
|---|---|---|
| High TTFT | Queuing, Prefill, Input processing | Scheduling congestion, long context, unreasonable batch policy |
| Low per-token speed | Decode, KV Cache, Bandwidth | Memory-bound, inefficient cache access |
| High GPU utilization but low throughput | Timeline, Matrix units, Batch | Too many small kernels, low compute efficiency |
| Sudden latency spike after concurrency increase | Cache, Preemption, Scheduling | Insufficient memory, eviction jitter |
| Poor multi-GPU scaling benefits | Communication and synchronization | Parallelism granularity too fine, network bottleneck |
| Significant tail latency increase | Long requests, Scheduling, Cache | Unreasonable request mixing, resource contention |
| CPU busy but GPU idle | Scheduling, Tokenization, Communication | Excessive host-side serial overhead |
6. Conclusion: Inference Optimization is Essentially Systems Engineering
LLM inference performance is not determined by a single parameter, but by the combined effects of hardware, operators, memory, scheduling, parallelism, and business traffic.
A reliable optimization loop should be:
Define metrics-> Establish baseline-> Split request path-> Collect timelines and hardware metrics-> Locate dominant bottleneck-> Single-variable modification-> Regression validation-> Evaluate tail latency and stability
Note particularly that after framework version changes, schedulers, cache management, batching methods, and process architectures may all change. Past effective experiences may not apply to the current system, so a new baseline should be established after every upgrade.
Truly mature performance optimization is not immediately tweaking parameters upon seeing a high utilization number, but being able to answer three questions: What is the slowest part of the system right now? Why is it slow? Has the modification been verified through repeatable experiments? Only by connecting these three questions can we move from “feeling like performance is bad” to explainable, measurable, and sustainable inference optimization.
