A GPU fleet can be fully booked while utilization still looks disappointing. The usual culprit is autoregressive decoding: each next token depends on the prior token, so a large model repeatedly launches relatively small decode kernels and waits on memory traffic. Speculative decoding for LLMs attacks that serial dependency without changing the target model’s output distribution. Done well, it turns unused verification parallelism into more tokens per second. Done carelessly, it adds cache churn, scheduler complexity, and little measurable gain.
Why decode is the expensive part
Prefill and decode stress serving hardware differently. During prefill, the server processes an entire prompt in parallel, producing high arithmetic intensity and generally strong GPU utilization. During decode, each active sequence usually advances by one token at a time. The model must read weights and the sequence’s KV cache to produce a small amount of new work.
For a large model serving long-context requests, this is often memory-bandwidth-bound. Batching helps, but only up to the point where request arrival patterns, latency targets, and KV-cache capacity constrain the batch. A platform can buy more GPUs and still receive poor marginal throughput because each device is spending too much time on token-by-token execution.
The core insight behind speculation is blunt: a cheaper model can guess several likely next tokens, and the expensive model can verify that proposed run in a single forward pass. When the guesses are good, one target-model invocation commits multiple tokens instead of one.
How speculative decoding for LLMs preserves quality
A draft model proposes a sequence of k tokens from its own probability distribution. The target model then evaluates the prompt plus those proposals, producing target probabilities for every proposed position in parallel. The server accepts the longest valid prefix, rejects at the first failed proposal, and samples a corrective token from the target distribution before continuing.
This is not merely “use a small model first.” Correct speculative sampling uses an acceptance rule based on the draft probability q(x) and target probability p(x), commonly accepting a proposed token with probability min(1, p(x)/q(x)). If a token is rejected, the replacement token must be sampled from a residual distribution that corrects for probability mass already represented by the draft proposal.
That correction is what matters operationally. A properly implemented algorithm is distributionally equivalent to sampling directly from the target model, subject to the same sampling policy. Greedy decoding has a simpler path: accept draft tokens while they match the target model’s argmax, then emit the target token at the first mismatch. Approximate variants exist, but they should be labeled as quality-performance trade-offs rather than marketed as lossless acceleration.
The useful quantity is not draft-model speed alone. It is accepted tokens per target-model verification. If a draft proposes eight tokens and the system accepts five on average, the target model advances roughly six positions after accounting for the corrective token. If it accepts only one, the extra draft work and orchestration overhead can make service worse.
The serving path is a cache-management problem
The algorithm is compact. The production implementation is not. Both models need state for the same request, and target verification creates provisional KV-cache entries that must be committed or discarded according to the accepted prefix.
A practical serving loop tracks the request’s committed token position separately from its speculative extent. The draft model appends k candidate tokens to its cache. The target model evaluates the same candidates against its committed context and writes candidate KV blocks. Once verification determines an accepted prefix length a, the runtime commits only those a blocks. Blocks beyond a are invalid and must be released or made available for reuse.
Paged KV-cache designs make this substantially less painful. Rather than copying a contiguous cache tensor on every branch, a request maps logical token blocks to physical pages. Candidate pages can be appended provisionally, then retained, remapped, or returned to a free list after verification. Copy-on-write semantics are useful when scheduler mechanics or prefix caching cause page sharing, but they must be explicit. Accidental aliasing between a rejected speculative suffix and a later request is a correctness failure, not a minor memory bug.
The cache accounting must include both models. Teams sometimes benchmark a small draft model in isolation, see negligible memory use, then discover that target-side speculative allocation reduces concurrency enough to erase the gain. This is especially acute with long contexts, high fan-out chat traffic, or models whose KV heads and precision format already put HBM under pressure.
Draft-model choice determines whether the math pays off
A smaller model is the conventional draft model, but “smaller” is not a sufficient criterion. It needs to be cheap enough to run and close enough to the target model’s local token distribution to earn a high acceptance rate. A poorly aligned 1B parameter draft model can lose to a moderately larger model trained or distilled specifically for the target.
Some systems use the target model’s own early-exit layers as a draft path. Others use multiple draft heads that predict several future tokens from one target-model hidden state. These approaches avoid operating a separate model and can simplify deployment, though they add architecture-specific training and may complicate model upgrades. Tree-based speculation can propose multiple continuations and let the target verify a branching candidate structure. It can improve coverage where uncertainty is high, but the verification mask, cache layout, and scheduling policy become materially more complex.
Proposal length is also dynamic, not a fixed tuning constant. Long drafts amortize target execution when acceptance is high. They waste work when the model enters a difficult region: source code with an unfamiliar API, structured JSON near a syntax boundary, multilingual text, or a tool call with low-probability arguments. A controller should adapt k using recent acceptance behavior, request class, context length, and queue pressure. Under a strict time-to-first-token SLO, it may be better to begin with ordinary decoding and enable speculation only after the first visible token.
Measure the system, not the benchmark
Speculation can produce impressive offline tokens-per-second results while degrading a multi-tenant endpoint. The evaluation unit should be a realistic workload mix with production sampling parameters, prompt lengths, output lengths, streaming behavior, and concurrency. A single fixed prompt hides the effects that actually determine fleet cost.
Track at least these signals:
- Mean accepted draft tokens per verification, segmented by model, temperature, request type, and output position.
- End-to-end output tokens per second, plus time to first token and inter-token latency at p50, p95, and p99.
- Target and draft GPU memory occupancy, KV-page allocation failures, and eviction activity.
- Scheduler efficiency, including batch size at verification, queue delay, and stranded capacity caused by incompatible sequence lengths.
- Cost per completed request and per generated token, not only GPU utilization.
Acceptance rate by itself is easy to misread. A 70% token acceptance rate may be excellent with a cheap draft and efficient fused verification, or disappointing if draft execution serializes behind the target model. Similarly, a throughput gain that increases p99 inter-token latency may be unacceptable for an interactive coding assistant but reasonable for asynchronous document generation.
Failure modes that appear after rollout
The first failure mode is model drift. Updating the target model, changing quantization, modifying the tokenizer, or serving a new domain mix can reduce alignment with the draft model. Acceptance collapses gradually, so a static benchmark does not catch it. Treat acceptance distribution as a release gate and a continuously monitored production metric.
The second is scheduler interference. Speculative requests have variable verification lengths, while continuous batching prefers predictable resource use. If the scheduler admits every request at a maximum draft length, a few low-acceptance sequences can reserve pages and reduce batch density for everyone else. Admission control should cap speculative depth based on free KV pages and disable it when memory pressure or queue delay exceeds a threshold.
The third is sampling inconsistency. Temperature, top-p, top-k, repetition penalties, logit bias, stop sequences, and grammar constraints must be applied coherently to both proposal and verification distributions. Applying a constraint only on the target path can break the assumptions behind acceptance correction. For constrained generation, measure whether the draft can produce valid candidates often enough to justify its cost.
Finally, do not hide fallback behavior. The serving stack should be able to disable speculation per model, tenant, request class, or overloaded replica without restarting the fleet. A circuit breaker keyed to acceptance, KV pressure, and tail latency is more valuable than a global feature flag that stays enabled until an incident.
The productive way to adopt speculation is to start with one target model and one representative traffic slice, then make the cache lifecycle, acceptance telemetry, and fallback path boring before chasing maximum draft depth. The real win is not a clever decoding trick. It is a serving system that converts unused GPU parallelism into lower cost without creating a new tail-latency incident.


Leave a Reply