Research notebook

Deterministic replay notebook

Edit a Python cell and run it here. Your code runs in this browser tab; the notebook runtime and packages are served by this site.

Python starts when you choose Run.

100 identical loss logs, 100 different model states

Aryan Putta · November 6, 2026

A Megatron-inspired CPU replay lab shows why matching seeds and rounded loss curves cannot establish bitwise reproducibility.

The experiment uses CPU float32 regression and Adam with synthetic data. Run the cells in order; results and figures are written to the working directory. Dependencies: NumPy and Matplotlib.

Method: CPU float32 regression with Adam on synthetic data. The controlled comparisons change gradient-reduction order and checkpoint state to test exact replay.

Sources:

  • https://developer.nvidia.com/blog/scale-bitwise-deterministic-pretraining-with-nvidia-megatron-core/
  • https://docs.pytorch.org/docs/stable/notes/randomness.html
  • https://docs.nvidia.com/cuda/floating-point/index.html
Python · cell 1

Run the study and its assertions

The printed results are computed, not illustrative. Change the constants in the previous cell to explore a different controlled setup.

Python · cell 2
{
  "checks_passed": 15,
  "summary": [
    {
      "scenario": "Same seed + full state",
      "first_weight_mismatch": null,
      "weight_mismatch_steps": 0,
      "hidden_weight_mismatch_steps": 0,
      "maximum_weight_difference": 0.0,
      "final_loss": 0.020268479118598137
    },
    {
      "scenario": "Full checkpoint",
      "first_weight_mismatch": null,
      "weight_mismatch_steps": 0,
      "hidden_weight_mismatch_steps": 0,
      "maximum_weight_difference": 0.0,
      "final_loss": 0.020268479118598137
    },
    {
      "scenario": "Reversed reduction",
      "first_weight_mismatch": 1,
      "weight_mismatch_steps": 100,
      "hidden_weight_mismatch_steps": 100,
      "maximum_weight_difference": 1.1920928955078125e-07,
      "final_loss": 0.020268477811632834
    },
    {
      "scenario": "Optimizer reset",
      "first_weight_mismatch": 41,
      "weight_mismatch_steps": 60,
      "hidden_weight_mismatch_steps": 1,
      "maximum_weight_difference": 0.1605449914932251,
      "final_loss": 0.024593437931813907
    },
    {
      "scenario": "Sampler RNG reset",
      "first_weight_mismatch": 41,
      "weight_mismatch_steps": 60,
      "hidden_weight_mismatch_steps": 1,
      "maximum_weight_difference": 0.02873385325074196,
      "final_loss": 0.02016254975299807
    }
  ],
  "reference_final_loss": 0.020268479118598137
}

Inspect the generated figures

These are rendered from the results just computed.

Python · cell 3
Loss and parameter differences between two float32 training runs with changed reduction order.Model-state divergence after checkpoint restoration variants.

Python runs locally in this page. Saved results and figures are visible before execution.

Download full experiment notebook