Reproducible AI Requires Reproducible Randomness

📅 2026-09-22
📈 Citations: 0
✨ Influential: 0
📄 PDF
🤖 AI Summary
研究探讨了通过转移伪随机数生成器的完整内部状态来确保跨库一致性和可移植性的问题,使用Mersenne Twister和Philox在四个Python生态系统中进行实验,提出实现保真度是科学重现性的必要条件。
📝 Abstract
Pseudorandom number generators (PRNGs) constitute indispensable computational tools across multiple scientific domains, including Monte Carlo simulations, stochastic computing, and artificial intelligence (AI). The reproducibility of such applications critically depends on the ability of PRNG implementations to generate identical sequences across software environments when initialized from the same internal state. These algorithms enable the simulation of stochastic processes while providing deterministic and repeatable behaviour, thereby facilitating reproducible experiments. Modern PRNG implementations may be initialized through either a seed or, more accurately, an initial state that exceeds the capacity of a conventional integer seed. However, reliance on a simple seed alone frequently proves insufficient to ensure consistent program execution traces across different implementations. A natural assumption is that transferring the complete internal state of a generator should guarantee identical outputs regardless of the software library used. This study examines the validity of this assumption by investigating whether complete initial states can ensure cross-library fidelity and portability of PRNG streams. We focus on two widely deployed generators, Mersenne Twister and Philox, and evaluate their implementations across four major Python ecosystems-Random, NumPy, PyTorch, and TensorFlow. We compare the sequences produced by these implementations against those generated by the original reference algorithms under identical initialization conditions. Our results demonstrate that reproducibility cannot be assumed from PRNG state transfer alone, even when implementations claim to follow the same underlying algorithm. While fidelity was successfully achieved for several implementations, significant discrepancies were observed in others. Most notably, the Philox implementation in PyTorch exhibits fundamental incompatibilities with the reference algorithm, preventing exact reproduction of generator outputs across environments. These findings challenge the common expectation that access to a full internal state of a PRNG is sufficient to ensure reproducibility across software stacks. They further highlight that implementation-specific design choices can introduce hidden barriers to experimental replication, particularly in AI workflows that rely on multiple frameworks. This work shows that implementation fidelity of a PRNG is a necessary condition for scientific reproducibility and makes two primary contributions. First, it identifies practical guidelines for achieving reliable PRNG usage and reproducibility within the Python scientific and AI ecosystem. Second, it evaluates the extent to which cross-library portability and fidelity can be recovered through user-level techniques, without requiring modifications to library source code.
Problem

Research questions and friction points this paper is trying to address.

Pseudorandom number generators
Reproducibility
Cross-library fidelity
Python ecosystems
AI workflows
Innovation

Methods, ideas, or system contributions that make the work stand out.

Pseudorandom Number Generators
Reproducibility
Cross-library Fidelity
Implementation-specific Design
Python Ecosystem
🔎 Similar Papers
No similar papers found.
💼 Related Jobs
No related jobs found.
A
Anthony Bertrand
Université Clermont Auvergne, Clermont Auvergne INP, CNRS, LIMOS, F-63000 Clermont–Ferrand, France
Tom Schmitt
Tom Schmitt
Université Clermont Auvergne, Clermont Auvergne INP, CNRS, LIMOS, F-63000 Clermont–Ferrand, France
Engelbert Mephu Nguifo
Engelbert Mephu Nguifo
professeur d'informatique, University Clermont Auvergne
artificial intelligenceformal concept analysisdata miningmachine learningbioinformatics
D
David R.C. Hill
Université Clermont Auvergne, Clermont Auvergne INP, CNRS, LIMOS, F-63000 Clermont–Ferrand, France