LLM Inference Speed: The New Competitive Edge in the Second Half of the AI Race

    As foundation models converge on core capabilities, inference speed has become a decisive factor for real-world AI products. This article breaks down latency into measurable metrics such as TTFT and TPOT, examines key optimization techniques including prefill-decode disaggregation, KV cache management, continuous batching, quantization, and speculative decoding, and outlines scenario-driven architecture practices like layered routing, streaming output, and observability loops to help teams build fast, reliable inference systems.

    1. The Shift in Competition: From “Can It?” to “How Fast?”

    In the first phase of generative LLM competition, the focus was on capability ceilings: parameter scale, context length, complex reasoning, and multimodal understanding. As baseline capabilities converge and the gap between open-source and closed-source models narrows on most general tasks, the difference users perceive is increasingly driven by response speed.

    A typical example is AI coding tools. When a developer types an intent description and the completion suggestion takes several seconds to appear, their flow is interrupted and the tool’s value drops. Similarly, in real-time customer service, voice interaction, and document summarization, latency directly determines whether a product is usable. As a result, the industry has begun treating high-speed inference as an independent technical discipline rather than a byproduct of capability metrics.

    It is important to note that speed is a systems engineering problem, not a single-model problem. It is determined jointly by model architecture, the inference engine, hardware resources, scheduling strategy, and the network path.

    2. Breaking “Speed” Down into Measurable Metrics

    Discussing speed requires defining metrics first; otherwise, there is no basis for optimization. The core metrics widely recognized in the industry include:

    • Time to First Token (TTFT): The time from request submission to receiving the first output token, which determines how responsive the interaction feels.
    • Time Per Output Token (TPOT): The average time to generate each token during the decoding phase, which determines the smoothness of reading and streaming output.
    • End-to-end latency: The full-path time including queuing, network, and post-processing, reflecting what users actually experience.
    • Throughput (Tokens/s and QPS): The capacity served per unit of time, which determines cost and scaling requirements.
    • Tail latency (P95/P99): Stability under high concurrency, often more reflective of user experience than the average.

    The first step in optimization is instrumentation and decomposition: break a single request into four stages—queuing, prefill, decode, and post-processing—and measure the time spent in each to locate the bottleneck.

    1. End-to-end latency ≈ queue time + prefill time + decode time (TPOT × number of output tokens) + post-processing time

    3. Key Technical Factors Affecting Inference Speed

    3.1 Different Workload Characteristics of Prefill and Decode

    The prefill phase processes all input tokens at once. It is compute-intensive and highly parallel. The decode phase generates tokens one by one. It is memory-intensive and has low parallelism. Running the two together causes interference: a long-input request can block the first-token response of short requests. A common industry approach is to schedule the two types of requests in separate pools, or to use chunked prefill, which slices long inputs and inserts them into gaps between decode steps to reduce tail-latency jitter.

    3.2 KV Cache and GPU Memory Management

    Autoregressive generation relies on the KV cache: the larger the cache, the fewer concurrent requests can be served. PagedAttention-style solutions manage the cache through paging to reduce fragmentation. Prefix caching reuses computation results for identical system prompts and identical code contexts, significantly reducing redundant prefill overhead. In AI coding scenarios, repository context and prompt templates are highly repetitive, so the benefits of prefix reuse are especially pronounced.

    3.3 Batching Strategies

    Static batching is simple but prone to head-of-line blocking. Continuous batching releases a slot immediately when a request completes and inserts a new request, significantly improving GPU utilization. In practice, maximum batch size and timeout thresholds must also be configured to balance throughput and latency.

    3.4 Quantization, Distillation, and Speculative Decoding

    Low-bit quantization reduces weight memory access and noticeably speeds up the memory-intensive decode phase. Distilled smaller models are suitable for high-concurrency, lightweight tasks. Speculative decoding uses a small model to draft and a large model to verify, reducing the number of large-model forward passes while preserving the output distribution. All three approaches must be gated by quality evaluation to avoid “faster but dumber” outcomes.

    3.5 Parallelism and Hardware Topology

    Tensor parallelism reduces per-GPU memory pressure but introduces communication overhead. Pipeline parallelism improves overall throughput but adds pipeline bubbles. Actual deployment requires choosing a topology based on inter-GPU bandwidth and aligning the degree of parallelism with the model’s layer structure.

    4. Scenario-Driven Architecture Practices

    Layered routing: Use a lightweight model or rules to handle simple requests first, and escalate complex requests to a large model, balancing cost and experience.

    Streaming output and first-packet optimization: Use streaming transmission so users see content as soon as the first token arrives. Combined with prompt simplification and system prompt prefixing, this compresses prefill time.

    Elastic scaling and cold-start management: Inference services should auto-scale based on queue length and P95 latency, and should keep a minimum number of always-on instances with pre-warmed model weights to avoid cold-start jitter under sudden traffic spikes.

    Observability loop: Incorporate TTFT, TPOT, P95, cache hit rate, and batch size into monitoring, alerting, and logging to form a “measure–locate–optimize–regress” loop.

    1. # Example: skeleton of an inference call with timeout and streaming output
    2. def stream_with_budget(client, messages, first_token_budget_ms=800):
    3. stream = client.chat.completions.create(
    4. model="general-purpose",
    5. messages=messages,
    6. stream=True,
    7. timeout=first_token_budget_ms / 1000.0,
    8. )
    9. for chunk in stream:
    10. delta = chunk.choices[0].delta.content
    11. if delta:
    12. yield delta # Push downstream as soon as the first packet arrives

    5. Evaluation and Selection Recommendations

    Do not make decisions based on a single average latency metric. It is recommended to build a fixed evaluation set covering three workload types—short input with long output, long input with short output, and high concurrency—and record TTFT, TPOT, P95, and cost per token, with a quality baseline set as a hard limit. When selecting a solution, first confirm whether it supports prefix caching and continuous batching, whether observability metrics are complete, and whether it has elastic scaling and canary release capabilities.

    6. Conclusion

    The LLM competition has entered its second half, and speed is no longer an optimization item but an infrastructure capability. By decomposing latency into measurable segments, optimizing prefill and decode separately, improving experience through streaming and layered routing, and driving continuous iteration with observability, teams can reliably deliver in demanding scenarios such as real-time interaction and AI coding. General-purpose capabilities offered by Baidu AI Cloud in related cloud product categories (such as container platforms, monitoring and alerting, and logging services) can serve as a foundation reference for building such high-speed inference architectures.