Agent Builder Foundations
Evidence-tiered mechanisms for agent builders
Agent foundations
스펙큘레이티브 디코딩은 어떻게 LLM 추론 속도를 높이는가?
Concept·Cost, latency, and operations·math intuition·8 sources·updated 2026-11-25
Decode dominates an agent's wall-clock, and by default it is strictly sequential: one token in, one full forward pass, one token out, repeated for every token of every turn. Speculative decoding is the one latency lever that cuts that sequential cost without touching model weights, retraining anything end-to-end, or trading away answer quality — which makes it worth understanding as a mechanism you can reason about, not just a serving flag you flip and hope.
A cheap draft process proposes several tokens ahead of where the target model has actually decoded. The target model then checks all of those guesses in a single forward pass instead of one at a time. Tokens the target model would have produced anyway are accepted for free; the first guess it disagrees with is thrown out and resampled correctly from there. The accept/reject math guarantees the final output has exactly the same distribution as running the target model alone — the speedup comes from turning a sequential dependency into a parallel check, not from approximating the model.
Decode at typical serving batch sizes is memory-bandwidth-bound, not compute-bound: most of a decode step is spent streaming model weights through the GPU, with FLOPs to spare. Speculative decoding spends that spare compute. Verifying several draft tokens in one forward pass costs about the same wall-clock as producing a single token normally, because the bottleneck — memory traffic — barely grows while the extra parallel compute is nearly free, right up until the batch gets large enough to saturate the chip.
One decode cycle has three steps:
- Draft. A cheap process — a much smaller separate model, or a lightweight head trained alongside the target model — autoregressively proposes several candidate tokens ahead of the current position.
- Verify. The target model runs a single forward pass over the drafted tokens together, producing next-token probabilities at every position at once. This is what the parallelism buys: a transformer's forward pass is inherently parallel across positions — only its own token-by-token *sampling* was ever sequential.
- Accept or reject. Walk the candidates left to right. Accept a draft token with probability
min(1, p_target(x) / q_draft(x)). At the first token the check fails, discard every draft token after it and resample that position from the corrected residual distribution, then start the next draft cycle from there.
The engineering advances that made this a serving default (EAGLE and its EAGLE-3 successor, now served in vLLM on AMD Instinct at about 2x throughput) are almost entirely in the draft step: instead of an independently trained small model, they train a lightweight head to predict the target model's own next hidden-state features autoregressively. Because the draft is derived from the target's own internal state rather than a separately trained approximation, its guesses correlate far more with what the target model would actually choose, which is what raises the acceptance rate high enough to pay for the extra verify pass.
The correctness argument is a modified rejection sampling scheme. For a draft distribution q and target distribution p, accept a drafted token x with probability min(1, p(x)/q(x)). If rejected, resample from the residual distribution max(0, p(x) - q(x)), renormalized. Summing the accept branch and the reject-then-resample branch over all possible tokens reproduces p(x) exactly, regardless of what q is — the draft can be a bad guesser and the math still holds, it just accepts less often. The draft is *free information*, never *different information*: a bad draft costs you speed, not correctness.
The speed argument follows from the memory-bound builder model above. If one decode step costs time T largely independent of small compute increases, then verifying k draft tokens in one step still costs roughly T, not k · T. Accepting an average of α · k tokens per verify step (α = acceptance rate) turns α · k sequential steps into one, so the achievable speedup tracks 1 + α · k — until batch size grows enough that the GPU becomes compute-bound and the "T regardless of k" assumption stops holding.
- Measure acceptance rate on your own traffic before trusting any vendor's throughput multiplier. Structured output (code, JSON, tool-call arguments) accepts far more often than open-ended text.
- For grammar-constrained output, let the grammar draft the forced tokens. Grammar-as-a-Draft raised mean acceptance length from 2.06 to 5.43 on JSON; run an output-quality eval first, because it is not strictly lossless.
- Prefer a feature-level draft head trained alongside the target model (the EAGLE approach) over an off-the-shelf small model as the draft; acceptance rate is the entire economics of the technique.
- Benchmark end-to-end latency and cost per token at your real concurrency, not tokens/sec at one batch size — the win shrinks as concurrency rises and the GPU shifts from memory-bound to compute-bound.
- Treat vendor multipliers (2x, 15x) as workload- and hardware-specific ceilings, not a number you inherit automatically; validate against your own agent's decode traffic.
- Certify a rollout per request, not by aggregate accuracy. Compare under batch-invariant kernels, where any diff is real, or against a reordering floor measured from at least three replicas.
- Assuming the speedup is free at any batch size. At high concurrency, verify compute competes with the batch; the benefit shrinks or vanishes once decode is compute-bound.
- Mismatched draft and target. An unrelated small model, or a draft head trained against a different target checkpoint, tanks acceptance and can make decode slower than not speculating.
- Treating headline multipliers as guaranteed. A hardware-co-designed benchmark number reflects a specific model, batch size, and accelerator; a different production workload will see a different number, often much smaller.
- Blaming speculation for batch noise. In one vLLM study it flipped about 1.5-1.8% of graded answers, no more than reordering the same requests did. Under batch-invariant kernels it reproduced the reference text exactly. A larger diff there is an accept/reject bug.
- Calling every variant lossless. Grammar drafts accepted with probability 1 can shift the output distribution.
See speculative decoding for current vendor and hardware coverage, and agent latency for why the strictly sequential decode loop this technique attacks dominates an agent's wall-clock in the first place.
newest first
- BenchmarkGrammar-as-a-Draft: More Tokens per Speculative Decoding Step on Grammar-Constrained Structured Outputsbenchmark/result-backed
Merges grammar-forced tokens (the only legal next token) into the draft row and accepts them without computing logits. On a JSON benchmark on TPU v7x, mean acceptance length rises from 2.06 to 5.43 with an MTP drafter, decoding 2.66-2.81x faster at batch 1 and 1.14-1.70x at batch 64. Caveat from the authors: accepting grammar drafts with probability 1 can shift the output distribution relative to grammar-masked decoding.
- BenchmarkExact on Paper: Which LLM Serving Shortcuts Flip Graded Answers, Measured Against the Noise of Reordering the Same Requestsbenchmark/result-backed
Serves one 4B model in vLLM and grades 3,380 requests per configuration. With default kernels, exact features including speculative decoding flip 1.47-1.78% of graded outcomes, none above the 1.72% floor from merely reordering requests. With batch-invariant kernels, speculative decoding reproduces the reference text on every request. A gate comparing a single replica pair rejected an unchanged configuration.
- TheoryFast Inference from Transformers via Speculative Decodingtheory/paper-backed
Introduces speculative decoding and proves the accept/reject scheme reproduces the target model's output distribution exactly, so the speedup carries no quality trade-off.
- TheoryAccelerating Large Language Model Decoding with Speculative Samplingtheory/paper-backed
Independently formalizes speculative sampling with the same modified-rejection-sampling correctness argument as Leviathan et al.
- TheoryEAGLE: Speculative Sampling Requires Rethinking Feature Uncertaintytheory/paper-backed
Drafts from the target model's own hidden-state features with a lightweight head instead of an independent small model. Higher acceptance rates made speculation a practical serving default.
- Source storyEAGLE-3 Speculative Decoding on AMD Instinct GPUs: Training and Serving with vLLM and AMD Quarksource story
EAGLE-3 in a real vLLM serving stack on AMD Instinct GPUs: 2.00x throughput on Kimi-K2.5 and 1.79x on MiniMax-M2.5. Shows the pattern ships across accelerator vendors. Vendor-reported.
- Source storyAchieve state-of-the-art inference latencies with speculative decodingsource story
Modal and Decagon production write-up treating speculative decoding as workload-specific draft/target tuning, not a flip-a-switch default.
- Source storyBoost Inference Performance up to 15x on NVIDIA Blackwell Using DFlash Speculative Decoding - NVIDIA Developersource story
DFlash on NVIDIA Blackwell reports up to 15x when the draft/verify pair is co-designed with the accelerator. A vendor ceiling number, not a typical one; compare roughly 1.8-2x in less specialized stacks.