Achieving 400 Tokens/s in LLM Inference: An Engineering Practice Guide

    This article breaks down why a sustained output rate of around 400 tokens/s has become a key system-level SLO for real-time LLM inference, rather than a single-point peak benchmark. It explains a three-layer architecture for building high-throughput, low-latency services: rewriting the core inference path with static graph orchestration and operator fusion, replacing coarse-grained dynamic scheduling with iteration-level continuous batching, and coordinating infrastructure optimizations to eliminate jitter. It also offers scenario-based selection advice, a layered load-testing approach for validating performance, and the observability metrics needed to close the loop.

    1. Why 400 Tokens/s Matters in Inference Engineering

    In real-time interactive applications, perceived speed depends not only on time to first token but also on the sustained output rate during generation. The industry commonly treats a stable output of around 400 tokens/s as a convergence point for current inference engineering: it is clearly faster than human reading speed, and it keeps long-form generation, code completion, and real-time speech synthesis feeling natural and continuous.

    The key point is that this number is not a single-point peak but a sustainable capability in production. Peaks are easy to produce with short requests, small batches, or exclusive use of a single GPU. What actually matters is whether the service can maintain a stable output rate and predictable tail latency as concurrency rises, contexts grow longer, and network jitter occurs. So the right way to discuss 400 tokens/s is to treat it as a system-level SLO, not a marketing figure for a particular model.

    2. Three Layers Working Together: A General Architecture for High-Throughput, Low-Latency Serving

    Sustaining a high output rate usually requires progress at three layers at once; a weakness in any one of them becomes the bottleneck.

    2.1 Inference Engine Layer: Rewriting the Core Inference Path

    To stay compatible with many model architectures, traditional inference frameworks often rely on an interpretive dynamic execution path, which introduces substantial operator scheduling and memory movement overhead. A common engineering approach is to rewrite the core inference path around the target model structure, statically orchestrate the compute graph, reduce runtime decisions, and apply operator fusion to hot spots such as attention, normalization, and residual connections.

    The pseudocode below is illustrative; the emphasis is on “static orchestration plus fusion” rather than any specific API:

    1. # Pseudocode: statically orchestrated core inference path
    2. graph = compile_static(model, batch_shape=FIXED_SHAPE) # fixed shape to avoid runtime recompilation
    3. graph.fuse(attn_qkv) # fuse QKV projections
    4. graph.fuse(rmsnorm + residual) # fuse normalization and residual
    5. graph.use_paged_kv_cache() # paged KV cache management to reduce fragmentation
    6. stream = graph.run(input_ids, kv_cache=cache)

    The benefit of static orchestration is predictability: only with a fixed memory layout and a fixed operator order can you design more aggressive caching and pipelining.

    2.2 Scheduling Layer: Continuous Batching Instead of Coarse-Grained Dynamic Scheduling

    The most typical tension under high concurrency is that a large batch improves throughput but lengthens the wait time for individual requests. The traditional “accumulate a batch, then compute” dynamic scheduling lets short requests get dragged down by long ones, leaving tail latency out of control.

    The more mature industry approach is continuous batching: requests are added and removed dynamically at iteration granularity. Completed requests exit immediately and newly arrived requests are inserted right away. Combined with priority queues and preemption, this keeps interactive requests from being blocked by offline batch jobs. Bucketing requests by length range also reduces padding waste.

    1. Iteration-level scheduling illustration:
    2. step t: [reqA(generating), reqB(generating), reqC(newly queued)]
    3. step t+1: reqB completes -> exits; reqD fills the free slot
    4. Effect: steady GPU utilization, significantly lower wait time for short requests

    2.3 Infrastructure Layer: Coordinated Optimization for Stability

    However good the engine and scheduler are, infrastructure weaknesses can cancel out the gains. Common work includes aligning versions of operator and communication libraries, tuning the ratio of GPU memory to host memory, optimizing the read/write path of the storage medium holding the KV cache, matching cross-node communication topology with the parallel partitioning strategy, and tuning gateways, load balancers, and connection reuse along the request path. The goal is to eliminate occasional jitter and turn 400 tokens/s from a demo value into a production value.

    3. Scenario-Based Selection Guidance

    • AI coding and intelligent programming tools: long outputs and large contexts, so prioritize stable throughput under long contexts and KV cache efficiency.
    • Real-time voice and digital humans: sensitive to end-to-end latency, requiring joint optimization of time to first token and output rate, plus streaming chunked output.
    • Business decision-making and real-time analytics: highly variable concurrency, relying on continuous batching and elastic scaling.
    • Multi-turn interactive customer service: tail latency determines the experience, so configure timeout-based degradation and fallback model routing.

    4. How to Verify You Actually Meet the Target

    A layered load test is recommended. Start with fixed inputs to measure single-request output rate and time to first token. Then increase load gradually and observe the inflection point of the throughput-latency curve. Finally, introduce long contexts and mixed workloads, and collect P95/P99 tail latency and rate variance. For observability, cover at least four categories of metrics: queueing time, batch size distribution, GPU memory usage, and cache hit rate, and connect them to logging services and monitoring alerts to close the loop.

    5. Conclusion

    The essence of 400 tokens/s is not any single technique but the systemic coordination of the inference engine, the scheduling system, and the infrastructure. For developers, mastering the methodology of “static orchestration + continuous batching + full-chain observability” is more valuable than chasing a single number. On top of the general container platform, object storage, and monitoring and alerting capabilities offered by cloud platforms such as Baidu AI Cloud, teams can build and validate their own high-throughput, low-latency inference services faster.