24 — Governance & Trust

Reproducibility#

SciencePractice 1 min read
◆ The PatternEnsuring any result can be replicated exactly

Reproducibility means anyone can re-run your experiment and get the same result. This requires pinned dependencies, fixed random seeds, versioned data (DVC), containerised environments, and recorded hardware specs. Without it, your "state of the art" result is just a story.

// Interactive — reproducibility checklist
Pattern bridge: Reproducibility in ML is the same discipline as walk-forward validation — if you can't reproduce it, you can't trust it. In markets, backtest reproducibility faces the same challenge with data versioning.
Worked example

A million float32 numbers summed in two different orders differ by 0.00012. Nothing is wrong with either sum; floating-point addition is not associative, and parallel hardware changes the order. Even the size of the gap depends on the machine: run the code below in the browser and it comes out at 0.00018, because that build of NumPy adds the numbers in a different order. The same seed does give the same random numbers (True), but bit-identical training also needs the same order of operations.

Where it misleads
  • Fixing seeds is necessary, not sufficient: library versions, hardware and non-deterministic GPU kernels change results too.
  • Exact reproduction is not always the goal; reporting the spread over seeds shows whether a result is robust.
  • Unversioned data makes every other control useless.
In code
x = np.random.default_rng(6).normal(0, 1, 1_000_000).astype(np.float32)
s1 = x.sum()
s2 = x[np.random.default_rng(7).permutation(len(x))].sum()   # same numbers, different order
order_diff = abs(float(s1) - float(s2))
same_seed = np.random.default_rng(42).random(3).tolist() == np.random.default_rng(42).random(3).tolist()
Python, in your browser — edit the code and run it again

Assumes import numpy as np and import pandas as pd. Each snippet carries its own example numbers; the comments say which are made up or simulated.

The same idea with a library
# Python — reproducibility essentials
import random, numpy as np, torch

# Lock all seeds
SEED = 42
random.seed(SEED)
np.random.seed(SEED)
torch.manual_seed(SEED)
torch.cuda.manual_seed_all(SEED)
torch.backends.cudnn.deterministic = True

# Pin deps: pip freeze > requirements.txt
# Version data: dvc add data/train.csv
# Container: docker build -t experiment:v1 .
Sources
  • J. Pineau et al., “Improving Reproducibility in Machine Learning Research”, Journal of Machine Learning Research 22(164), 2021
  • O. E. Gundersen & S. Kjensmo, “State of the Art: Reproducibility in Artificial Intelligence”, AAAI, 2018
  • D. Goldberg, “What Every Computer Scientist Should Know About Floating-Point Arithmetic”, ACM Computing Surveys 23(1), 1991

Last reviewed October 2026 · How this site checks its content · Report a mistake

Check yourself

1. Same code, same seed, a different GPU — and slightly different results. Why?

Show answer

B. Bit-identical results need the same hardware, library versions and deterministic kernels, not just a seed.

2. Besides the code, what do you need to reproduce a training run?

Show answer

A. Lineage tools and experiment trackers record these together, so a result can be traced back to its inputs.

3. Your requirements file pins only top-level packages, like numpy>=1.20. What can go wrong?

Show answer

C. A rebuild months later can silently pull different versions and change results.

Linked from 1
← Previous
Fairness Audits
Open in the full reader, with the topic sidebar