27B Open-Source LLM Inference Speed: Benchmarking and Optimization Guide

    This article explains why tokens/s figures for 27B-class open-source models are not directly comparable, reviews the memory-bandwidth bottleneck in autoregressive decoding and the mechanics of speculative decoding, and provides measured speed ranges, a structured benchmarking workflow, and engineering practices for quantization, context length, batching, and deployment.

    27B Open-Source LLM Inference Speed: Benchmarking and Optimization Guide

    “What generation speed are you getting in tokens/s?” This is one of the most frequently asked questions in self-hosted LLM communities. The question looks simple, but many variables affect the answer: GPU model, quantization precision, concurrency level, context length, sampling temperature, whether speculative decoding is enabled, and more. Change any one variable, and the final number can differ by several times. Using a 27B-class open-source model as an example, this article outlines a systematic approach to measuring inference speed, the factors that affect it, and optimization paths.

    1. Why There Is No Standard Answer to “How Many tokens/s?”

    Before discussing specific numbers, one point must be clear: speed figures are meaningless without the runtime configuration. The same 27B model can range from tens of tokens/s to hundreds of tokens/s during the decode phase under different conditions. The main factors include:

    • Hardware environment: Consumer flagship GPUs, professional inference cards, and data center accelerators differ greatly in memory bandwidth. The decode phase with a small batch is a typical memory-bandwidth-bound scenario.
    • Quantization precision: BF16, FP8, INT4/NVFP4, and other precisions change the amount of weight data read by a factor. For a 27B model, BF16 weights are about 54 GB, while 4-bit quantization can compress them to around 15 GB, making the model fit on a single GPU and greatly reducing bandwidth pressure.
    • Context length: KV cache grows linearly with context. With long contexts, the read overhead of attention at each step rises significantly, and decode speed continues to decline as the conversation gets longer.
    • Decoding strategy: Whether speculative decoding is enabled, along with the quality and acceptance rate of the draft model, directly determines how many tokens can be advanced per forward pass.

    Therefore, a well-formed speed question should include at least: hardware environment, software stack and inference framework, loading configuration (context length, quantization method, whether speculative decoding is enabled, etc.), test workload type (short requests, long context, concurrency level), and finally the speed number.

    2. The Bottleneck of Autoregressive Decoding and the Principle of Speculative Decoding

    2.1 Why AR Decoding Is Slow

    Standard autoregressive (AR) decoding produces only one token per forward pass. With a small batch, the GPU must read the full model weights at every step, but the amount of computation is far from enough to saturate compute capacity. The whole process is limited by the “memory wall.” This is the fundamental reason why generation speed for large models is generally low in single-user scenarios.

    2.2 How Speculative Decoding Saves Time

    The core idea of speculative decoding is to “guess with a small model and verify with a large model”:

    1. A lightweight draft model (or a drafter built from some layers of the main model) quickly generates a sequence of candidate tokens.
    2. The target model verifies the entire candidate sequence through one parallel forward pass.
    3. It keeps the continuously accepted prefix from the beginning, samples a corrected token according to the rules at the first rejected position, and discards all draft tokens after that point.

    As long as the verification rules are designed correctly, the output distribution of speculative decoding is exactly the same as that of the original model, making it “lossless acceleration.” What is saved is the target-model forward overhead that would otherwise require multiple token-by-token executions.

    2.3 The Key Formula for Gains

    Let τ denote the average number of tokens ultimately advanced per round (including the token emitted during verification). Then the time per decode round can be approximated as:

    1. T_round ≈ T_draft + T_verify + T_other
    2. Average speed ≈ τ / T_round

    This formula reveals a fact that is often overlooked: a high acceptance rate is only one condition; the draft and verification themselves must also be cheap enough. Public experimental data shows that in some parallel draft schemes, the verification stage accounts for more than 70% of the time per round. In other words, even if drafting were completely free, the speedup would still have a theoretical ceiling. Optimization therefore falls into two directions: first, increase the average acceptance length τ (for example, by improving the drafter structure and establishing token dependencies layer by layer along network depth); second, reduce verification cost (for example, through more efficient KV management and batch scheduling).

    3. Measured Reference: Typical Speed Ranges for a 27B Model

    Based on publicly available third-party tests and community re-tests, running a 27B-class model on a single new-generation professional inference card gives the following order-of-magnitude reference points:

    • BF16 precision + speculative decoding: For long-context encoding tasks, decode speed can reach about 4x that of the same setup without speculative decoding.
    • 4-bit mixed quantization + speculative decoding: Decode speed for short code-generation requests can approach 470 tokens/s.
    • Ultra-long context (~100k), single-round continuation: Multi-request aggregate throughput is about 160 tokens/s, roughly 3x that of pure AR decoding.

    Note the large gap between the second and third groups: as context grows from a few hundred tokens to the 100k level, KV cache reads expand sharply, and decode speed can drop to one third of that for short requests. For scenarios such as code agents, where input keeps getting longer and output is not always regular code, peak speed on short requests has limited reference value. Steady-state throughput under long context is what really determines the user experience.

    4. How to Benchmark and Evaluate Scientifically

    Developers should run benchmarks in their own environments using the following process:

    1. Fix variables: Specify the hardware, driver, inference framework version, quantization method, and maximum context configuration.
    2. Test in layers: Measure three workload groups separately: short requests (<2k context), medium requests (8k–32k), and long context (64k and above).
    3. Record metrics: In addition to decode tokens/s, record TTFT (time to first token), average acceptance length τ, and memory usage.
    4. Compare against a baseline: Use pure AR decoding as the baseline, calculate the actual speedup from speculative decoding, and observe how the acceptance rate changes with output content type (regular code vs. natural language).
    5. Stress test concurrency: High single-user speed does not mean high serving throughput. Gradually increase concurrency and observe the inflection point in the throughput curve.

    5. Practical Engineering Recommendations

    For teams that want to use 27B-class models in production, several practical lessons are worth considering:

    • Prioritize quantization: When accuracy loss is acceptable, prefer 4-bit quantization to leave more VRAM headroom for longer KV caches.
    • Enable speculative decoding as needed: The speedup is most significant for short requests. With larger batches, verification cost takes a larger share, so measure whether there is still a gain.
    • Pay attention to the framework ecosystem: Mainstream inference frameworks differ in their support for speculative decoding, paged KV cache, and continuous batching. Choose based on actual tests.
    • Use elastic cloud resources wisely: If the cost of self-managed hardware is too high, GPU compute and model inference services from cloud platforms can support elastic deployment. For example, platforms such as Baidu AI Cloud provide compute and model service capabilities that can be used to quickly validate the performance of models of different sizes under realistic workloads before deciding on a long-term deployment plan.

    Conclusion

    The real value of the question “how many tokens/s?” is not the number itself, but the way it forces us to systematically analyze variables such as hardware, quantization, context length, and decoding strategy. With new-generation hardware and speculative decoding, a 27B-class model can reach hundreds of tokens/s for short single-user requests, but long-context scenarios remain the throughput bottleneck. Every self-hosting developer should establish their own standard benchmarking methodology and drive optimization decisions with data rather than intuition.