LLM Speculative Decoding: How It Works and How to Deploy It at High Concurrency
Learn how speculative decoding combines low-cost draft generation with target-model verification to accelerate LLM inference. This article explains acceptance rules, confidence-based scheduling, cache management, performance evaluation, and deployment practices for high-concurrency services, with an emphasis on output correctness and operational stability.
1. From Token-by-Token Bottlenecks to Speculative Decoding
Large language models typically generate text autoregressively: the model predicts the next token from the existing context, appends it to the sequence, and repeats. A token is the basic unit of text processed by the model; it does not necessarily correspond to a complete character or word.
This process has an inherent sequential dependency. Even on hardware with substantial parallel processing capacity, later tokens in a request must wait for earlier results. During decoding with small batch sizes, repeated model-weight access, attention-cache reads, and compute-task launches can make memory bandwidth and scheduling overhead the limiting factors, leaving compute capacity underused.
High-concurrency serving makes this trade-off more pronounced. Combining requests into batches can improve hardware utilization, but larger batches may also increase the waiting time for individual requests. Production services therefore need to track two distinct goals:
- Overall throughput: How much valid output the service delivers per unit of time.
- Per-request generation speed: How quickly subsequent tokens arrive after a request begins producing output.
Speculative decoding reorganizes part of this sequential work. A lower-cost mechanism first generates several candidate tokens, and the target model verifies them together. The goal is to confirm multiple output positions in a single target-model pass.
This is an inference execution optimization, not necessarily a change to the target model’s core architecture. The target model, draft module, and inference scheduler should be designed as cooperating components with distinct responsibilities.
2. The Core Workflow: Draft, Verify, and Continue
2.1 The Draft Module Proposes a Candidate Sequence
Given the current context, the draft module generates a sequence of candidate tokens. It may be a smaller model or a lightweight prediction module trained to work with the target model.
Its purpose is not to produce the final answer independently. Instead, it should predict the target model’s likely next tokens as accurately and cheaply as possible.
This requires balancing two factors. The draft must be inexpensive enough that its additional computation does not cancel out the benefits of verification. It must also agree sufficiently with the target model; otherwise, frequent rejections force the system back toward token-by-token generation.
Parameter count alone is therefore not enough to judge a draft model. Consistent token handling, contextual understanding, alignment with the workload, and actual execution latency all affect the result.
2.2 The Target Model Verifies Multiple Positions Together
The target model receives the existing context and candidate sequence. Using causally constrained computation, it obtains the conditional probabilities needed to evaluate each candidate position.
Verifying multiple positions together does not remove autoregressive dependencies. The candidate sequence supplies a provisional prefix, allowing the target model to evaluate several positions in one pass. Each position can still depend only on the context that precedes it.
When candidates satisfy the acceptance criteria, the system can advance by multiple tokens. If a candidate fails at a particular position, the system typically corrects that position and discards later candidates that depend on the rejected prefix.
Attention key-value (KV) caches must remain synchronized with this process. States for accepted tokens are retained, while states for rejected candidates are discarded or rolled back. A cache that does not match the actual output prefix can compromise subsequent generation.
2.3 Acceptance Rules Determine Output Semantics
Speculative decoding is not simply a matter of accepting candidates that the target model considers “close enough.”
For deterministic greedy decoding, a candidate can be checked against the token selected by the target model at the corresponding position. Random sampling requires an acceptance and correction procedure that preserves the target distribution.
In a classic exact speculative sampling scheme, let the target distribution be p, the draft distribution be q, and the proposed token be x. Its acceptance probability is:
α(x) = min(1, p(x) / q(x))
If the candidate is rejected, the algorithm constructs a correction distribution from the difference between the target and draft distributions and samples again. The complete algorithm must also correctly handle the additional sampling step when all proposed tokens are accepted.
This formula is not a universal interface for every implementation. It illustrates the central requirement: mathematically preserving the target sampling distribution depends on correct acceptance and correction rules. Accepting candidates solely on a probability threshold may be an approximate optimization and requires separate evaluation of output-quality changes.
Preserving the sampling distribution also does not guarantee identical text under the same random seed. Changes in random-number consumption and execution paths can produce different individual outputs.
3. The Boundaries of Semi-Autoregressive Generation and Confidence-Based Scheduling
3.1 Semi-Autoregressive Generation Provides Local Parallelism
Semi-autoregressive generation generally parallelizes part of the generation process while retaining dependencies between blocks or stages.
Speculative decoding has similar execution characteristics: the draft stage proposes multiple positions, and the target stage confirms a segment of output. However, the terms are not strictly synonymous. These characteristics do not establish that a system uses a particular training objective or network architecture.
For deployment, actual execution behavior is more informative than architectural labels:
- How many candidates are proposed in each draft round?
- How does the target model organize verification?
- How many candidates are accepted on average?
- How does decoding recover after a rejection?
- Does the implementation preserve the original output distribution?
The answers explain practical performance gains more directly than the label attached to the system.
3.2 Confidence Should Guide Scheduling, Not Replace Verification
The draft module can use prediction confidence to decide whether to extend a candidate sequence. If later predictions become uncertain, a longer draft may add wasted computation. Moving to verification earlier can be more efficient.
However, high confidence does not necessarily mean high accuracy. A model may be overconfident on certain tasks, and the relationship between confidence and acceptance rate can change with prompts, context length, and sampling settings.
Confidence is therefore better used as a scheduling signal than as a reason to skip target-model verification. Production systems should assess confidence calibration on real workloads and combine it with recent acceptance rates, candidate length, and hardware load.
3.3 Hardware-Aware Scheduling Must Consider End-to-End Cost
Longer candidate sequences are not always faster. They may increase the number of tokens a verification pass can confirm, but they can also increase draft computation, verification work, cache usage, and batch-scheduling complexity.
Hardware-aware scheduling should account for:
- Compute utilization and memory-bandwidth pressure.
- The number of active requests and their remaining generation lengths.
- Verification batch shapes and padding overhead.
- Cache capacity and temporary-state memory usage.
- Data-transfer costs between the draft and target models.
A candidate length that works well at low concurrency may perform poorly under heavy load. Scheduling should adapt to service conditions rather than treating a fixed length as universally optimal.
4. How to Determine Whether Speculative Decoding Helps
A simplified relationship captures the performance trade-off:
Effective generation rate ≈ Valid tokens confirmed per round ÷ Total time per round
The total time includes at least draft generation, target verification, request scheduling, and state management.
Acceptance rate is an important diagnostic metric, but it is not the final objective. A draft module may achieve a high acceptance rate while being expensive to run. Another may accept fewer candidates but deliver better end-to-end performance because its execution cost is lower.
4.1 Separate Time to First Token from Sustained Generation Speed
Time to first token includes request queuing, context processing, and the computation needed to begin generation. Speculative decoding primarily optimizes the subsequent decoding stage, so it may not improve first-token latency. Some implementations may even increase it through additional initialization or draft computation.
Measure time to first token, inter-token latency, and total response time separately. First-token latency may dominate short responses, while sustained generation speed is usually more important for long responses.
4.2 Measure Tail Latency as Well as Average Performance
An improvement in average speed does not guarantee a better experience for every user. Under high concurrency, a small number of long-context or low-acceptance requests may consume substantial verification resources and delay other requests.
Track median and high-percentile latencies alongside queue growth, timeout rates, resource contention, and fairness across requests.
4.3 Compare Throughput Under Explicit Constraints
“Faster for an individual user” and “higher overall throughput” are different claims.
If a service improves per-request speed at the same aggregate throughput, its resource organization may be better suited to user experience. If it handles more requests under the same latency constraints, the capacity benefit is more direct.
Performance results must specify the hardware configuration, input and output length distributions, concurrency conditions, sampling settings, and baseline implementation. Speedup figures without this context should not be used directly for capacity planning in another deployment.
5. Deployment Design for High-Concurrency Serving
5.1 Establish a Reliable Baseline First
Before enabling speculative decoding, measure the conventional decoding path and verify that it does not have obvious scheduling inefficiencies or resource-configuration problems.
The baseline should cover short responses, long responses, long contexts, and tasks of varying complexity. Include concurrency levels near saturation rather than testing only when the hardware is mostly idle.
5.2 Enable Speculation According to the Workload
Not every request benefits from speculative decoding.
Short outputs may not provide enough generation work to amortize draft costs. Tasks on which the draft and target models disagree may yield too few accepted candidates. When hardware is close to capacity, additional compute and cache requirements can also reduce service stability.
The system can decide whether to use speculative decoding based on task category, expected output length, recent acceptance behavior, and resource pressure. Conventional decoding should remain available as a fallback.
5.3 Keep Streaming Output and State Management Consistent
Only tokens that have completed verification and been accepted should be sent to the user as final output. Streaming unverified draft tokens can lead to text retractions, visible flickering, or incorrect responses.
State handling must also be defined for request cancellation, output-length limits, termination conditions, and exceptions. When a request ends, promptly release draft caches, target caches, and associated scheduling resources to prevent leaks.
5.4 Use Staged Rollouts and Automatic Fallback
Begin deployment with a small share of requests. Monitor end-to-end latency, valid-output throughput, memory usage, and error rates before expanding coverage.
Fallback conditions should reflect service objectives, such as sustained latency degradation, excessive cache pressure, or rising error rates. Ideally, fallback preserves the user-visible behavior of the conventional generation path, keeping the internal acceleration mechanism from becoming an external interface dependency.
6. Draft Training and Quality Validation
Draft-module training should reflect how the target model is actually used, rather than focusing only on general text prediction. Training data should cover common languages, task types, context lengths, and output styles in the service workload.
Changes to the target model, token handling, or sampling strategy require renewed validation of draft compatibility. A previously high acceptance rate may not carry over to the updated configuration.
Quality validation should distinguish two implementation categories:
- Exact methods: Focus on the correctness of acceptance rules, correction sampling, cache rollback, and termination handling.
- Approximate methods: In addition to engineering correctness, evaluate quality loss and define acceptable limits.
Even exact methods need checks for numerical precision, the order of probability transformations, and special-token handling relative to the baseline. Structured outputs also require validation of format completeness and field constraints; fluent text alone is not sufficient.
Speculative decoding does not add fact-checking or safety capabilities. Existing access controls, content checks, audit logging, and sensitive-information handling must remain in place.
7. Conclusion: Measure Acceleration Through Valid Output and Service Stability
Speculative decoding reduces some of the sequential overhead of token-by-token generation by combining low-cost candidate proposals with consolidated target-model verification. Its practical value depends on draft accuracy, verification efficiency, cache management, and high-concurrency scheduling—not on an algorithm label alone.
A sound deployment follows three principles: preserve output semantics first, verify performance gains under real workloads, and maintain service stability through adaptive scheduling and reliable fallback.
The most meaningful result is not a peak speed recorded in a single experiment. It is the ability to consistently deliver more valid output, faster, within a defined resource budget and latency requirements.
