GO TO A SECTION

↑ ↓ to navigate · Enter to openExplore all sections →
FDEInterviews logo
NeurIPS 2025

Understanding and Mitigating Numerical Sources of Nondeterminism in LLM Inference

Greedy decoding is not deterministic in practice. Changing batch size, GPU count or GPU type gave a reasoning model a 9% accuracy spread on AIME'24 in bfloat16; FP32 math removed it.

Breakdown by FDE Interviews · 11 min read · Updated

About the original · 2025
AUTHORS
Yuan, Li, Ding, Xie, et al.
FROM
Rice University, University of Minnesota Twin Cities, Adobe
PUBLISHED
Jun 2025 · NeurIPS 2025
CITED BY
99Semantic Scholar · Nov 2026
IN THIS BREAKDOWN · 10 SECTIONS

You can read 22% of this breakdown.

01

The paper in one minute

If you set temperature to zero, a language model should pick the most likely token every time and produce the same answer every time. Evaluations rely on this: they run greedy decoding once and report the score. This paper shows that the assumption breaks as soon as the serving setup changes. With the same prompt and seed, changing the evaluation batch size, the number of GPUs or the GPU model changed the outputs, and for reasoning models it changed the accuracy.

The cause is ordinary floating-point arithmetic. Addition in finite precision is not associative: (a + b) + c can differ from a + (b + c). Matrix multiplications and reductions on GPUs add numbers in orders that depend on the batch size, how work is split across GPUs, and the kernel the hardware picks. In bfloat16, which keeps only 8 bits of precision, those small differences are large enough to change a logit. When the top two tokens are close, a tiny change flips the greedy choice, and from that token on, the two runs are generating different text. Reasoning models, which write thousands of tokens of chain of thought, give that flip thousands of chances to happen.

The authors measured it across 12 configurations: two GPU types (NVIDIA L40S and A100), two GPU counts and three batch sizes, in bfloat16, float16 and float32. For DeepSeek-R1-Distill-Qwen-7B on AIME'24, accuracy had a standard deviation of 9.15% in bfloat16, 5.74% in float16 and zero in float32. Output length varied with a standard deviation of over 9,000 tokens in bfloat16. Non-reasoning models varied far less.

Float32 everywhere fixes it but doubles memory and time. The proposed LayerCast stores linear-layer weights in bfloat16 and casts each one to float32 just before using it, so all arithmetic is float32. It matched float32's determinism and used 34% less memory than full float32 inference.

THE IDEA, VISUALLY
SAME NUMBERS, TWO ORDERS (TABLE 2) a = 0.0016, b = 0.0027, c = 1.0 (a+b)+c (a+c)+b float32 1.0043 1.0043 bfloat16 1.0078 1.0000 same differ bfloat16 keeps 8 significant bits, float32 24. Batch size, GPU count and kernel choice change the order of additions inside matmuls, so logits differ slightly between setups. ONE FLIP CHANGES THE REST (GREEDY DECODING) chance two runs stay identical over L tokens, per-token flip 1e-4 98% 90% 82% 61% 37% 0 5,000 10,000 output tokens (our model, not measured) AIME'24 ACCURACY SPREAD, 12 CONFIGS (TABLE 3) standard deviation; DeepSeek-R1-Distill-Qwen-7B, greedy bfloat16 9.15% float16 5.74% float32 0.0% 9.15% of 30 questions = about 2.7 questions OUTPUT LENGTH SPREAD, AIME'24 (TABLE 4) R1-Distill-Qwen-7B 9,190 R1-Distill-Llama-8B 9,349 Qwen2.5-7B-Instruct 211 Llama-3.1-8B-Instruct 119 tokens, bfloat16; float32 gives 0 for all four LAYERCAST (SECTION 4) weights stored in bfloat16, upcast to float32 one layer at a time; all math in float32 near-float32 determinism, 34% less memory arXiv 2506.09501, NeurIPS 2025
Floating-point addition is not associative, and bfloat16 keeps only 8 bits of precision, so the same logits computed with a different reduction order can differ slightly. Under greedy decoding, one flipped token sends a long reasoning chain down a different path; the longer the output, the more likely two runs diverge.
Research notes: the problem, approach and results
9.15%

standard deviation of AIME'24 accuracy across 12 configurations, greedy decoding, bfloat16 (Table 3)

0

the same standard deviation in float32 for DeepSeek-R1-Distill-Qwen-7B (Table 3)

34%

less memory for LayerCast than full float32 inference, with near-float32 determinism (Section 4)

THE PROBLEM

Evaluations assume greedy decoding is deterministic and that one run per configuration is enough. In practice, the same model, prompt and seed can produce different answers when the batch size, number of GPUs or GPU model changes, which makes benchmark numbers hard to reproduce.

THE IDEA

Measure it systematically: run greedy and sampled decoding for reasoning and non-reasoning models across 12 runtime configurations (2 GPU types, 2 GPU counts, 3 batch sizes) in bfloat16, float16 and float32, and track accuracy, output length, where outputs first diverge, and the spread of top-1 probabilities. Then propose LayerCast: weights stored in bfloat16 but every computation done in float32.

THE RESULT

In bfloat16 with greedy decoding, DeepSeek-R1-Distill-Qwen-7B's AIME'24 accuracy had a 9.15% standard deviation across the 12 configurations and its output length a standard deviation of about 9,190 tokens; in float32 both were zero. LayerCast matched float32's stability while using 34% less memory than full float32.

02

Why it matters to an FDE

Every FDE eventually hears "we set temperature to zero, so why did the answer change?" This paper is the explanation and the guide to what to do about it.

Your evaluation numbers depend on your serving setup. An eval run on 1 GPU at batch 8 and a production deployment on 4 GPUs at batch 64 can disagree, even with greedy decoding. When comparing a customer's numbers with a vendor's or a paper's, record precision, GPU type and count, and batch size alongside the score.

Single runs are not enough for reasoning models. A one-run accuracy on a 30-question benchmark like AIME'24 can move by several questions just from configuration. Report the mean and spread over several configurations or seeds, and treat small differences between models as noise.

Flaky regression tests have a root cause. If an LLM regression test that compares outputs exactly fails intermittently, numeric nondeterminism is a likely cause. Either pin the configuration and use float32 for the test, or compare outputs semantically instead of byte by byte.

THE FULL BREAKDOWN

Understand the mechanism. Try it on a real problem.

Unlock this breakdown and 290 more papers.

Premium opens every paper in full, plus every answer, concept, course and guide on the site. One payment for six months of access.

6 months · One payment · No auto-renewal

Get Premium · ₹2,000 / $25
  • ◇1 architecture diagram
  • </>1 runnable code experiment
  • ▦2 results tables
  • ?5 interview questions with answers
  1. 03Key takeaways

    The mechanism, the measurements, what makes it worse, LayerCast and two misreadings

    Free account
  2. 04How it works

    Floating-point formats, the 12-configuration design, the metrics, ablations and LayerCast

    Premium
  3. 05The numbers that matter

    Accuracy and length spread by model and precision, divergence, and LayerCast's cost

    Premium
  4. 06Try it yourself

    Reproduce the rounding tables, flip a logit by reduction order, model divergence over length

    Premium
  5. 07Where it breaks

    Scope of models and hardware, cost of float32, batch-invariant alternatives and wording

    Premium
  6. 08Using it on a deployment

    How to make evaluations reproducible and production comparisons fair

    Premium
  7. 09Interview angles

    Five questions this paper prepares you for, with answer hints

    Premium
Back to the paper library →