induwara.lk
induwara.lkAI · LLM inference

Speculative Decoding Speedup Calculator

Enter your draft model's acceptance rate, the draft tokens per step, and the draft-to-target cost ratio to get the exact LLM inference speedup — plus the optimal number of draft tokens. Uses the published Leviathan et al. formula, runs fully in your browser, no signup.

By Induwara AshinsanaUpdated Jul 8, 2026
Speculative decoding speedupexact formula
Leviathan et al. · ICML 2023
75%

Share of draft tokens the target model accepts.

Tokens the draft speculates before each verification.

Draft forward-pass time ÷ target forward-pass time.

Presets

Leave blank for a unitless speedup, or enter your baseline tokens/s to estimate effective throughput.

Speedup
1.88×
vs. plain autoregressive decoding
Tokens / step (E)
3.29
Cross-check: 3.29
Cost / step
1.75×
γ·c + 1 = 5·0.15 + 1
Optimal γ
4
Peak 1.91× at γ=4

Worth enabling

A clear latency win — the draft is fast enough and accurate enough to pay for itself.

At α = 75% and c = 0.15, the best number of draft tokens is γ = 4 (1.91×), not γ = 5.

Speedup by γ (1–12)

γSpeedupRelative
11.52×
21.78×
31.89×
4best1.91×
51.88×
61.82×
71.76×
81.68×
91.61×
101.53×
111.46×
121.39×

How this was computed

E = (1 − α^(γ+1)) / (1 − α) = (1 − 0.75^6) / (1 − 0.75) = 3.29
series check: 1 + α + … + α^γ = 3.29
cost = γ·c + 1 = 5·0.15 + 1 = 1.75
speedup = E / cost = 3.29 / 1.75 = 1.88×

Speculative decoding is exact: it produces the same output distribution as the target model (Chen et al., 2023). Only latency changes — never quality.

Formulas from the original speculative-decoding paper.

How it works

Speculative decoding speeds up large-language-model inference by letting a small, cheap draft model guess several tokens ahead, then verifying all of them in a single forward pass of the large target model. Any prefix of guesses the target agrees with is kept for free; the first disagreement is corrected by the target itself. Because the expensive model runs once per batch of γ guesses instead of once per token, wall-clock latency drops — without changing the output.

This tool implements the exact improvement-factor model from Fast Inference from Transformers via Speculative Decoding (Leviathan, Kalman & Matias, ICML 2023). Every quantity is measured in units of one target-model forward pass, so the result is a hardware-independent multiplier. Three inputs drive it:

  • Acceptance rate α — the probability the target accepts a given draft token (an empirical number you measure on your own prompts).
  • Draft tokens per step γ — how many tokens the draft speculates before each verification.
  • Cost ratio c — one draft forward pass divided by one target forward pass; estimate it as target tokens/s ÷ draft tokens/s.

The math is three deterministic steps:

  1. Expected tokens per step. The number of tokens produced per iteration is a geometric series over accepted draft tokens plus the one guaranteed target token: E = (1 − α^(γ+1)) / (1 − α), which equals 1 + α + α² + … + α^γ. The calculator computes it both ways as a self-check.
  2. Cost per step. The draft runs γ times at cost c each, plus exactly one parallel target verification pass: cost = γ·c + 1.
  3. Speedup (improvement factor). Expected tokens divided by cost per step (Theorem 3.8): speedup = E / (γ·c + 1). A value above 1 is a real wall-clock win; below 1 means the overhead outweighs the savings.

Speedup is concave in γ: it rises, peaks at an interior optimum, then falls as each extra draft token costs more than it earns. That optimum shrinks as the draft gets slower (larger c). The tool scans γ = 1 to 12 and reports the peak, so you can pick the best draft length directly. Finally, per Chen et al. (2023), the accept/reject scheme is distribution-preserving — the output is identical to plain target sampling, so this is purely a latency gain.

Worked examples

Strong draft — α = 0.80, γ = 4, c = 0.10

  1. E = 1 + 0.8 + 0.64 + 0.512 + 0.4096 = 3.3616 tokens/step
  2. cost = 4 × 0.10 + 1 = 1.40 target passes
  3. speedup = 3.3616 / 1.40 = 2.40×
  4. γ scan peaks near γ = 5 (E = 3.68928, cost = 1.5, speedup = 2.46×),
  5. so the tool suggests bumping γ from 4 to 5.

Weak draft — α = 0.60, γ = 3, c = 0.20

  1. E = 1 + 0.6 + 0.36 + 0.216 = 2.176 tokens/step
  2. cost = 3 × 0.20 + 1 = 1.60 target passes
  3. speedup = 2.176 / 1.60 = 1.36×
  4. Lowering γ to 2 is competitive (E = 1.96, cost = 1.4, speedup = 1.40×),
  5. which the γ scan surfaces — a positive but marginal setup.

Edge case — α = 0 (draft never accepted), γ = 5, c = 0.15

  1. E = (1 − 0) / (1 − 0) = 1 token/step — only the guaranteed target token
  2. cost = 5 × 0.15 + 1 = 1.75 target passes
  3. speedup = 1 / 1.75 = 0.57× — a net slowdown
  4. Verdict: don't enable. The draft adds cost but contributes no accepted tokens.

Frequently asked questions

Sources & references

The speedup and expected-tokens formulas were last cross-checked against Leviathan et al., ICML 2023 (arXiv:2211.17192) on 2026-07-08. The two worked examples above (2.40× and 1.36×) are reproduced exactly by the calculator.

Related tools

Rate this tool
Be the first to rate

Comments & feedback

Spotted a bug or want an improvement? Tell us — our team reviews every comment, and good ideas get built. Comments are public and anonymous.

Found a bug, edge case, or want to suggest an improvement?

Email me at [email protected] — most fixes ship within 24 hours.