Semi-Autoregressive Drafting to Speed Up LLM Inference: Design Principles
This article explains why autoregressive decoding limits large language model throughput and how speculative decoding addresses that limit. It compares autoregressive and parallel draft models, describes a semi-autoregressive drafting design, and shows how load-aware scheduling can choose the draft length. It closes with engineering considerations for deployment.
1. Background: Why Autoregressive Generation Is Slow
Large language models generate text autoregressively. Each new token depends on all the tokens generated before it. Token N cannot be generated until token N-1 is determined, so the whole process is inherently sequential.
The cost of sequential generation shows up mainly in hardware utilization. During decoding, each generated token requires reading the full set of model weights and the cached key-value history, while the actual computation is relatively small. Compute units spend most of their time waiting for data to move from memory, and much of their capacity goes unused. As output gets longer, waiting time grows linearly, and the latency that users notice becomes more pronounced.
For this reason, the key to faster generation is not making each computation step faster. It is getting more useful tokens out of each forward pass.
2. The Basic Idea of Speculative Decoding
Speculative decoding is a widely used acceleration method. It has two core steps: drafting and verification.
- A smaller draft model proposes k candidate tokens in a row.
- The large model takes these k candidate tokens as input and, in a single forward pass, produces a probability distribution for each position.
- Candidates are checked one by one, starting from the first position. Accepted tokens are output directly. At the first rejected position, the large model’s distribution is used to resample a token, and all remaining candidates are discarded.
The speedup depends on the acceptance rate. The higher the acceptance rate, the more tokens each forward pass of the large model can confirm. If the acceptance probability at each position is approximately a constant α, the expected number of tokens produced per round is about (1 - α^(k+1)) / (1 - α). This formula shows two things. First, the gain from a higher acceptance rate levels off as k increases. Second, the draft model must be fast enough. Otherwise, the time spent drafting cancels out the time saved during verification.
The following pseudocode illustrates the process. It is not a specific implementation.
def speculative_step(target, draft, prefix, k):candidates = draft.propose(prefix, k) # Draft k candidate tokensprobs = target.score(prefix, candidates) # Verify k positions in one forward passoutput = list(prefix)for i, tok in enumerate(candidates):if accept(probs[i], tok): # Accept based on the probability ratiooutput.append(tok)else:output.append(resample(probs[i])) # On rejection, resample from the target distributionreturn outputoutput.append(sample(probs[k])) # If all candidates are accepted, get one extra tokenreturn output
3. Two Existing Drafting Approaches and Their Bottlenecks
Approach 1: Autoregressive drafting. The draft model generates tokens one at a time, just like the large model. Its candidates are of good quality, and its acceptance rate is stable. The problem is that drafting itself is sequential. As k grows, drafting takes longer, which offsets part of the gain.
Approach 2: Parallel drafting. The draft model outputs results for all k positions at once, so it is very fast. However, each position is computed independently of the others, so later positions cannot see the specific values chosen at earlier positions. As depth increases, the candidate tokens fit together less well, and the acceptance rate drops quickly. The longer the draft, the more likely the large model is to reject it as a whole.
A third problem arises at the scheduling level. Regardless of draft quality, the system usually sends all candidates to the large model for verification. When the system is idle, this extra computation costs almost nothing. When the system is at full load, candidates that are bound to be rejected use compute that could serve other requests, and overall throughput falls. Therefore, the draft length should match the current load rather than stay fixed.
4. Semi-Autoregressive Generation: Balancing Speed and Coherence
The semi-autoregressive approach combines the strengths of the two drafting approaches.
The main network keeps computing in parallel. A single forward pass produces the hidden states for all positions, which preserves high throughput. After the main network’s output, a lightweight sequential module is added so that each position’s prediction depends on the tokens already drafted before it. As a result, the distribution at each later position is constrained by the values at earlier positions, and the candidate sequence is more coherent in meaning and word choice.
When designing this sequential module, the following points matter:
- Module size. The number of layers and the dimensions of the sequential part should be kept small. Otherwise, it reintroduces sequential latency. The goal is for its cost to be much smaller than one forward pass of the large model.
- Training method. If training conditions only on ground-truth prefixes, the model encounters its own generated prefixes at inference time. The two distributions differ, which is known as exposure bias. Training should usually simulate the drafting trajectories used at inference to reduce this mismatch.
- Training objective. The draft’s training objective should align directly with the large model’s output distribution, not only fit the next ground-truth token. This ties the acceptance rate to the actual speedup.
With this structure, the acceptance rate can stay high across positions even when the draft is long. This is what makes long drafts useful.
5. Hardware-Aware Confidence-Based Scheduling
With a high-quality long draft, the next question is how many positions the large model should verify. This question breaks down into two sub-problems.
First, estimate the survival probability of each position. A lightweight scorer is attached to the draft model to predict the probability that the large model will accept each candidate position. Acceptance is decided in prefix order. For position k to contribute any output, all of positions 1 through k must be accepted. So its expected contribution is the product of the probabilities of all earlier positions up to k.
Second, choose the verification length based on real-time load. Verifying each additional position costs compute, and that cost changes with how busy the system is. When the system is idle, extra positions are nearly free, so the scheduler should verify as many as possible. When the system is busy, extra positions take compute away from other requests, so the draft should be shortened. The scheduler needs to collect signals such as queue length, batch size, and compute utilization continuously, and smooth them to avoid frequent fluctuations in draft length.
The following decision logic illustrates the idea. The constants are for illustration only and are not actual parameters.
def choose_draft_length(probs, load_factor, max_len):# probs: estimated acceptance probability for each draft position# load_factor: system load between 0 and 1unit_cost = 0.02 + 0.5 * load_factor # Higher load means a higher verification cost per positiongain, survive = 0.0, 1.0best_k, best_value = 0, 0.0for k, p in enumerate(probs[:max_len], start=1):survive *= p # Probability that the first k positions are all acceptedgain += survive # Cumulative expected number of accepted tokensvalue = gain - unit_cost * k # Net gain: accepted tokens minus verification costif value > best_value:best_k, best_value = k, valuereturn best_k
This approach has one main benefit. At low load, the scheduler automatically allows longer verification. At high load, it automatically tightens the limit. This keeps compute focused on the positions most likely to produce useful output.
6. Engineering Considerations
- Track acceptance rates by position. An average acceptance rate can hide problems. Record acceptance separately for each depth, and use those results to set the maximum draft length.
- Account for high-concurrency scenarios. As batch size grows, compute units move closer to saturation, and the relative benefit of speculative decoding shrinks. Under these conditions, the scheduling policy should fall back to shorter drafts or turn speculation off.
- Align training data with production traffic. If the draft model is trained on data that differs substantially from live requests, the acceptance rate drops noticeably.
- Evaluate end to end. Single-request speed does not reflect overall service performance. Evaluation should measure throughput, average latency, and tail latency such as p99 across different concurrency levels.
- Plan for extra memory and overhead. The draft model’s parameters and the intermediate state for candidate sequences both use GPU memory. Deployments should reserve space for them and confirm the actual gains on the target hardware.
7. Summary
The value of speculative decoding is that one large-model computation can produce multiple tokens. Semi-autoregressive drafting keeps the speed of parallel generation while adding a lightweight sequential module that improves the coherence of long drafts. Hardware-aware scheduling uses survival probabilities and real-time load to decide how many positions to verify, so wasted computation does not crowd out other work. Together, these techniques can raise throughput while keeping latency variation under control. When deploying, base decisions on the acceptance rate distribution and end-to-end metrics under concurrent load, not on a single-point speedup figure.
