
Setting temperature to zero is widely treated as a guarantee that an LLM will return identical outputs for identical prompts, yet the guarantee covers only the token-selection step. The math that produces the logits runs on parallel hardware where floating-point rounding, batch-dependent kernel behavior, and Mixture-of-Experts routing can each shift token probabilities between runs. When two candidate tokens sit within a rounding error of one another, tiny numerical drift flips the argmax, and the divergence compounds through autoregressive decoding. Developers debugging flaky tests, unstable evaluation runs, or reproducibility-sensitive pipelines need a precise map of where this variability originates. This article traces each layer of the inference stack — kernel numerics, batching, multi-GPU sharding, and serving infrastructure — and its specific contribution to non-determinism. It closes with a ranked assessment of the mitigations that actually work, from batch-invariant kernels to isolated batch-size-1 decoding, along with test designs that survive the residual variance.

The mathematical contract
Temperature scales the soft‑max that turns logits into a probability distribution. When T → 0 the distribution collapses onto the highest‑scoring token, and most libraries shortcut this case to greedy argmax decoding. Consequently, the only operation guaranteed to be deterministic is the selection of a token given a fixed set of logits【0†https://mbrenndoerfer.com/writing/why-llms-are-not-deterministic】.
What the contract does not cover
Logit computation is outside the guarantee
The logits are produced by parallel GPU kernels, mixture‑of‑experts routing, and batch‑dependent optimizations. Small floating‑point rounding differences or different kernel schedules can change a logit by a few µe‑9, enough to flip the argmax when two candidates are very close.
Other sampling knobs must be pinned
Greedy decoding assumes top_k=1 and top_p=1 (or top_p=0 in some stacks). If top_k > 1 or nucleus sampling (top_p < 1) remains active, the decoder may still sample among several tokens, re‑introducing randomness even with T = 0【2†https://mbrenndoerfer.com/writing/why-llms-are-not-deterministic】.
Tie‑breaking is implementation‑defined
When two tokens have nearly equal probabilities—e.g., 0.5000 vs. 0.4999—tiny numeric drift can make the lower‑probability token appear larger. Libraries resolve ties in different ways: deterministic ordering by token ID, adding a minuscule jitter, or, as OpenAI notes, internally raising the temperature slightly to force a break‑tie decision at exactly zero【0†https://mbrenndoerfer.com/writing/why-llms-are-not-deterministic】. This behavior varies by provider and version, so reproducibility cannot rely on a single rule.
Random seeds only affect stochastic samplers
A fixed RNG seed controls the randomness used by temperature, top‑k, top‑p, etc. With T = 0 and all other stochastic knobs disabled, the seed has no effect; it becomes relevant only when any source of randomness remains active【2†https://mbrenndoerfer.com/writing/why-llms-are-not-deterministic】.
Thesis
Setting temperature to zero makes the sampling rule deterministic—greedy argmax will always pick the token with the highest logit if those logits are identical. However, the upstream computation of logits is not guaranteed to be invariant across runs because of hardware parallelism, numerical rounding, and provider‑specific tie‑breaking. Understanding this distinction is the first step toward building reproducible LLM pipelines.

In IEEE‑754 floating‑point arithmetic the addition operator is not associative:
[(a + b) + c \neq a + (b + c)]
Each intermediate result is rounded to the format’s mantissa length (bf16‑≈7 bits, fp16‑≈10 bits, fp32‑≈24 bits). Consequently, the order in which a series of numbers is summed determines the low‑order bits of the final value.
Transformer inference performs billions of such reductions. Every matrix‑multiply (GEMM) and attention‑score accumulation reduces a set of products into a single accumulator. On GPUs the reduction order is chosen by the kernel implementation to maximise parallel throughput. Libraries such as NVIDIA CUTLASS employ tree‑ or warp‑level reductions that differ depending on batch size, tensor‑parallel degree, and the number of active SMs. Parallel reductions that split a sum across threads and later combine partial results therefore introduce a tiny, data‑dependent rounding error that varies from run to run.
The arXiv study Numerical Sources of Nondeterminism in LLM Inference (2506.09501) measured this effect empirically. By running identical prompts with the same weights while varying only the batch size and GPU count, the authors observed that the standard deviation of the top‑1 token probability grows monotonically with both dimensions. The trend is visible for all three precision modes (bf16, fp16, fp32), but the magnitude is largest for bf16 and fp16 because their shorter mantissas amplify rounding noise. Figure 2 of the paper shows a clear upward slope: a batch of 1 on a single GPU yields a sub‑(10^{-5}) probability variance, whereas a batch of 64 spread across eight GPUs can reach variance on the order of (10^{-3}) – (10^{-2}) link.
During greedy (temperature = 0) decoding the model selects the token with the highest logit. The rounding noise only matters when the gap between the top‑1 and top‑2 logits is comparable to the observed numerical drift. This situation is rare—most vocabularies have a clear margin—but when it occurs the argmax flips, the output prefix diverges, and every subsequent forward pass operates on a different hidden state. Because each step repeats the same accumulation pattern, the probability of further flips compounds, leading to exponential divergence over longer generations. Practically, reproducibility failures therefore surface first in long‑form tasks (e.g., essays, code generation) where many decoding steps provide repeated opportunities for drift.
It is important to separate measurement (the documented growth of probability variance with parallelism) from the interpretation that floating‑point non‑associativity alone explains all nondeterminism. Later sections will show how additional factors—such as batch‑dependent kernel heuristics, tensor‑parallel routing, and serving‑stack optimisations—contribute their own sources of variability, sometimes outweighing pure rounding error.

Recent work from the Thinking Machines Lab overturns the common “concurrency + floating‑point” story. Their experiments show that pure concurrency does not generate nondeterminism in the core matrix‑multiply primitive: running torch.mm(A, B) on CUDA a thousand times with identical inputs yields bitwise‑identical results each time. This rules out race conditions on atomic adds as the primary source of variance in LLM inference【https://thinkingmachines.ai/blog/defeating-nondeterminism-in-llm-inference/】.
The remaining and dominant factor is batch‑dependent kernel numerics. Most GPU kernels—particularly the highly optimized GEMM and attention kernels used in LLM forward passes—are written to exploit the batch dimension for parallelism. The reduction order inside a kernel (e.g., summing partial products) changes when the batch size changes, because the scheduler assigns different thread‑block configurations. Consequently, the floating‑point rounding performed on a single element varies with the surrounding batch, even though the element’s logical computation is unchanged.
Two concrete observations support this:
A prompt that appears stable in local unit tests becomes flaky in production not because the model changed, but because the batch context changed. When the serving layer groups requests to optimise throughput, the effective batch size can fluctuate from request to request, causing the underlying kernels to produce slightly different logits. This explains many “flaky test” reports where greedy decoding (temperature=0) still yields different strings.
batch_size=1 on a dedicated inference instance or disable dynamic batching for reproducibility tests.By recognizing batch‑dependent kernel numerics as the primary nondeterminism source, developers can move beyond generic “floating‑point randomness” explanations and apply concrete mitigations that keep LLM pipelines reproducible even under heavy load.

Running a model across several GPUs changes more than throughput; it changes the numerical path that produces the logits. When tensor parallelism splits a layer’s matrix‑multiply across devices, each GPU performs part of the reduction independently and the partial results are summed with a collective operation (e.g., NCCL All‑Reduce). Because floating‑point addition is not associative, the order of the reductions determines the last‑bit rounding of the summed values. Different tensor‑parallel degrees therefore generate subtly different logits even when the weights and the prompt are identical 【1†https://github.com/vllm-project/vllm/discussions/17166】.
| Source | How it affects reproducibility | Mitigation (if any) |
|---|---|---|
| Tensor‑parallel size – splitting a layer across p GPUs changes the reduction tree. A different p (e.g., 2 vs 4 GPUs) yields a different rounding order, so the argmax can flip when two token scores are close. | Pin the tensor‑parallel degree (and the exact GPU count) as part of the reproducibility configuration. | |
| GPU micro‑architecture – H100, H200, A100, T4 each implement BF16/FP8 accumulation differently. Even two cards of the same model may have driver‑level variations that affect low‑level kernels. | Record the exact GPU model, driver version, and CUDA/cuDNN library versions. | |
| Kernel implementation – cuDNN/CUTLASS kernels evolve across releases; a newer kernel may reorder GEMM tiles or use a different reduction scheme, altering rounding. | Freeze the CUDA toolkit and cuDNN versions; disable automatic kernel selection if possible. | |
| Collective‑operation library – NCCL vs. custom all‑reduce can produce different rounding because of distinct tree depths. | Use the same NCCL version and configure a deterministic all‑reduce algorithm (e.g., ring vs. tree consistency). | |
Serving mode – vllm serve batches incoming requests, whereas offline inference runs with batch 1. Batching changes the shape of intermediate tensors, which changes how kernels tile the work and thus the rounding order. | For strict reproducibility, run inference in a batch‑size‑1 mode or employ batch‑invariant kernels that guarantee the same reduction order irrespective of batch size. |
Empirical studies show that the standard deviation of the top‑1 token probability grows with both batch size and the number of GPUs, confirming that more parallel reductions increase numerical spread 【2†https://arxiv.org/pdf/2506.09501】.
--deterministic) where supported, or compile with -DDETERMINISTIC.Treat the parallelism configuration as a reproducibility parameter, not merely a performance tweak. Changing any of these dimensions—even swapping a single GPU for a newer model—will alter the floating‑point rounding path and can break the illusion of deterministic temperature=0 outputs.

In a Mixture‑of‑Experts (MoE) LLM, each token is first handed to a router that selects a small subset of expert sub‑networks (e.g., “top‑k” experts) to process the token. The router’s output is not a pure function of the token alone; it also depends on how many and which other tokens are present in the same inference batch.
Limited expert buffers – Every expert has a fixed capacity for how many tokens it can accept in a single forward pass. When several sequences are packed together, tokens compete for those slots. If the buffer of an expert is already full, the router will fall back to the next best expert, causing the same token to be dispatched to a different expert in a different batch. This makes the routing decision deterministic only at the batch level.
Batch composition as a hidden variable – Because production servers group incoming requests into dynamic batches for throughput, the routing for a given prompt can change depending on what other users’ prompts happen to be co‑batched. Even with temperature=0 (greedy sampling) and perfectly repeatable kernels, the model can produce different token sequences solely due to these routing shifts. The effect is described in multiple analyses of MoE non‑determinism, which note that “tokens from different sequences compete for the same expert resources, so the model is no longer deterministic at the sequence‑level”【1†https://www.guild.ai/glossary/non-deterministic-systems】【2†https://mbrenndoerfer.com/writing/why-llms-are-not-deterministic】.
Practical symptom – When an identical prompt is sent twice to a shared endpoint, the first request may be batched with a light traffic load, the second with a heavy load. The differing batch composition can push the token’s router assignment from expert A to expert B, leading to a different forward‑pass computation and a divergent final answer, despite a temperature of 0.
Not all MoE families suffer equally from this effect. Newer DeepSeek‑MoE models introduce a static hash‑of‑token‑ID routing for the early layers. The hash deterministically maps each token identifier to a fixed set of experts, eliminating the batch‑dependent argmax in those layers【3†https://www.thesoftwarefrontier.com/p/deepseek-v4-flash-the-cost-of-deciding】. However, this static routing is optional and only applies to specific layers; later layers still use learned gating and thus retain the batch‑level variability. Consequently, the guarantee of sequence‑level reproducibility remains an architecture‑specific property, not a universal MoE characteristic.
Because the root cause is the competition for expert slots, the only foolproof way to obtain sequence‑level determinism is to isolate the request:
In practice, teams that need reproducible results must treat MoE determinism as an infrastructure decision (budget for isolated serving or specialized kernels) rather than a simple sampling‑parameter tweak. The trade‑off between throughput and reproducibility is therefore intrinsic to MoE‑based LLM deployments.

OpenAI’s API exposes a seed argument as a best‑effort way to make a request reproducible, but the documentation explicitly warns that determinism is not guaranteed because backend changes can still alter the logits [OpenAI docs – seed][https://www.zansara.dev/posts/2026-03-24-temp-0-llm/]. In parallel, every response includes a system_fingerprint field that uniquely identifies the exact serving configuration (model version, hardware, driver, library stack, and batching policy). When the fingerprint differs between calls, the provider has swapped to a different deployment slice, and any prior reproducibility assumptions are void [OpenAI docs – fingerprint][https://www.zansara.dev/posts/2026-03-24-temp-0-llm/]. Because seed support varies by provider, model, and SDK version, it must be verified for each endpoint before relying on it.
Most commercial LLM services route incoming requests through a load balancer that distributes traffic across many GPU shards. These shards often differ in:
Even when the same model checkpoint is loaded on each shard, these hardware and software variations shift token‑probability distributions by tiny amounts. When two candidate tokens sit within a rounding margin, the arg‑max can flip, and the error compounds through the autoregressive loop.
An arXiv study (2408.04667) evaluated five major LLMs at temperature=0 across eight tasks. The authors observed 5–15 % accuracy swings across naturally occurring runs, and extreme cases where the best‑to‑worst gap reached 70 % (Mixtral‑8x7B on college‑math: 75 % vs. 3 %). Crucially, the same models ran deterministically when the authors executed Llama‑3‑8B on a local GPU without any serving optimizations, confirming that the nondeterminism originates in the inference‑engine layer rather than the model itself [arXiv 2408.04667][https://arxiv.org/html/2408.04667v5].
| Mitigation | Effect on nondeterminism | Trade‑off |
|---|---|---|
Pin a specific system_fingerprint and verify it unchanged across runs | Detects when backend has switched shards | May require extra API calls; occasional unavoidable changes |
| Force batch size = 1 (isolated decoding) | Removes continuous‑batch effects; makes inference deterministic on a single shard | Large latency and reduced throughput |
| Disable or bypass prefix‑caching and chunk‑prefill (where the provider permits) | Eliminates mutable internal buffers | Slower generation, higher memory use |
| Use providers that expose per‑shard seed control and allow static GPU selection | Eliminates seed‑fixable randomness | Often only available in enterprise tiers |
In summary, even with temperature=0 and a fixed seed, the serving infrastructure—particularly load‑balanced sharding and throughput‑oriented optimizations—introduces measurable output variance. Monitoring the system_fingerprint and, where possible, restricting traffic to a single, deterministic shard are the only reliable ways to preserve reproducibility in production pipelines.

| Tier | Lever | Determinism gain | Typical cost | Guarantees vs. best‑effort |
|---|---|---|---|---|
| 1 | Batch‑size‑1 / isolated single‑worker serving (disable concurrency) | Highest – the inference kernel sees a fixed batch context, eliminating batch‑dependent reduction order. | Throughput drops dramatically; latency increases roughly linearly with request rate. | Guarantee of bit‑wise reproducibility provided the rest of the stack is deterministic. |
| 2 | Kernel‑level controls – batch‑invariant ops, selective up‑casting, deterministic algorithms flag | Moderate – removes the main source of numerical drift (different reduction trees) and stabilises sensitive ops such as attention softmax and layer‑norm. | Performance hit of 5‑30 % depending on model size and hardware; need to compile or select specific kernels. | Best‑effort: still dependent on hardware‑specific implementations (e.g., cuDNN) but variance is usually bounded to < 1e‑6 in logits. |
| 3 | Environment pinning – identical GPU model, driver, CUDA/cuDNN versions, library stack, and a fixed model revision | Low‑to‑moderate – guarantees that any remaining nondeterminism comes from the same code path, making debugging reproducible. | Administrative overhead; may require containerisation or dedicated hardware pools. | Best‑effort: does not eliminate floating‑point rounding differences caused by batch size or kernel selection. |
| 4 | Sampling hygiene – temperature=0, top_k=1, top_p=1; seed only matters when temperature > 0 | Minimal – the sampling step is already deterministic; the main variability lies upstream in the logits. | No performance impact. | Best‑effort: essential for clarity but does not address the core source of drift. |
Running a model with a batch size of 1 and a single worker removes all dynamic scheduling effects. vLLM’s reproducibility guide explicitly recommends disabling multiprocessing in offline mode to obtain deterministic scheduling, and notes that “isolated worker / no concurrent jobs” is the most reproducible configuration, albeit slower 【0†url】. In online serving this is the only way to guarantee that the same token order is produced regardless of request interleaving.
Two complementary approaches are common:
PyTorch’s torch.use_deterministic_algorithms() flag can enforce deterministic kernels across the stack, but the documentation warns of a noticeable performance penalty 【1†url】.
Exact matching of GPU architecture, driver, CUDA, and library versions eliminates version‑specific numerical paths. Even with identical software, minor firmware differences can alter reduction ordering; therefore many teams freeze the full container image and enforce a single GPU SKU for reproducibility tests.
When temperature=0, the decoding rule is simply “pick the argmax”. Setting top_k=1 and top_p=1 removes any stochastic sampling path, and a seed is irrelevant because no random numbers are drawn. This hygiene is required for clarity but does not solve the upstream floating‑point nondeterminism that the previous tiers target.
Every optimization that increases throughput—dynamic batching, multi‑GPU sharding, or aggressive bf16 kernels—reintroduces a source of numeric variance. No major provider currently promises bit‑wise identical outputs across runs; the closest practical guarantee comes from Tier 1 combined with deterministic kernels (Tier 2). In practice, most production pipelines adopt a mixed strategy: use isolated decoding for critical evaluation runs (Tier 1), and batch‑invariant kernels with selective up‑casting for high‑throughput services (Tier 2), while keeping the environment pinned (Tier 3) and maintaining clean sampling flags (Tier 4). This hierarchy balances reproducibility against cost in a predictable, ranked manner.

When temperature = 0, the token‑selection rule is deterministic, but the preceding numerical pipeline is not. Floating‑point rounding, parallel GPU kernels, and batch‑dependent routing can shift logits by a few bits, causing occasional tie‑breaks that diverge after a few steps【1†url】. Because bitwise reproducibility is infeasible on hosted APIs and expensive to guarantee on‑prem, test suites must tolerate a small amount of variance instead of demanding exact string matches.
Switch to property‑based assertions
Statistical repeat runs
Bound generation length
max_new_tokens reduces the number of decoding steps where drift can accumulate. The authors of the 2408.04667 study explicitly recommend a conservative token ceiling to keep variance manageable【2†url】.Prefer variability‑tolerant regression testing
When multiple LLM components are composed (e.g., retrieval → generation → post‑processing), each stage’s nondeterminism multiplies, rapidly widening the overall variance envelope. Consequently, leaderboard differences that fall within this envelope are statistically indistinguishable and should be treated as noise.
By embracing property‑based checks, statistical repeat testing, and transparent reporting of configuration‑aware metrics, developers can build robust test and evaluation pipelines that remain reliable despite the inherent nondeterminism of modern LLM inference.