FPRev: Revealing the Order of Floating-Point Summation by Numerical Testing

Peichen Xie, Yanjie Gao, Jilong Xue · OpenReview

Abstract

Accumulation-based operations are fundamental to modern computing, yet their internal execution orders are often undocumented. Because floating-point addition is non-associative, these hidden "accumulation orders" cause numerical discrepancies across different hardware and software environments. We present FPRev, a diagnostic tool that non-intrusively reveals these orders through numerical testing. By employing a "swamping" technique, FPRev identifies the underlying summation tree structure of black-box implementations. Our evaluation across popular libraries (NumPy, PyTorch) and hardware (NVIDIA Tensor Cores) demonstrates that FPRev can efficiently reverse-engineer complex, undocumented behaviors, facilitating the creation of bit-wise reproducible software.

Introduction: The Reproducibility Gap

In scientific computing and deep learning, the exact result of a summation depends on the order in which elements are added. Due to the non-associative nature of floating-point arithmetic—where $(a + b) + c \neq a + (b + c)$—different summation strategies lead to different rounding errors. While critical for reproducibility, these strategies are rarely documented for high-performance libraries or hardware accelerators like NVIDIA’s Tensor Cores. This lack of transparency creates a "black box" problem, where code moved between different CPUs or GPUs produces inconsistent results.

Methodology: The Swamping Trick

FPRev addresses this by treating implementations as black boxes and using numerical testing to deduce their internal logic. The core mechanism is "swamping": adding a very large number $M$ to a small number $\sigma$ such that $M + \sigma = M$ due to precision limits.

By constructing specific input arrays containing $M$, $-M$, and several $1.0$s, FPRev observes the final output to determine when $M$ and $-M$ cancelled each other out. This information allows the algorithm to find the Lowest Common Ancestor (LCA) of any two indices in the summation tree.

A complex 32-element summation tree revealed by FPRev, illustrating the intricate grouping of operations in optimized libraries.

The tool evolves from a naive brute-force approach to a polynomial-time algorithm (BasicFPRev) that builds the tree bottom-up. The full FPRev implementation further handles multi-term fused summations common in modern hardware.

Revealing Hardware and Software Secrets

FPRev was evaluated against industry-standard stacks, including NumPy, PyTorch, and JAX, across various Intel/AMD CPUs and NVIDIA GPUs.

One of the most significant findings involves NVIDIA Tensor Cores. While often perceived as standard units, FPRev revealed they utilize undocumented multi-way trees that vary by architecture: a 5-way tree on the V100, a 9-way tree on the A100, and a 17-way tree on the H100.

A simpler 8-element summation tree structure, demonstrating how different implementations can result in non-uniform, unbalanced accumulation orders.

In software libraries, FPRev identified that while basic operations like NumPy's sum() are consistent, more complex operations like matrix-vector multiplication vary based on CPU core counts, explaining why results drift when scaling across different server configurations.

Results and Scalability

FPRev is highly efficient, with a time complexity of $O(n^2 t(n))$. In practical tests, it revealed the summation tree for 8,192 elements in approximately 1 second—orders of magnitude faster than basic polynomial solutions. This efficiency makes it a viable tool for generating "reproducibility specifications." A developer can use the tree revealed by FPRev on a specific GPU to implement a matching software version, ensuring bit-wise identical results across platforms.

Conclusion

FPRev provides a much-needed lens into the hidden numerical logic of modern computing stacks. By reverse-engineering accumulation orders through non-intrusive testing, it empowers developers to diagnose reproducibility issues and verify the equivalence of different implementations. As hardware continues to evolve with specialized accelerators, tools like FPRev will be essential for maintaining numerical integrity in high-performance computing.

Summary updated

BibTeX
@inproceedings{xie2025fprev,
  author = {Peichen Xie and Yanjie Gao and Jilong Xue},
  title = {{FPRev: Revealing the Order of Floating-Point Summation by Numerical Testing}},
  booktitle = {USENIX ATC},
  year = {2025},
  url = {https://openreview.net/forum?id=aYWNoghCCG},
}
Figure