Defeating Nondeterminism in LLM Inference - Thinking Machines Lab
Reproducibility is a bedrock of scientific progress. However, it’s remarkably difficult to get reproducible results out of large language models. For example, you might observe that asking ChatGPT the same question multiple times provides different results. This by itself is not surprising, since getting a result from a language model involves “sampling”, a process that converts the language model’s output into a probability distribution and probabilistically selects a token. What might be more surprising is that even when we adjust the temperature down to 0This means that the LLM always chooses the highest probability token, which is called greedy sampling. (thus making the sampling theoretically deterministic), LLM APIs are still not deterministic in practice (see past discussions here, here, or here). Even when running inference on your own hardware with an OSS inference library like vLLM or SGLang, sampling still isn’t deterministic (see here or here).
Reproducibility is a bedrock of scientific progress. However, it's remarkably difficult to get reproducible results out of large language models. For example, you might observe that asking ChatGPT the same question multiple times provides different results. This by itself is not surprising, since getting a result from a language model involves “sampling”, a process that converts the language model’s output into a probability distribution and probabilistically selects a token. What might be more surprising is that even when we adjust the temperature down to 0 This means that the LLM always choo
saved by
- Winnie Xu
- Pranav
- Elizabeth Qiu
- Sahil Patel
- Tasha Pais
- Ratan Kaliani
- HudZah
- Julian Quevedo
- Freeman Jiang
- Samuel Lo
- Karthik Suresh
- Anosha Rahim
related reading
- Non-determinism in GPT-4 is caused by Sparse MoE - 152334H152334h.github.io
- How can LLM RL Work Despite Information-Theoretic Inefficiencyberen.io
- LLM Inference Performance Engineering: Best Practices | Databricks Blogdatabricks.com
- Non-Determinism of “Deterministic” LLM Settingsarxiv.org
- ⭐️ Fast LLM Inference From Scratchandrewkchan.dev
- [2510.13786] The Art of Scaling Reinforcement Learning Compute for LLMsarxiv.org
- [2506.09501] Understanding and Mitigating Numerical Sources of Nondeterminism in LLM Inferencearxiv.org
- Transformers Inference Optimization Toolset | AstraBlogastralord.github.io
- Fast Inference from Transformers via Speculative Decodingarxiv.org
- Productizing Large Language Modelsblog.replit.com
- All About Transformer Inferencejax-ml.github.io
- Taking LLMs Seriously (As Language Models) — LessWronglesswrong.com