Sub topic 1
What Reproducible Means for an ML Project
Prerequisites
You should know basic Python and pip, use the command line, and understand the main steps of training or running a model. You should also know basic Git concepts such as commits and branches.
Reproducibility as a Set of Conditions
An ML result is reproducible when another run can recreate the same result, or a result within an agreed tolerance, from the same recorded inputs.
“Same code” is not enough. A training run depends on several inputs:
- Code: The source files, configuration, and command used to start the run.
- Data: The exact dataset, including its version, split, preprocessing, and labels.
- Environment: The Python version, packages, operating-system libraries, hardware, and GPU software.
- Randomness: Random seeds and the algorithms used to generate random values.
- Outputs: The model artifact, metrics, logs, and intermediate files.
A useful model is:
result = f(code, data, environment, randomness, configuration)If any input changes, the result can change. Reproducibility means recording and controlling these inputs instead of assuming they remain constant.
A Reproducible Training Run
Consider a classifier trained with PyTorch. You commit the training code to Git and record the command:
python train.py --config configs/resnet.yamlThat record still leaves important questions unanswered:
- Which Python version ran the command?
- Which versions of PyTorch, NumPy, and other packages were installed?
- Did the dataset change after the first run?
- Did the run use a CPU or a particular GPU?
- Were random seeds set?
- Did the hardware use an operation with nondeterministic behavior?
A second machine might install newer packages from the same broad requirements. The code may start successfully but produce different metrics. A package update can change numerical behavior, default settings, or an algorithm’s implementation.
What You Can and Cannot Guarantee
Reproducibility has levels. Decide the level before you compare runs.
| Level | What should match | Typical use |
|---|---|---|
| Exact rerun | Parameters, predictions, and metrics match exactly | Debugging and tests |
| Numerical rerun | Metrics and predictions stay within a defined tolerance | Most model training |
| Experiment rerun | The same conclusion holds, though values differ slightly | Research and model selection |
Exact matching is difficult on some GPUs because parallel operations can produce results in a different order. Floating-point addition is not always associative, so changing the order can change the final value slightly.
A reproducibility record should therefore state both the controls and the tolerance. “The model is reproducible” is incomplete without saying what was compared.
The Main Dependency
The environment is one part of the full chain:
Lock files and containers mainly control the environment. They do not automatically version the dataset, fix every GPU operation, or record the exact command. Reproducibility requires all of these records to travel with the experiment.
Exercise
Two runs use the same Git commit but different NumPy versions and dataset revisions. Is the second run reproducible?
Show answer
No. The code revision matches, but the environment and data inputs do not. The runs are comparable only after those differences are recorded and their effects are evaluated.