Wink Pings

Temperature 0 Is Not Deterministic: The Same Prompt Produces 80 Different Answers

A common LLM technical interview question: set temperature to 0, and the inference engine switches to greedy decoding, picking the token with the highest logit at each step; the same prompt should produce the same output every time. But in Thinking Machines' tests on Qwen3-235B, 1,000 runs produced 80 different answers. The difference comes from the computation of logits—floating-point addition is not associative, and other requests on the server change the order of summation.

A common LLM technical interview question: set temperature to 0, and the inference engine usually switches to greedy decoding, picking the token with the highest logit at each step. With the same prompt, it should in theory produce the same output every time.

In practice, it does not.

AI company Thinking Machines sent “Tell me about Richard Feynman” to Qwen3-235B with temperature 0, repeated it 1,000 times, and got 80 different complete answers.

The argmax that selects the highest logit is deterministic. The difference comes from how the logits are computed—if the numbers differ even slightly, argmax can select a different token.

The problem is that floating-point addition is not associative, and GPUs have limited precision.

fp16 (half-precision floating point) has only 11 significant bits. When numbers fall between 1024 and 2048, the fractional part is simply lost; 1024.4 gets rounded back to 1024.

Compute 1024 + 0.4 + 0.4:

From left to right: 1024 + 0.4 rounds back to 1024; adding another 0.4 still gives 1024.

Add the fractions first: 0.4 + 0.4 = 0.8, and 1024 + 0.8 rounds up to 1025.

The same expression gives two different results. An LLM executes billions of such additions per forward pass. If the summation order changes, the logits change too.

What causes the order to change?

A common guess: the completion order of GPU parallel threads is uncontrollable.

That guess is wrong. In a typical forward pass, the kernel has a fixed execution order for each summation. With the same inputs and the same batch size, the matrix multiplication result is bit-for-bit identical.

The real cause is other requests on the server.

The inference server combines requests from multiple users into a single batch. The kernel decides how to split the computation based on batch size:

  • Large batch: every GPU core is busy, each computes its own part, and it all finishes in one go.
  • Small batch: many cores sit idle, so the kernel splits long summations into chunks, distributes them, and finally merges the partial results.

Different splitting methods lead to different addition orders. Batch size depends on how many people are using the server at that moment.

The output you get may depend on how many strangers' requests are sharing the server with you at the same moment.

Concretely, in numbers: run the same prompt twice:

With batch size 8, the logits are:

  • “Queens” = 12.3417
  • “New” = 12.3415

argmax selects “Queens”.

With batch size 32, the rounding is slightly different:

  • “Queens” = 12.3414
  • “New” = 12.3416

argmax selects “New”.

The output only changes when the logits are very close. Once it changes, every subsequent token is generated on a different prefix.

In Thinking Machines' 1,000 runs, the first 102 tokens were completely identical. Starting with token 103, the outputs diverged: 992 runs output “Queens, New York”, and 8 runs output “New York City”.

There is a solution. Decouple the kernel's splitting method from batch size—for attention, that means fixing the chunk size. The cost is speed.

Thinking Machines reran with batch-invariant kernels, and all 1,000 runs were completely identical. On Qwen3-8B, the open-source inference framework vLLM took 26 seconds to process 1,000 requests; the deterministic version took 55 seconds; after optimizing the attention kernel, it dropped to 42 seconds.

Batch is not the only variable. Cache hits also change how the summation is split—some attention kernels process cached tokens separately from new tokens, and Thinking Machines handled this case separately.

This is an analysis posted by Daily Dose of Data Science. At the end of the article, it also mentions an article about four types of cache in LLM serving (KV, prefix, prompt, semantic), with a link in the original post.

The visualization accompanying the original post:

A commenter added a verification method that does not require reading the kernel source code: run the same prompt separately with batch size 1 and under load, and compare logprobs (log probabilities). The gap between the top 2 will reveal which tokens are nearly tied before the text changes.

发布时间: 2026-11-24 01:54