Reproducible Randomness in Parallel Stochastic Simulations

23 concepts19 papers1 proposal

In scientific computing and machine learning, reproducibility is the bedrock of verification. If an experiment cannot be reprocessed to yield the exact same bit-level results, debugging becomes a guessing game, and benchmarking loses its statistical validity.

In single-threaded workflows, achieving determinism is relatively straightforward: we initialize a global Pseudo-Random Number Generator (PRNG) with a fixed seed. As demonstrated by Marcus Liwicki et al. in DeepDIVA: A Highly-Functional Python Framework for Reproducible Experiments and Improving Reproducible Deep Learning Workflows with DeepDIVA, centralizing random seeds across standard libraries (like NumPy or PyTorch) effectively stabilizes stochastic machine learning pipelines. A similar approach is used by Aghiles Salah et al. in Cornac: A Comparative Framework for Multimodal Recommender Systems to ensure consistent evaluation baselines.

However, this centralized approach completely breaks down when we introduce parallelism, asynchronous execution, or distributed environments.

The Pitfalls of Shared Global State

To understand why parallelism destroys reproducibility, consider a simulation where multiple threads concurrently draw random numbers from a single global PRNG.

Global PRNG State: [ Seed ] ---> Thread A draws (Value 1)
                            ---> Thread B draws (Value 2)

Because operating system thread schedulers are non-deterministic, the exact order in which threads access the global PRNG changes from run to run. If Thread B happens to execute slightly faster on a second run, it will consume Value 1 instead of Value 2. Consequently, the entire downstream execution path of both threads diverges, rendering the simulation non-reproducible.

To eliminate this interleaving dependency, we must shift from a global random state to a localized one. As argued by Ana M. Martínez et al. in Probabilistic Graphical Models on Multi-Core CPUs using Java 8, avoiding shared global seeds is essential for multi-core execution. By isolating random number generation within individual threads or tasks, the sequence of random values remains consistent regardless of how the operating system schedules those threads. For instance, Tanay Dey et al. leverage this in Parallelization of Garfield++ and neBEM to simulate space-charge effects in RPCs by provisioning each parallel Monte Carlo thread with its own uniquely seeded PRNG instance, ensuring uncorrelated yet reproducible physical simulations.

Splittable PRNGs: Managing Localized States

While giving every thread its own PRNG solves the race condition, it introduces a new management problem: how do we generate thousands of independent, statistically uncorrelated seeds for these threads without manually tracking an exhaustive list?

The modern solution to this problem is the splittable PRNG. Instead of treating a random state as a linear sequence, a splittable PRNG allows a parent random state to be deterministically "split" into independent child streams.

                  [ Root Seed ]
                       |
            +----------+----------+
            |                     |
     [ Child Seed 1 ]      [ Child Seed 2 ]
            |                     |
       (Thread A)            (Thread B)

In Provenance Design and Evolution in a Production ML Library, Adam Craig Pocock et al. show that by storing only the initial root seed and the tree history of these splits, a system can precisely reconstruct the exact random state of any sub-task at any point in time. This mechanism is incredibly powerful for distributed architectures. Miguel Biron-Lattes applies this concept to high-dimensional statistical sampling in Pigeons.jl: Distributed sampling from intractable distributions, demonstrating that independent, splittable random streams guarantee bit-for-bit reproducibility across varying hardware topologies, irrespective of the number of underlying CPU cores or distributed nodes utilized.

Decoupling Randomness from Execution Timing

Localizing PRNG states works perfectly when the workload mapping is static. But what happens in high-throughput, asynchronous systems where tasks are processed dynamically based on network availability or variable execution speeds?

Consider an asynchronous reinforcement learning framework where environment executors collect data and send it to neural network actors. If an actor selects an action using a random draw at the moment a network request arrives, the timing of that request dictates the random outcome.

To solve this, Iou-Jen Liu et al. in High-Throughput Synchronous Deep RL propose a design that decouples randomness generation from execution timing. Instead of actors generating randomness upon request arrival, the environment executors generate the random seeds internally and bundle them directly with the environment state data. When the actor receives the bundle, it uses the attached seed to make its stochastic decision. Because the seed is bound to the data payload rather than the arrival time, the system achieves bit-perfect reproducibility despite highly non-deterministic network execution speeds.

A similar principle applies to parallelized optimization algorithms. In PASO: Step Parallel Stochastic Optimization, Jianrong Lu et al. break the sequential constraint of deep learning training by computing multiple gradient steps simultaneously. To maintain mathematical equivalence with a standard serial run, they implement a deterministic seeding mechanism that forces each parallelized step to access the exact data mini-batch it would have encountered sequentially. This rigorous alignment ensures that the parallel solver recovers the identical optimization trajectory of traditional serial gradient descent. As emphasized by Wenjie Tang et al. in DA-OCBA: Distributed Asynchronous Optimal Computing Budget Allocation Algorithm of Simulation Optimization Using Cloud Computing, maintaining this uniform sequence of random variates across both serial and parallel executions is the only way to guarantee accurate, unskewed comparative evaluations in distributed optimization.

Reproducible Environments and Data Pipelines

This philosophy of binding seeds directly to data structures allows us to make complex, branching pipelines fully reproducible.

In data augmentation, for example, Anguelos Nicolaou et al. demonstrate in TorMentor: Deterministic dynamic-path, data augmentations with fractals that treating every stochastic image distortion as a serializable object containing an explicit seed allows researchers to replay complex, branched augmentation paths perfectly during debugging.

This concept scales up to entire simulation environments:

Eliminating Non-Determinism Beyond the PRNG

Achieving true bit-for-bit consistency across parallel systems often requires looking beyond pseudo-random number generators to eliminate hidden sources of hardware and environmental variance.

In distributed microservices, non-determinism frequently creeps in via external interaction points like system clocks or remote procedure calls (RPCs). To fuzz these systems reliably, Bingchang Liu et al. develop a framework in MicroFuzz: An Efficient Fuzzing Framework for Microservices that records the values returned at these external interaction points during an initial execution and replays them in subsequent runs, forcing a consistent execution path for a given input seed.

Even purely mathematical operations can introduce non-determinism due to floating-point roundoff errors or ambiguous geometric configurations when processed in parallel. In PatCC1: an efficient parallel triangulation algorithm for spherical and planar grids with commonality and parallel consistency, Haoyu Yang et al. tackle this in the context of Earth system modeling. When computing Delaunay triangulations across parallel processors, ambiguous geometric cases can cause different cores to construct different mesh topologies. The authors resolve this by enforcing strict, coordinate-based tie-breaking rules. Because these rules rely solely on invariant spatial coordinates rather than the order of thread execution, they guarantee identical geometric outputs whether the code runs on a single core or a thousand.

By localizing random states, leveraging splittable PRNGs, decoupling seeds from execution timing, and enforcing deterministic tie-breaking rules, modern parallel frameworks successfully bridge the gap between high-throughput performance and absolute scientific reproducibility.

Key Foundational Work

BatchJobsandBatchExperiments: Abstraction Mechanisms for UsingRin Batch Environments (2015) — contributed 2 concept elements to this direction.
Efficient Statistical Methods for Evaluating Trading Agent Performance (2007) — contributed 1 concept elements to this direction.
History & citationVersion 1 · 2026-10-04

Current · Permanent link

View frozen version 1

Cite this direction

Latest version (a living page):

@misc{lacuna_deterministic_parallel_sampling_8942098e,
  title = {deterministic parallel sampling},
  author = {{Lacuna}},
  howpublished = {Lacuna research direction},
  year = {2026},
  url = {https://lacuna.tiptreesystems.com/direction/deterministic-parallel-sampling/rdr_8942098ebcd54febbeeaccaa4706eac1},
  note = {Latest version of a living research direction; cite a version for a fixed text. Accessed 2026-11-27},
}

This exact version (version 1, frozen text):

@misc{lacuna_deterministic_parallel_sampling_8942098e_v1,
  title = {deterministic parallel sampling},
  author = {{Lacuna}},
  howpublished = {Lacuna research direction},
  year = {2026},
  url = {https://lacuna.tiptreesystems.com/direction/deterministic-parallel-sampling/rdr_8942098ebcd54febbeeaccaa4706eac1/v/1},
  note = {Version 1, frozen 2026-10-04. Accessed 2026-11-27},
}
About

These directions overlap with this one through shared papers.

See something wrong? Report a mistake