It’s late, you’ve had a long day of debugging, and you just want your model outputs to be consistent. You’re using greedy decoding because, mathematically, it’s a pure function: same weights, same prompt, same tokens. Right?
Well, the authors of Vega-Fafnir have some unsettling news for your late-night peace of mind. In the world of finite-precision hardware, "identical" isn't always identical.
TL;DR
Greedy decoding is supposed to be deterministic, but tiny rounding errors in bfloat16 mean that changing how you run a model—like using speculative decoding, batching, or even just padding—can lead to completely different text. This paper shows that speculative decoding, often promised as "lossless," actually diverges from standard decoding in 60% of cases, and explores the high cost of trying to fix this numerical non-determinism.
What Problem Does This Paper Address?
In theory, greedy decoding (always picking the token with the highest probability) should produce the same result every time. However, modern serving engines use various tricks to go faster:
- Speculative Decoding: Guessing multiple tokens and verifying them all at once.
- Batching: Processing multiple prompts together.
- Padding: Adding "empty" tokens to make sequences fit specific hardware-friendly shapes.
Each of these changes the "shape" of the matrix operations on the GPU. Because floating-point math isn't perfectly associative (adding $A+B+C$ can give a slightly different result than $C+B+A$ due to rounding), these different shapes produce tiny variations in the output "logits" (the raw scores for each token). If the top two tokens are very close in score, these tiny "rounding noises" can flip the winner, causing the model to take a different path entirely.
The authors set out to measure how often this happens and whether we can actually fix it without losing all our hard-won speed gains.
Methods
The researchers used Qwen3-0.6B (and its 1.7B sibling) as their test subjects, running them in bfloat16 precision. They established a "Width-1 Reference"—the standard, one-token-at-a-time decoding—and compared it against several common serving paths:
Key experimental setups included:
- 4-token verification: A speculative decoding setup.
- Margin Gates: A mechanism that checks the gap between the top two tokens. If the gap is too small (below a calibrated "noise bound"), the system falls back to a safer, slower decoding method.
- Cache Rebuilding: When a fallback occurs, the system re-calculates the Key-Value (KV) cache for previous tokens to ensure no rounding noise has "poisoned" the history.
- Fixed-Shape Decoding: Forcing every computation to have the same matrix shape by using filler tokens, ensuring rounding is at least consistent, if not "correct."
Datasets
The study evaluated these paths across several benchmarks to see if the "noise" was universal:
- GSM8K: Grade school math word problems (used for both calibration and evaluation).
- ARC (Easy & Challenge): Multiple-choice science questions.
- MMLU & HellaSwag: Used as "shifted" distributions to see if the noise bounds calibrated on math problems would hold up for general knowledge and common sense.
Key Insights and Ideas
- The "Identical" Speculation is a Myth: Speculative decoding is mathematically identical to the target model, but numerically distinct. On a real GPU, "lossless" speculation is often a lie.
- The KV Cache is "Poisoned": The noise doesn't just happen in the current step. When you verify multiple tokens at once, the values written into the KV cache are slightly different than if you wrote them one by one. This "cache noise" persists and can cause future tokens to diverge even if the current step is done carefully.
- The Logit Margin is the Key: Divergences almost exclusively happen when the gap between the top-1 and top-2 tokens is very small. The authors found a "noise bound" of 0.375; if the gap is larger than this, the rounding noise is almost never strong enough to flip the result.
- Consistency vs. Correctness: You can achieve perfect reproducibility between speculative and non-speculative paths by using Fixed-Shape Decoding. However, this doesn't mean you match the "standard" reference; it just means both paths are equally (and consistently) "noisy."
Key Results
The numbers are surprisingly high. After generating just 128 tokens:
- 60% of prompts diverged when using 4-token speculative verification.
- 68% of prompts diverged simply by changing the padding.
- 69.3% of prompts diverged when batching four prompts together.
As the model generates more text, the probability of staying "identical" to the reference drops steadily. There is no "safe" zone; every new token is another roll of the numerical dice.
To achieve 0% divergence, the authors had to "rebuild" the cache during fallbacks, which cost a staggering 7.2 model passes per token—effectively negating the speed benefits of speculative decoding.
Limitations and Future Work
The authors are careful to note that these results are a snapshot of a specific ecosystem: one GPU type (RTX 4090), one software stack (PyTorch/Transformers), and relatively small models.
Larger models might have wider logit gaps (making them more robust) or different reduction sizes (changing the noise profile). Furthermore, this study focused strictly on greedy decoding. In the more common world of sampled decoding, this rounding noise is likely drowned out by the intentional randomness of the sampler, but for researchers relying on greedy benchmarks for "reproducible" science, Vega-Fafnir is a loud wake-up call.
Summary updated