arXiv論文メモ
新着一覧
cs.AI · 査読状況未確認

乱数生成器の状態を移しても再現性は保証されない

Reproducible AI Requires Reproducible Randomness

Anthony Bertrand (UCA, LIMOS), Tom Schmitt (UCA), Engelbert Mephu Nguifo (LIMOS, UCA), David Hill (INP Clermont Auvergne, ISIMA, LIMOS, UCA)

この論文をやさしく読む

ひとことで言うと

乱数生成器の内部状態を同じにしても、異なるPythonライブラリで同じ数列になるとは限らない。

何に役立つ?

複数のAI・科学計算環境をまたぐ実験の再現手順を設計する際に役立つ。

この研究の面白いところ

シードだけでなく完全な内部状態を合わせても、特にPyTorchのPhiloxなどでは参照実装と一致しないと示した。

どこまで分かった?

比較対象は二つの生成器と四つのPython環境。相違の程度や回復策は実装ごとに異なる。

v1のアブストラクトに基づくAI解説。日本語訳とは別に、用途の解釈を含みます。

アブストラクトの日本語訳

疑似乱数生成器(PRNG)はモンテカルロシミュレーション、確率的計算、人工知能などで欠かせない。これらの再現性は、同じ内部状態から始めたときにソフトウェア環境をまたいで同じ数列が得られるかに大きく依存する。疑似乱数アルゴリズムは確率過程を模擬しつつ決定的で反復可能な動作を提供し、再現可能な実験を支える。現代の実装はシード、または通常の整数シードでは表しきれない、より正確な初期状態から開始できる。しかし単純なシードだけでは、異なる実装で同じ実行経路を保証できないことが多い。生成器の完全な内部状態を移せばライブラリを問わず同じ出力になると考えがちだが、本研究はこの仮定を検討する。広く使われるMersenne TwisterとPhiloxを対象に、PythonのRandom、NumPy、PyTorch、TensorFlowという四つの環境の実装を、同一の初期化条件で元の参照アルゴリズムの数列と比較した。結果は、実装が同じ基礎アルゴリズムに従うと主張していても、PRNGの状態を移すだけでは再現性を仮定できないことを示した。複数の実装では一致したが、他では大きな相違があった。特にPyTorchのPhilox実装には参照アルゴリズムとの根本的な非互換性があり、環境間で出力を正確に再現できなかった。この結果は、PRNGの完全な内部状態へのアクセスだけでソフトウェア間の再現性が得られるという期待を覆す。実装固有の設計選択は、特に複数のフレームワークを使うAI工程で、実験再現の隠れた障害となり得る。PRNG実装の忠実性が科学的再現性に必要な条件であると示し、Pythonの科学・AI環境で信頼できる利用と再現を行うための実務指針を示す。さらにライブラリのソースコードを改変せず、利用者側の手法でライブラリ間の移植性と忠実性をどこまで回復できるかを評価する。

v1の要旨から自動生成。本文の精読・人による確認は未実施。

初稿
2026-09-22(UTC)
最新改訂
2026-09-22 · v1
査読・掲載
査読状況未確認
arXivで読むPDF

更新履歴

取得できた版を表示。版の更新は査読済みを意味しません。過去版の本文差分は未解析です。

原文の要旨

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.

arXiv ID: 2609.26461 / 要約の誤りについて