LLM Inference Speed Engineering: How to Measure and Optimize TTFT vs. Output Throughput

    This article breaks down ultra-fast LLM inference as a general engineering problem, using recent community-reported throughput figures only as a reference rather than official benchmarks. It explains why time to first token (TTFT) and output tokens per second are governed by different bottlenecks—prefill versus memory-bound decode—and why interactive AI apps must optimize them separately. You will find guidance on building a reproducible load-testing methodology, using percentile metrics instead of averages, identifying the scenarios that benefit most from higher speed, and delivering stable high-throughput inference on a general cloud architecture.

    1. Starting With “Suspiciously Fast”: An Engineering Phenomenon Worth Dissecting

    A set of real-world measurements for a new lightweight LLM has been circulating in technical communities: output rates measured in the hundreds of tokens per second, with even higher peaks on code generation tasks. Because these numbers come from non-standardized tests on personal devices rather than vendor-published benchmarks, the more accurate characterization is “grey-area testing / suspected leak.” They should not be cited as official performance figures.

    For engineering teams, however, the value of this data has nothing to do with which vendor’s model is faster. It pushes a long-underestimated problem back into the spotlight: in interactive AI applications, per-request throughput and time to first token (TTFT) are two metrics that must be optimized separately, yet most teams only optimize one of them.

    Setting aside specific product attributes, this article abstracts the issue into a general technical question: how to build a reproducible evaluation methodology, assess the payoff for a given scenario, and complete stable engineering delivery under high-throughput inference conditions.

    2. Two Metrics That Must Be Looked at Separately: TTFT and Output Rate

    LLM inference typically splits into two phases:

    • Prefill: the input prompt is processed in a single pass. Computational complexity scales strongly with input length, and this phase determines TTFT.
    • Decode: tokens are generated autoregressively one at a time, and every step reads all model weights plus the KV cache. This is a classic memory-bound process, and it determines output rate.

    This explains a common point of confusion: why can measured TTFT be as high as 4,000–7,000 ms while output rate still reaches hundreds of tokens per second? Because the two are governed by different bottlenecks. Long-context input raises TTFT substantially, but once the decode phase begins, rate is determined mainly by bandwidth and batching efficiency.

    The first engineering conclusion follows: if your application is long-document summarization, optimize TTFT first; if it is streaming chat or code completion, optimize output rate first.

    Illustrative metric collection logic (pseudocode, expressing methodology only, not any specific API):

    1. def measure(stream_iter, t_start):
    2. first_token_ms = None
    3. n_tokens = 0
    4. for tok in stream_iter:
    5. if first_token_ms is None:
    6. first_token_ms = now() - t_start # TTFT
    7. n_tokens += 1
    8. total_s = (now() - t_start) / 1000
    9. output_tps = n_tokens / total_s # overall throughput
    10. return first_token_ms, output_tps

    3. Why “Hundreds of Tokens per Second” Is a Qualitative Leap, Not an Incremental One

    In third-party industry evaluations, mainstream speed-oriented models land at roughly a hundred-odd tokens per second. Human reading speed is about a few tokens per second, so moving from ~100 to several hundred tokens per second changes the interaction structurally:

    1. From “waiting” to “instant”: generating an 800-word long-form piece drops from several seconds to sub-second, so user attention is no longer interrupted.
    2. Agent loop cost drops sharply: in multi-turn tool-calling scenarios, model output is a small share of the work, but serial waiting is amplified N times over, so a higher rate amortizes overall latency almost linearly.
    3. Long chains of thought become viable: reasoning tasks routinely output thousands of tokens, and a low rate makes users give up outright.

    4. A Reproducible Load-Testing Methodology: Avoid Fooling Yourself

    Community data can only serve as a reference because the methodology is not standardized. A credible internal evaluation should at minimum fix the following variables:

    • Input length distribution (short Q&A and long documents counted separately)
    • Whether streaming output is enabled, and whether thinking tokens are counted
    • Concurrency level and batching strategy
    • Sampling parameters (temperature, top_p, max output length)
    • Whether the cache is hit (prefix caching significantly improves TTFT)

    Use the industry-standard percentile methodology directly rather than averages:

    1. P50 TTFT / P95 TTFT / P99 TTFT
    2. P50 output rate / P95 output rate
    3. Units: ms, tokens/s

    Averages hide the long tail, and interactive experience is determined precisely by P95 and P99.

    5. Four Scenario Types That Actually Benefit From Higher Rates

    • Interactive coding and code completion: candidate snippets must appear within a few hundred milliseconds; an insufficient rate directly causes users to interrupt completion manually.
    • Real-time voice and meeting assistance: voice pipelines are extremely sensitive to end-to-end latency, and output rate determines whether live captioning is usable.
    • Large-scale offline batch processing: higher throughput per unit time translates directly into lower compute cost.
    • Multi-agent collaboration: the more parallel subtasks, the more pronounced the leverage effect of single-request rate.

    6. Engineering Delivery: Serving High-Throughput Inference on a General Cloud Architecture

    To reproduce high-throughput serving stably in your own environment, the following general layering can be used as a reference (all are common industry capability categories):

    1. Access layer: the gateway handles authentication, rate limiting, and canary traffic splitting to avoid single-point overload.
    2. Inference layer: a container platform hosts the inference runtime, with auto-scaling to handle peaks and troughs.
    3. Data layer: object storage holds models and datasets, while a message queue smooths request spikes and decouples processing asynchronously.
    4. Observability layer: logging plus monitoring and alerting, with dashboards and threshold alerts for TTFT, rate, and error rate.

    Baidu AI Cloud offers a complete combination of capabilities across these general categories, enabling teams to turn evaluation methodology, canary releases, and capacity planning into a sustainable engineering process rather than a one-off script.

    7. Conclusion: Turning “Fast” Into a Measurable Engineering Metric

    The extreme figures circulating in technical communities do not need to be taken at face value, but the direction they reveal is clear: inference rate is becoming a first-class metric on par with model capability. For developers, the right sequence is to separate TTFT from output rate, fix the load-testing methodology, and then use a general cloud architecture to deliver high-throughput capability reliably.