In school, we are taught that addition is associative: $(a + b) + c$ is always equal to $a + (b + c)$. In the world of computer science, this is a lie. Because floating-point numbers have finite precision, the order in which you add them changes the final result.
This "numerical drift" was once a niche concern for high-precision climate simulations. However, as we move into the era of massive parallelization and Large Language Models (LLMs), this tiny mathematical quirk has become a major roadblock for reproducibility, security, and verification.
The Source of the Drift
The root of the problem is rounding. When a computer adds two floating-point numbers of different magnitudes, it must align their binary points. This often causes the smaller number's least significant bits to be "shifted out" and lost.
As Ingo Mueller and colleagues explain in Reproducible Floating-Point Aggregation in RDBMSs, this means that the sequence of operations determines the cumulative rounding error. If you sum a list of numbers from left to right, you get one answer; if you sum them in a tree structure or from right to left, you get another.
In modern computing, we rarely control this order. To maximize speed, compilers and hardware backends reorder operations based on available resources. A program running on 4 GPUs will likely perform additions in a different order than the same program running on 8 GPUs, leading to divergent results.
The Butterfly Effect in LLMs
For a long time, the machine learning community assumed these tiny errors were "noise" that averaged out. Recent work by Jiayi Yuan and Xinheng Ding has shown this is not the case.
In Give Me FP32 or Give Me Death?, they demonstrate that even with "greedy decoding" (where the model always picks the most likely next word), changing the GPU count or batch size can lead to a 9% swing in accuracy. A microscopic rounding error in an early layer can slightly nudge the probability of a token, causing the model to choose a different word. Because LLMs are autoregressive, this single different word changes the context for all future tokens, leading to entirely different responses.
Exploiting the Soundness Gap
This lack of determinism isn't just a debugging headache; it's a security vulnerability. Attila Szász and others identified a "soundness gap" in No Soundness in the Real World. They found that neural network verifiers—tools meant to prove a model is safe—often assume perfect real-number math. By exploiting non-associativity, researchers can create "deployment-sensitive backdoors" that pass verification but trigger malicious behavior only on specific hardware.
Similarly, Jinjun Peng and Baishakhi Ray showed in Your Compiler is Backdooring Your Model that compilers can unintentionally (or intentionally) introduce these deviations during optimization, effectively altering the model's logic during the translation from source code to executable.
Strategies for Bit-Level Determinism
To solve this, researchers are developing "invariant" computational methods that force a specific order of operations regardless of the hardware.
- Fixed Reduction Trees: Ziyang Zhang and Jiayi Yuan proposed Tree-Based Invariant Kernels (TBIK) in Deterministic Inference across Tensor Parallel Sizes. TBIK enforces a rigid, hierarchical summation order that remains identical whether you are using one GPU or a hundred.
- Hybrid Precision: In Understanding and Mitigating Numerical Sources of Nondeterminism in LLM Inference, the authors introduce LayerCast. This approach stores weights in lower precision (like BF16) to save memory but performs critical accumulations in FP32. This higher "headroom" prevents many rounding errors from ever occurring.
- Software Libraries: Tools like RepDL by Shuo Chen and Pigeons.jl by Nikola Surjanovic provide standardized wrappers that ensure "Strong Parallelism Invariance." They guarantee that a simulation or training run will produce bit-for-bit identical results across any computing environment.
By treating floating-point non-associativity as a first-class constraint rather than a negligible error, these researchers are building a foundation for "numerical sovereignty"—the ability to trust that a mathematical model will behave exactly the same way, no matter where it is deployed.