Speculative Decoding for High-Concurrency LLM Inference: Principles and Practice
Speculative decoding reduces serial generation cost in autoregressive LLM inference by proposing draft tokens cheaply and verifying them in batch with the target model. This article explains the execution model, correctness limits for greedy and sampled decoding, confidence and hardware-aware scheduling, draft-module training, cache and streaming engineering, and how to evaluate and roll out the technique without treating a local speedup as a universal result.
1. Why token-by-token generation becomes the bottleneck
Online generation in large language models is usually autoregressive: the model predicts the next token from the current context, appends that token, and continues. Along the generation axis, later steps depend on earlier ones, so the work cannot simply be completed entirely in advance.
For a large model, each step performs substantial computation and also reads model weights plus the cache of prior context. Depending on model size, batch size, and hardware, the system may be limited by compute, memory bandwidth, cache capacity, or scheduling efficiency. Inference optimization therefore cannot focus only on the latency of a single model call. It should also consider:
- time until the user sees the first output;
- the interval between successive tokens during generation;
- end-to-end time for one request;
- how many requests and output tokens the system can sustain per unit time;
- resource use and tail latency under different loads.
Speculative decoding mainly targets the serial cost of the output phase. It does not let the target model skip correctness checks. A cheaper proposal process suggests several possible future tokens, and the target model verifies them together.
The subject here is the execution method, not a particular model name, launch, or commercial setting. Whether it is worth using should be decided by reproducible performance tests and quality checks.
2. Speculative decoding: trade proposals for batched verification
A typical setup has two roles: a draft generator and a target model.
The draft generator proposes a possible continuation. It may be a smaller model, or a prediction module that shares part of the target model’s structure. The target model still verifies candidates and decides what becomes official output.
One speculation cycle usually works as follows:
- From the currently accepted context, generate several candidate tokens.
- Send the candidate sequence to the target model and, in one verification pass, compute the conditional distributions at the corresponding positions.
- Check the candidates in order under the decoding rule.
- Accept the longest continuous prefix that meets the rule, and correct at the first rejection.
- Update the accepted context and cache, then start the next round.
With causal attention, conditional probabilities at different positions in a candidate sequence can be computed in batch, in a way similar to scoring a known prefix. Those positions still depend on the preceding candidates. Parallel verification does not remove the causal constraint on generation.
The gain comes from a simple fact: if one verification pass can confirm multiple tokens, fewer serial verification rounds may be needed for the same output. Draft generation, verification, cache maintenance, and scheduling all have costs. When draft quality is poor, much of that work is discarded, and the speedup can vanish or turn into a slowdown.
3. Correctness: a plausible draft is not the same as an equivalent output
Correctness depends on the decoding method in use.
3.1 Consistency under greedy decoding
Under greedy decoding, the target model chooses the highest-probability token at each step. To match ordinary decoding, each draft token must match the target model’s choice in the corresponding context.
Once they disagree, later draft tokens cannot be emitted as official output, because they were conditioned on a context the target model has not accepted. The system should take the target model’s choice at that position and start speculation again.
In practice, numerical precision and tie-breaking for equal maxima should also be fixed, so implementation differences are not mistaken for algorithmic errors.
3.2 Distributional consistency under random sampling
Random sampling cannot accept a token merely because the target model also assigns it a relatively high probability.
Let p be the target model’s conditional distribution, q the draft generator’s, and x the candidate token. The classic exact speculative sampling method accepts the candidate with probability:
acceptance probability = min(1, p(x) / q(x))
Here p and q must be defined on the same already accepted context and the same previously accepted draft prefix. If the candidate is rejected, a correction sample is drawn from a normalized positive residual related to max(p − q, 0), not by picking an arbitrary substitute token.
When the algorithm’s assumptions and the implementation conditions hold, this correction preserves the target model’s sampling distribution. Temperature, truncation, and other sampling operations must be part of how p and q are defined; comparing raw model outputs is not enough.
Draft confidence can help decide how far to speculate and when to verify. It cannot replace an acceptance rule that preserves the distribution.
4. How semi-autoregressive generation and confidence scheduling help
4.1 Semi-autoregressive generation organizes computation
Semi-autoregressive generation usually means producing several positions as a block or group while keeping some sequential dependence. It can be combined with speculative decoding, but the two are not the same idea.
The draft generator may emit candidates step by step, or use block prediction to cut its own serial cost. Either way, target-model verification must still follow the intended generation semantics.
The main difficulty with block prediction is that uncertainty usually grows at more distant positions. Proposing a very long sequence to reduce the number of rounds can increase bad candidates and lower the fraction of useful compute. Block size should be chosen from draft quality, verification cost, and the actual workload.
4.2 Confidence scheduling controls speculation effort, not output correctness
The basic idea is to use uncertainty to decide whether to keep drafting or verify immediately.
For example, a peaked distribution and a history of good acceptance may justify a longer draft; a diffuse distribution or repeated rejections should shorten it. This is a design pattern, not a fixed threshold that fits every task.
Calibration also matters. A high probability from the draft generator does not necessarily mean agreement with the target model. More reliable scheduling should also use historical acceptance, task type, context length, and the current queue.
4.3 Hardware-aware scheduling should optimize real execution cost
The same draft length can run very differently under different hardware or load.
At low concurrency, a longer draft may reduce verification rounds. At high concurrency, extra draft compute and cache use can crowd out other requests. A verification batch that is too small may underuse compute; one that is too large may increase queue time and memory pressure.
Hardware awareness is not only “tune parameters by device model.” Policy should follow live signals such as free memory, verification-batch time, active request count, and cache occupancy. The goal is overall benefit under production load, not the largest speedup on an isolated request.
5. Training the draft module: optimize useful acceptance, not prediction score alone
A draft generator is valuable only if it can cheaply propose sequences the target model will accept.
If the draft module is trainable, its data should cover the context types that appear in real traffic, including natural-language question answering, long-form continuation, code generation, and structured output. Data from a single task can look strong offline and still be rejected often in production.
Training can include ordinary next-token prediction and, where appropriate, matching the target model’s probability distribution. A lower training loss does not automatically mean faster inference. Also track:
- acceptance probability at different draft positions;
- average length of the accepted continuous prefix per round;
- useful output per unit of draft compute;
- behavior across input lengths and task types;
- the draft module’s own runtime and cache cost.
A more accurate prediction at a distant position may still not be worth keeping if it is too expensive. Training and inference scheduling should be evaluated together, not optimized in isolation.
6. Production concerns: cache, streaming, and fallback
6.1 Separate accepted state from speculative state
Verification creates context state that is not yet confirmed. The implementation should distinguish the accepted prefix from temporary speculative branches.
When a candidate is rejected, temporary cache entries after the rejection point must be dropped. Otherwise later steps may read history that does not match the official output, producing errors that are hard to trace.
Systems that use paged caches or dynamic memory management should also account for allocation, release, and rollback cost. Fewer verification rounds at the algorithm level do not automatically mean lower memory-management overhead.
6.2 Stream only tokens that have been accepted
Candidates that have not passed verification should not be sent to the user. A later rejection would require retracting or rewriting text that was already shown.
After several tokens are accepted together, the server can emit them as a batch. That can make output feel like a pause followed by a burst. User-experience evaluation should therefore look beyond average generation speed to the distribution of inter-token gaps and the share of long silences.
6.3 Fallback should be a normal path
Speculative decoding does not have to stay on for every request. When acceptance stays low, resources are tight, or outputs are short, ordinary decoding may be better.
Fallback should use observable signals and include damping so the policy does not flap. It should also be possible to turn the accelerated path off quickly and return to a verified baseline when something goes wrong.
7. Measuring speed, throughput, and service quality together
Single-user generation speed and system throughput are different metrics. The first describes how fast one request produces output. The second describes how much work the system completes overall.
A claim that latency falls while throughput stays the same should state the hardware, target model, input and output length distributions, concurrency, sampling configuration, and scheduler. Comparisons between methods should keep those conditions as consistent as possible.
At a minimum, record:
- time to first token and end-to-end latency;
- mean inter-token interval during generation, and its tail;
- request throughput and output-token throughput;
- candidate acceptance rate and average accepted prefix length;
- time spent in drafting, verification, and scheduling;
- peak memory, cache occupancy, and resource use;
- rates of timeout, cancellation, and failure.
For long outputs, fewer serial verification rounds are more likely to pay off. For short outputs, time to first token and fixed scheduling cost may dominate. Results should be broken down by request characteristics so one average does not hide real differences.
Speedup numbers from a particular source should not be treated as a general conclusion. Each system needs its own load tests to establish performance bounds.
8. From offline checks to gradual rollout
The first stage is correctness. Under fixed conditions, test output identity for greedy decoding, and check distribution and task quality for random sampling. Matching the sampling distribution does not mean that the same random seed must produce token-identical text, because the two execution paths may consume different random-number sequences.
The second stage is offline performance analysis. Cover different context lengths, output lengths, task types, and concurrency levels, and locate whether the main bottleneck is drafting, target verification, or cache management.
The third stage is shadow evaluation or a small-traffic rollout. Within the resource budget, observe real requests, with attention to tail latency, abnormal requests, and behavior as load changes—not only average speed.
The fourth stage is gradual expansion. Use acceptance rate, load, and task features to decide when the path is on or off, keep ordinary decoding as a stable fallback, and watch whether the policy favors some request groups over others.
Conclusion
Speculative decoding spends cheap draft generation to obtain batched verification from the target model, reducing serial generation rounds under a correctness constraint. Semi-autoregressive prediction, confidence scheduling, and hardware adaptation can widen the gain, but none of them should be judged apart from the acceptance mechanism and real execution cost.
A dependable deployment should answer three questions at once: whether output semantics stay correct, whether the user experience improves, and whether the system is more efficient at the target load. Only when training, scheduling, cache management, and service evaluation are optimized together does speculative decoding move from a local speedup trick to a capability that can run sustainably.
