Four Key Levers to Speed Up Single-Stream LLM Inference
This article examines four practical levers for accelerating single-stream inference of a 27-billion-parameter dense LLM with a 262,144-token context on a desktop-class accelerator. It separates first-token latency from decode throughput, then shows measured gains from speculative decoding, deeper draft models, 4-bit quantization, and prefix caching, along with why quantization offers little benefit under concurrency. A bottleneck-first tuning methodology is included.
1. Background: Why “It Runs” and “It Runs Fast” Are Different Problems
A desktop-class accelerator has far less memory capacity and bandwidth than a data-center training cluster, yet it is expected to serve a 27-billion-parameter dense model with the context length stretched to around 262,144 tokens. Under this configuration, loading the model and getting results out is not the hard part. The real challenge is decode speed.
Two metrics that are often confused need to be separated first:
- Time to first token (TTFT): Determined by the prefill stage. It is compute-intensive and mainly affected by compute capacity and batching strategy.
- Single-stream decode speed (tok/s): Determined by token-by-token autoregressive generation. It is memory-intensive and mainly affected by memory bandwidth and the number of bytes moved per step.
With weights at the original precision (8-bit float), measured single-stream throughput was only about 7.88 tok/s. That number is not unusual: every generated token requires reading all weights from memory into the compute units once, which makes bandwidth the hard ceiling and leaves compute largely idle. The core optimization idea, therefore, is not to add compute but to reduce effective memory traffic and idle waiting per step.
2. Lever 1: Speculative Decoding, Replacing Serial Waiting with Parallel Verification
The basic structure of speculative decoding is that a lightweight draft model proposes several candidate tokens in a row, and the target model verifies them all in a single parallel pass, accepting the longest matching prefix. Its mathematical property is critical: the output distribution is identical to that of the target model. It changes only the computation path, not the result, so it is not a precision-for-speed trade-off.
The measured gain is clear: throughput rose from 7.88 tok/s to 46.8 tok/s, roughly 6x. The reason is that N serial small matrix-vector multiplications are compressed into a single batched “1+N” forward pass, converting idle compute into throughput.
Three engineering points matter:
- A longer draft is not always better; wrong guesses waste compute.
- The sampling method (probabilistic sampling or greedy) must match the target model’s decoding strategy.
- The draft model and the target model must have strictly aligned vocabularies and tokenizers, otherwise verification fails outright.
Illustrative configuration (paths and repository identifiers must be replaced with actual values):
Inference service startup parameters (illustrative)--max-model-len 262144--gpu-memory-utilization 0.85--max-num-batched-tokens 16384--enable-prefix-caching--speculative-config {"method": "<draft model scheme identifier>","model": "<draft model path>","num_speculative_tokens": 7,"draft_sample_method": "probabilistic"}
3. Lever 2: Draft Model Depth, the Balance Point Between Gain and Cost
Draft schemes differ markedly in cost structure. One type performs a projection mapping for every token, so overhead accumulates linearly with length; another uses a multi-layer stacked design that produces 7 candidate tokens in one batched pass, amortizing the projection cost.
The practical data: after deepening the draft layers, single-stream throughput rose further from 46.8 tok/s to 58.5 tok/s. This points to a general rule: tuning speculative decoding is not only about how many tokens to guess, but also about how accurately and how cheaply they are guessed. A draft model that is too large consumes the gains in its own forward pass; one that is too small yields an acceptance rate that is too low. The reasonable range must be determined from acceptance-rate measurements for the specific model pair.
4. Lever 3: Low-Bit Quantization, Effective for Single Stream and Nearly Ineffective Under Concurrency
Pushing weights further down to 4-bit brought single-stream throughput to 75 tok/s. The reason is still bandwidth: the bytes moved per step are roughly halved, which directly relaxes the memory bottleneck.
Under 16-way concurrency, however, total throughput was about 256 tok/s, and the improvement from quantization was only 0.2%. This is not a contradiction but a reflection of two fundamentally different workloads:
- Single stream: Compute is idle and bandwidth is saturated, so the workload is memory-bound and quantization takes effect immediately.
- Concurrency: Batching combines multiple requests into larger matrix multiplications, which fills compute again and shifts the bottleneck from bandwidth to compute, thinning the marginal benefit of weight compression to nearly zero.
The conclusion generalizes: quantization is not a global acceleration switch but a targeted measure for memory-bound workloads. The precision loss from low-bit formats also needs evaluation, especially for long-context and structured-output scenarios.
5. Lever 4: Prefix Caching, a Multiplier for Long-Prefix Scenarios
Prefix caching is disabled by default. Once enabled, it delivers a 14–22x improvement in scenarios with shared long prefixes, such as long-document question answering, fixed system prompts, and multi-turn conversations, because the key-value tensors for the common portion do not need to be recomputed. The cost is that it occupies scarce memory to store the key-value cache, which may compress the available context length or concurrency. Whether to enable it depends on how much prefixes overlap across requests, not on intuition.
6. Tuning Methodology: Locate the Bottleneck First, Then Pick the Lever
Recommended order of investigation:
- Measure baseline TTFT and single-stream tok/s to determine whether the bottleneck is in prefill or decode.
- For single stream, apply speculative decoding first, then tune draft layers and candidate count using the acceptance rate.
- When the memory bottleneck is clear and the precision is acceptable, introduce low-bit quantization.
- Under high concurrency, re-evaluate the benefit of quantization and give the memory budget to batching and the key-value cache.
- Enable prefix caching for workloads with high prefix overlap, and monitor memory usage and context truncation.
If the inference service runs on a cloud container platform, it is advisable to use monitoring, alerting, and logging services to continuously collect throughput, memory, and acceptance-rate metrics, so that parameter iteration is driven by data.
7. Summary
The 75 tok/s single-stream result is not the credit of any single trick, but the combined outcome of speculative decoding as the baseline, draft-depth tuning, quantization to break through bandwidth, and prefix caching adapted to the scenario. The core judgment is one sentence: confirm the bottleneck type first, then decide which class of lever to use. Copying parameters without regard to workload characteristics will not reproduce the gains.
