Why an AI Can Give Different Answers Even at Its Most Predictable Setting (Temperature 0)
Why an AI Can Give Different Answers Even at Its Most Predictable Setting (Temperature 0)
Temperature 0, the setting that makes a model always pick its top choice, removes sampling randomness, not floating-point and batching randomness (both explained below). The model still picks the most likely token (chunk of text) at each step. But the numbers it picks between are computed fresh on every request. Tiny differences in that arithmetic can flip a near tie, two choices with almost equal scores. One flipped token changes everything after it.
New to these terms? Every word is explained in the series glossary.
The short version
Think of a photo finish. Temperature 0 is the rule that says the fastest runner wins. Floating-point arithmetic is the camera. If the camera measures the two runners a hair differently from one race to the next, a different runner wins, even though the rule never changed. The rule is deterministic (same result every time). The measurement is not.
What you expect, and what actually happens
You send the same prompt, the text you send in, twice at temperature 0 and expect the same answer twice. At every step the model takes the token with the highest score. No dice are rolled. So the answer should be identical.
Often it is. Then one day it is not, and a word changes halfway through. A test that passed yesterday fails today, with the same prompt, the same model, and the same settings.
The most striking measurement is from Thinking Machines Lab. In September 2025, Horace He and colleagues sent "Tell me about Richard Feynman" to Qwen3-235B-A22B-Instruct-2507, a very large open model, one thousand times at temperature 0, asking for one thousand tokens each time. They got 80 unique completions, the most common appearing only 78 times. All one thousand were identical for the first 102 tokens. At token 103, 992 continued with "Queens, New York" and 8 with "New York City". From there they diverged into 80 different answers.
That is the primary source for the figure, their post "Defeating Nondeterminism in LLM Inference", published 10 September 2025. Qwen3-235B is a mixture-of-experts model, which matters for cause 3 below.
Cause 1: floating-point addition is not associative
This is the root of everything, and you can check it yourself. Floating-point addition is not associative. In plain words, the order you add numbers in changes the answer. Floating point is how computers store decimals, with limited precision. Rounding happens at the last digits.
Here it is in Python 3, using ordinary 64-bit floats.
pythona, b, c = 1e16, 1.0, 1.0 print((a + b) + c) # 1e+16 print(a + (b + c)) # 1.0000000000000002e+16 print((a + b) + c == a + (b + c)) # False
Adding 1.0 to 1e16 does nothing, because 1e16 has no room left to record a change of 1. But adding 1.0 and 1.0 first gives 2.0, and adding that to 1e16 does register.
The same thing happens on the kind of sums a model actually does, adding 100,000 random float32 numbers in three different orders. Float32 is 32-bit floating point, the precision much model math runs in. Each addition was rounded back to float32, the way a GPU kernel (a small program on the graphics chip) would round it.
pythonimport struct, random, math def f32(x): return struct.unpack('f', struct.pack('f', x))[0] random.seed(7) vals = [f32(random.uniform(-1, 1)) for _ in range(100000)] def add32(a, b): return f32(a + b) s = 0.0 for v in vals: s = add32(s, v) print('forward :', s) s = 0.0 for v in reversed(vals): s = add32(s, v) print('reverse :', s) def pairwise(xs): while len(xs) > 1: xs = [add32(xs[i], xs[i + 1]) if i + 1 < len(xs) else xs[i] for i in range(0, len(xs), 2)] return xs[0] print('pairwise:', pairwise(list(vals))) print('exact :', math.fsum(vals))
The output:
forward : -192.0651092529297
reverse : -192.06532287597656
pairwise: -192.0642547607422
exact : -192.0642422089163
Three ways of adding the same 100,000 numbers gave three different answers. The differences are tiny. But a model does billions of such sums in every forward pass, and greedy decoding only needs one near tie to flip. Greedy decoding means always picking the highest scoring token.
Most of the time the winning token wins by a large margin, and tiny noise cannot change the result. But sometimes two tokens have almost the same score. Then a difference in the last digits decides the winner. In the Feynman experiment the first 102 tokens had clear winners, so nothing flipped. At token 103 the two continuations were close enough that the noise decided, and eight runs in a thousand flipped. Then the flip propagated, because every token after a flip is generated from a different prefix. A prefix is everything generated so far.
Cause 2: batching changes the arithmetic
Floating-point noise alone does not explain why the same prompt gives different answers. If the model added numbers in the same order every time, the noise would be identical too. Something has to change the order.
sequenceDiagram autonumber participant Y as Your request participant S as Server participant K as GPU kernel Note over Y,K: Same prompt, temperature 0, two times Y->>S: Run 1, quiet moment S->>K: Small batch K->>K: Sum split one way K-->>Y: Top token wins clearly Y->>S: Run 2, busy moment S->>K: Bigger batch, other users K->>K: Sum split another way Note over K: Different order, different last digits K-->>Y: A near tie flips, text diverges
Diagram: Same prompt, two moments: a different batch splits the sums differently.
That something is batching. A server groups your request with other people's requests. A batch is that group. The batch size depends on how many other people are sending requests at that moment. The way a GPU kernel splits a sum depends on the batch size. A kernel is a small program that runs on the GPU. A bigger batch splits the work differently, which changes the order of addition, which changes the last digits, which can flip a near tie.
This is the central finding of the Thinking Machines Lab post. The simple story says GPU concurrency makes floating point random. Their finding says the opposite. The same kernel on the same input returns the same bits every time. What changes is the batch. Your output depends on who else is online when you send your request.
They demonstrated the fix as well. With batch-invariant kernels, all 1,000 Feynman completions came out identical. Batch-invariant means the result does not depend on the batch. The cost was speed. On Qwen3-8B, generating 1,000 sequences of 90 to 110 tokens, default vLLM, a popular serving program, took 26 seconds. The first deterministic version took 55 seconds. An improved attention kernel (attention is the step where the model looks back at earlier tokens) brought it down to 42 seconds. Determinism is available. With the improved kernel it costs roughly 1.6 times the runtime in that test. That is 42 seconds against 26.
A local server with one request at a time and no prompt cache is far more repeatable. A prompt cache reuses stored work from earlier prompts. Turning it off removes one more source of variation.
flowchart TD A[Same prompt at temperature 0] --> B[Server groups it with other requests] B --> C[Batch size depends on who is online] C --> D[Kernel splits each sum by batch size] D --> E[Order of addition changes] E --> F[Float addition not associative: last digits change] F --> G{Top two tokens a near tie?} G -- No --> H[Same token wins] G -- Yes --> I[Winner can flip] I --> J[New prefix: every later token differs] H --> K[Next token] K --> G
Diagram: From busy server to different answer: batch size, addition order, last digits, a flipped near tie.
Cause 3: mixture-of-experts routing can shift
Qwen3-235B is a mixture-of-experts model. A mixture-of-experts model has many small sub-networks called experts. Only some experts are active for each token. Which experts are chosen depends on routing scores, computed from the same floating-point arithmetic as everything else. If batch neighbours shift the arithmetic slightly, routing can shift too. A different expert for one token means a different computation, which can flip a near tie.
The mechanism fits the batching story above, but no published experiment found for this article isolates routing from the rest of the arithmetic. Treat it as a suspected cause, not a proven one.
Does QK-norm change this?
A common follow-up question is whether QK-norm touches the problem. My answer is no. This is reasoning from what QK-norm does, not a tested claim. No source found for this article tests QK-norm against batch invariance.
QK-norm normalises the query and key vectors inside attention, which helps training, the phase where the model learns, stay stable. Normalising means rescaling the numbers to a standard range. It does not change how a GPU kernel splits a sum across a batch, and it does not make the arithmetic batch-invariant. It might make flips rarer by keeping scores better behaved. But it cannot remove the mechanism. As long as the reduction order depends on batch size, temperature 0 can still drift. A reduction is the step where many numbers are added together into one.
What actually helps
Four things help, each with honest limits.
Fixed seeds help where they are offered. A seed is a starting number for random sampling. OpenAI documents seeded requests as mostly deterministic, with a warning that a system fingerprint change can shift output. The system fingerprint is an ID for the backend setup serving your request. A seed controls sampling randomness. It does not control the batching arithmetic. Use it, but do not trust it alone.
Single-request runs help. If you control the server, send one request at a time with no other traffic and the prompt cache off. That removes the batch variance. It is slow and wasteful, but it is the most reliable option today.
Batch-invariant kernels help where they exist. vLLM has a beta option, the environment variable (a named setting programs read when they start) VLLM_BATCH_INVARIANT set to 1, which makes results independent of batch size at a performance cost. SGLang, another serving framework, has a deterministic inference flag (command option), --enable-deterministic-inference. Neither flag was tested for this article. Check the framework docs before you use them, because beta flags move.
Designing evals that tolerate variation helps most. An eval is a test you run on a model. If your test asserts byte-identical output, it will fail for reasons that have nothing to do with your code. Assert structure instead. Check that the JSON (a structured data format) parses, that the required fields are present, and that the answer is semantically right. Semantically right means the meaning is correct, even if the wording differs. Run the same prompt several times and require it to pass most of the time. That is how you build a test that survives the arithmetic.
| Fix | What it controls | Limit |
|---|---|---|
| Fixed seed | Sampling randomness | Does not control batching arithmetic |
| Single-request runs | Batch variance | Slow, wasteful, not possible on shared APIs |
| Batch-invariant kernels | Reduction order | Beta, costs speed, not everywhere |
| Tolerant evals | Your test, not the model | Accepts variation instead of removing it |
Try this
Send the same prompt 20 times at temperature 0 through one API (the way programs send requests to a model service) and count distinct outputs. Pick a prompt with a long answer, because flips need time to appear. The Feynman experiment needed 102 tokens before the first flip. If all 20 come back identical, try again at a busy time of day. Record the model name, the date, and the time. No API result is reported here, so run it yourself.
What to read next
This is the third article in the inference and serving cluster, after the KV cache article and the speculative decoding article.
FAQs
Does temperature 0 make an LLM deterministic? No. It makes decoding greedy, so no sampling randomness is added. It does not make the arithmetic identical between runs.
Why did the same prompt give me a different answer? The batch changed, most likely. Your request was grouped with different neighbours, the kernels split their sums differently, and a near tie flipped.
What is batch invariance? It is the property that one request gets the same result whatever else is in the batch with it. Most serving kernels do not have it.
Does setting a seed fix it? Only partly. A seed controls sampling randomness, which temperature 0 already removes. It does not control the batching arithmetic.
Does QK-norm make temperature 0 deterministic? No. It stabilises training by normalising queries and keys. It does not make kernels batch-invariant.
Sources
- He, Horace, and Thinking Machines Lab, "Defeating Nondeterminism in LLM Inference", 10 September 2025. https://thinkingmachines.ai/blog/defeating-nondeterminism-in-llm-inference/ Checked 14 November 2026. Primary source for the Qwen3-235B figure.
- OpenAI API documentation on seeded chat completions, checked 14 November 2026. Seeded requests are described as mostly deterministic.
- SGLang team, "Towards Deterministic Inference in SGLang and Reproducible RL Training", 22 September 2025. Source for the --enable-deterministic-inference flag.
- vLLM documentation on batch invariance, checked 21 November 2026. Source for the VLLM_BATCH_INVARIANT=1 beta option.
