Speculative Decoding for LLM Inference: How DSpark Pushes Throughput Beyond Single-Request Latency
This article breaks down why single-request latency in large language model inference eventually hits a floor, leaving throughput as the remaining lever. It contrasts the two mainstream draft-source designs—built-in draft modules trained alongside the main model and external lightweight draft networks trained after the main model is frozen—and uses a simple speedup formula to show how draft cost, acceptance rate, and draft steps trade off. The core of the high-throughput DSpark approach is explained: pushing draft cost down by an order of magnitude, fusing multi-layer features with both embedding and hidden representations, distilling the main model's distribution with acceptance length as the key metric, and adapting verification and batching for parallel checks. The article also covers selection criteria, a pseudocode skeleton of the decoding loop, engineering caveats, evaluation practices and common pitfalls, and cloud deployment guidance.
1. Background: Once Single-Request Latency Is Squeezed Dry, Only Throughput Is Left
The cost structure of LLM inference splits into two phases. Prefill is compute-bound, while decoding is memory-bandwidth-bound. Every generated token requires moving all weights and the growing context cache from GPU memory, yet the vector that actually participates in the matrix multiplication is very short, so compute units sit largely idle. As a result, per-token latency in the decoding phase is determined almost entirely by weight-transfer time and is only weakly correlated with batch size within a certain range.
This produces two independent optimization directions. The first is raising batch concurrency to amortize bandwidth cost across more requests, which is a scheduling and memory-management problem. The second is making a single forward pass emit multiple tokens, which is an algorithm-level problem. Speculative decoding takes the second path: a cheap draft source guesses several consecutive tokens, the target model verifies them in one parallel forward pass, correctly guessed tokens are kept, and positions where the guess fails fall back to resampling. Because verification is a single parallel batched forward pass, its cost is close to that of single-token decoding, so emitting multiple tokens per round can theoretically raise throughput several-fold.
The key premise is that the output distribution stays unchanged. As long as verification uses the standard accept/reject sampling rule, the final sampling distribution is strictly identical to token-by-token decoding of the target model, making the speedup lossless. This is what makes speculative decoding an optimization that can be deployed with confidence, rather than an approximation that trades quality for speed.
2. Structural Differences Between the Two Mainstream Approaches
Draft sources fall into two broad categories: built-in draft modules trained together with the main model, and external lightweight draft networks trained after the main model is frozen. Recently proposed high-throughput designs essentially redraw the boundary between these two routes.
A built-in draft module usually hangs off the end of the main network: it takes the last-layer hidden state, mixes it additively with the token embedding through a projection layer, then runs a full heavy block isomorphic to the backbone (including the feed-forward and mixture-of-experts structure). Its advantage is that features come from the same source and single-step prediction is highly accurate, yielding a high acceptance rate. The drawback is equally clear—single-step cost is roughly one to two percent of a main-model step. That looks small, but drafting is autoregressive and must run serially, so latency accumulates linearly as the number of steps grows. In engineering practice this often forces a conservative one token per round, locking in the throughput gain.
External lightweight drafting takes a different approach: it extracts semantic features from several intermediate layers at different depths of the main model, concatenates them while preserving information from both the embedding space and the hidden space, and feeds them into a single-layer decoding block of only a few hundred million parameters. Single-step cost can be pushed down to roughly one thousandth of the main model, so even seven serial steps accumulate less latency than one step of a heavy draft. The cost is that features come from “outside,” which requires extra alignment training, and draft quality is more sensitive to training data and distillation strategy.
Placing both in the same formula makes the picture clearer. Let the main model’s single-step time be T, the draft’s single-step time be c·T, the number of draft steps per round be k, and the acceptance rate be α. Expected tokens produced per round is approximately (1−α^(k+1))/(1−α), and the speedup is approximately that expectation divided by (1+k·c). The formula yields three clear tuning levers: lower c, raise α, and adjust k so marginal benefit equals marginal cost. The problem with a heavy draft is that c is too large, forcing k to 1; the value of a lightweight draft is that it drops c by an order of magnitude, giving k room to open up.
3. What Is Actually New in the High-Throughput Approach
Based on public descriptions, the core contribution of the new approach is not inventing a draft structure but pushing “drafting can be very cheap” to the extreme, along with solving three engineering problems.
The first is how features are taken and fused. Concatenating multi-layer features is more stable than a single hidden layer and mitigates the distribution drift caused by limited draft-model capacity; retaining both embedding and hidden representations also prevents the projection layer from becoming an information bottleneck.
The second is the training objective. A draft model should learn not only “what the next token is” but also “what the main model will accept.” The common practice is therefore to distill the main model’s distribution and use acceptance length rather than cross-entropy as the primary observable.
The third is compatibility between verification and batching. The verification stage must assemble the k candidate positions into one parallel sequence, and the attention mask, positional encoding, and context-cache reads and writes must all be adapted to a tree or chain structure; otherwise theoretical speedup gets eaten by kernel inefficiency. The wide range of reported throughput gains, 51% to 400%, is precisely a mapping of acceptance-rate differences across tasks: high-determinism scenarios such as code and structured text have high acceptance rates and multipliers near the upper bound, while open-ended generation and long-tail knowledge Q&A have low acceptance rates and multipliers near the lower bound.
4. Implementation Notes and a Sketch
A simple selection rule applies: if the main model is still training or will undergo further pretraining, a built-in draft is almost free and joint training should be preferred; if the main model is frozen and only post-training is possible, an external lightweight draft is the only viable path.
The skeleton of the decoding loop is as follows (logic only, not a specific framework API):
# Pseudocode: main loop of chain-based speculative decodingdraft_state = draft.init_from(main.hidden_states)draft_tokens = []for _ in range_k: # serial drafting; k is set by marginal benefitdraft_state = draft.step(draft_state)draft_tokens.append(draft_state.sample())verified = main.forward_in_parallel(draft_tokens) # one parallel verificationaccepted = accept_by_spec_rule(verified, draft_tokens) # lossless accept/rejectyield from acceptedif len(accepted) < len(draft_tokens): # on rejection, fall back and resampleyield resample_from(verified, position=len(accepted))
Four engineering points also matter. First, the context cache must be adapted to “append multiple tokens per round” to avoid repeated per-token allocation. Second, accepted length differs across requests in a batch, so compact packing is needed to keep compute from being wasted on branches that have already finished. Third, the draft step count k should ideally be adaptive per request, estimated online from recent acceptance rates rather than hard-coded globally. Fourth, acceptance rate, average accepted length, and the share of time spent drafting should be exposed as monitoring metrics, with logging and alerting to pinpoint fallbacks.
5. Evaluation Method and Common Pitfalls
Do not report only end-to-end throughput. It is better to report average accepted length, the share of single-step draft time, the distribution of speedups across task types, and behavior under concurrency pressure. There are three common pitfalls: using the high acceptance rate measured under greedy decoding to infer gains in sampling scenarios; ignoring the draft model’s own memory footprint and warm-up cost; and evaluating at small batch sizes and low concurrency, which masks the bandwidth-amortization effect.
6. Cloud Deployment Recommendations
In cloud environments, this kind of optimization is typically combined with elastic container platforms, model-serving frameworks, model repositories in object storage, and monitoring, alerting, and logging services: the draft model is version-managed as a separate artifact, rolled out gradually according to traffic characteristics, and k and batch strategy are tuned dynamically driven by monitoring metrics. If you use the relevant general capabilities of Baidu AI Cloud, draft weights and main-model weights can be stored in separate buckets and released gradually by version, with monitoring metrics closing the loop on parameter tuning, so throughput gains stay stable while the output distribution remains unchanged.
