Check run-to-run determinism¶
A search that gives a different answer on the second run cannot be
debugged, and a change to the code cannot be compared with the old
behaviour. This page lists the settings that decide whether gprn and
gprd repeat, shows how to compare two runs byte for byte, and
describes the harness that does the same on the 44 UMA cells of the
paper panel.
What repeats¶
Repeatability here means the same inputs, the same flags and the same
number of threads and MPI ranks. Builds that differ only in
simd_baseline or use_highway repeat each other bit for bit: Eigen
runs unvectorized, which is the default (scalar_eigen=true).
-Dscalar_eigen=false opts into vectorized Eigen and is outside this
contract. Nothing contracts into a fused multiply-add, and the
Highway kernels round as the scalar loops do. The one vectorized Eigen
kernel, the double matrix-product kernel of gpr/linalg/ScalarGebpKernel.h,
holds only independent entries in one vector and adds each in the order
of the scalar kernel, so it returns the scalar bits. Other differences between
builds, two machines or two rank counts can still change the result.
test_capi_gp_neb prints a digest of every oracle evaluation of its GP
bands, and the correctness workflow builds it at x86-64-v2,
x86-64-v3 and native, and with Highway, then compares those digests
with a build at the compiler default
(scripts/check_gp_neb_invariance.py).
Output |
Repeats |
Compare with |
|---|---|---|
|
yes |
sha256 of the file |
|
yes |
sha256 of the file |
Oracle calls, |
yes |
the lines of the log |
|
datasets only |
dataset arrays (the container bytes differ) |
|
no |
grep the lines above (timing lines differ) |
Observation archive ( |
no |
read it with readcon-db; do not hash the files |
“Yes” for the first three rows and the dataset claim for neb.h5 are
checked by the blocks below on a Lennard-Jones cluster. The
observation-archive row and the container-bytes statement for neb.h5
were observed on the same run and are not asserted here.
The IRC certificate record is written to <archive>/irc_certificate.txt.
With the default --gp-observation-archive auto the archive is
obs-archive/ beside --output. With --gp-observation-archive off the
record goes to the working directory. The log line IRC certificate record: PATH names the file. gprd has no --irc-certificate flag.
Settings that decide whether a run repeats¶
Setting |
Default |
Effect on repeatability |
|---|---|---|
|
1 |
Sets the dense linear-algebra thread count. TOML key |
|
1 |
Independent kernel-block threads per MPI rank. Command line only. Needs |
|
|
|
|
42 |
Seeds the random number generators of the driver and the samplers. TOML key |
|
0 |
A positive value is one absolute deadline for search, oracle calls and certificates. On expiry |
|
true |
Uses a fixed axial grid instead of random samples in the PSIS uncertainty arm (only when |
|
|
Does not change the search. It moves the IRC record (see above). |
|
true |
Meson option. Combines MPI reductions in rank order. |
|
|
Meson option. Does not change results: Eigen runs unvectorized by default and nothing contracts into FMA. |
gprn and gprd set OPENBLAS_NUM_THREADS, MKL_NUM_THREADS,
OMP_NUM_THREADS and RAYON_NUM_THREADS to 1 at start-up when the
environment does not already define them (main_neb.cpp, runGprn).
The drivers then apply --linalg-threads through the runtime APIs. An
exported OMP_NUM_THREADS therefore does not override the numerical or
engine team selected by the caller.
The SLATE and distributed GP backends enforce fixed-tile reduction order
across thread counts, MPI rank counts and 2D BLACS process grids by
default (unconstrained fast reductions remain opt-in via
GPR_UNCONSTRAINED_REDUCTIONS=1):
SLATE ``v2025.05.28`` host-task kernels (
gpr/linalg/SlateKernels.cpp):src/trsm.cc:17defaults toMethodTrsm::AwhenB.nt() < 2, accumulating partial panels per rank (src/internal/internal_gemmA.cc:89-189) and reducing along a root-shifted hypercube (include/slate/BaseMatrix.hh:2320,src/internal/internal_comm.cc:72-123).SlateKernels.cpppinsOption::MethodTrsm = MethodTrsm::BsoBremains stationary on its(p, q)owner with zero cross-rank floating-point reductions, pinsOption::MaxPanelThreads = 1forheev(src/internal/internal_geqrf.cc:80), redistributesheevthroughGridOrder::Col(src/stedc_merge.cc:102), and stages ScaLAPACK slabs into 64-byte aligned canonical-stride SLATE tiles (src/core/Memory.cc:124,patches/slate-deterministic-host-tiles.patch, which also restores thedepend(in:col[k-1])edge and trailing-block guard insrc/trtri.cc:197-243).Distributed GP, HS-SVD, RFF and Laplace reductions:
gpr/ml/GaussianProcessRegression.inl:1082,1128runs the 2-lane alignedExactSumtrace contraction in bothreproducibleandlibrarymodes;gpr/ml/gp/StableBasis.cpp:430keeps the canonical eigensolve consistent across rank counts;gpr/linalg/ScalapackBackend.h:143,744,1082partitionsdistributed_gemm_nninto fixed 64-column tiles,TSQRinto fixed 64-mode leaves in global leaf order, and inverse diagonals viaExactSum;gpr/ml/RFFModel.cpp:180andgpr/ml/gp/LaplaceSlice.cpp:678reduce fixed tiles viaExactSum.Thread-count and oracle isolation:
gpr/potentials/EnginePotential.cpp:178-201scopes pluginforceandforceBatchcalls to the thread count passed by the driver when the engine is opened. It does not readOMP_NUM_THREADSor another environment override, so the oracle team is fully caller-controlled; local OpenMP,stdpar, andKokkosreductions (gpr/ml/GaussianProcessRegression.inl:2232,gpr/covariance_functions/ManifoldEnergyForceKernel.cpp:370,gpr/ml/ARDGridSearch.cpp:71,gpr/linalg/StdParBackend.h:132,gpr/linalg/KokkosJointKernel.h:736,gpr/linalg/KokkosDensePosterior.h:308) use static fixed-tile schedules folded in canonical index order.
The oracle has to repeat as well. A Python-defined potential with
unseeded randomness, or a model package that gives a new output for the
same geometry, defeats every setting above. --metatomic-deterministic
(default false) asks torch for deterministic execution in the metatomic
oracle. The UMA section below covers the exporter side.
Check a run on a Lennard-Jones cluster¶
The check below uses the five-atom Lennard-Jones pentamer of the gprn tutorial, which needs no model file. Copy the supplied endpoints.
examples="$GPRIDGE_ROOT/examples/lj-pentamer"
cp "$examples/reactant.con" "$examples/product.con" .
Run the same command twice into two directories, and a third time with a
different --seed. The thread, archive and certificate flags are the
harness settings of the UMA section. --gp-nonperiodic true treats the
cluster as an isolated molecule whatever the box of the .con file, as
the paper’s band runs do (bench/uma/canonical_argv).
run() {
mkdir -p "$1" && cd "$1" && shift
gprn --reactant ../reactant.con --product ../product.con \
--potential lj --nimages 7 --gp-model-profile gprd_zbl \
--linalg-threads 1 --kernel-threads 1 --gp-nonperiodic true \
--gp-observation-archive off --irc-certificate true \
--output neb.h5 --write-con band.con "$@" > gprn.log 2>&1
cd ..
}
run a
run b
run c --seed 7
grep -E '^(Oracle calls \(to convergence\)|Converged:|IRC certificate record)' a/gprn.log
Oracle calls (to convergence): 17 (endpoints=2, initial=0, outer=15, dimer=0, certificate=0, transition=0)
Converged: yes
IRC certificate record: ./irc_certificate.txt
Compare the band and the certificate by content. cmp exits 0 only
when the files are identical.
cmp a/band.con b/band.con
cmp a/irc_certificate.txt b/irc_certificate.txt
echo "a and b: band and certificate identical"
a and b: band and certificate identical
The third run differs only in --seed. The driver draws no random
numbers on this case, so the seed does not matter here.
cmp a/band.con c/band.con
echo "a and c: band identical"
a and c: band identical
The seed matters where a sampler or a random start is used, for example
the Python dimer’s random initial orientation (GPDimer(seed…)=) or
the sampled PSIS arm with --use-psis-deterministic false. A different
seed on those paths gives a different run by design.
neb.h5 is compared by dataset. The container bytes of the two files
differ even when every array is equal.
import h5py
import numpy as np
with h5py.File("a/neb.h5") as fa, h5py.File("b/neb.h5") as fb:
names = []
fa.visititems(lambda n, o: names.append(n) if isinstance(o, h5py.Dataset) else None)
assert names, "no datasets found"
for name in names:
assert np.array_equal(fa[name][()], fb[name][()]), name
print(len(names), "datasets equal")
Compare runs with the project’s comparator¶
bench/determinism/compare.py compares two CSVs cell by cell on oracle
calls, IRC label, convergence flag, exit code and the sha256 of
band.con and the certificate record. It exits 0 only when every cell
agrees, 1 when a cell differs, and 2 when a CSV is malformed or does
not list exactly the cells of the --cells file. The block below
builds the CSVs for the three runs above with the helpers of
run_uma_cells.py and compares them. The cell file names one cell,
toy/lj5.
import csv
import os
import subprocess
import sys
from pathlib import Path
harness = Path(os.environ["GPRIDGE_ROOT"]) / "bench" / "determinism"
sys.path.insert(0, str(harness))
from run_uma_cells import parse, sha256 # noqa: E402
Path("cells.txt").write_text("toy/lj5\n")
header = ["label", "cell", "calls", "irc", "converged", "exit_code",
"band_con_sha256", "irc_record_sha256", "wall_s"]
for run in "abc":
got = parse(Path(run, "gprn.log").read_text())
row = [run, "toy/lj5", got["calls"], got["irc"], got["converged"], "0",
sha256(Path(run, "band.con")), sha256(Path(run, "irc_certificate.txt")), "0"]
with open(f"{run}.csv", "w", newline="") as out:
writer = csv.writer(out)
writer.writerow(header)
writer.writerow(row)
def compare(x, y):
return subprocess.run(
[sys.executable, str(harness / "compare.py"), "--cells", "cells.txt", x, y],
capture_output=True, text=True,
)
same = compare("a.csv", "b.csv")
print(same.stdout.strip())
assert same.returncode == 0 and "differing 0" in same.stdout
text = Path("b.csv").read_text().replace("17", "18", 1)
Path("tampered.csv").write_text(text)
different = compare("a.csv", "tampered.csv")
print(different.stdout.strip())
assert different.returncode == 1
cells 1/1 calls 17/17 differing 0
toy/lj5 calls=17/18
cells 1/1 calls 17/18 differing 1
Matching failed outcomes establish repeatability only. Acceptance of a saddle still needs the force and index checks of the IRC certificate how-to.
Repeat the UMA panel¶
This section is specific to the 44 UMA cells (Baker and Birkholz sets,
listed in bench/determinism/cells.txt) behind the paper. It needs the
deposited archive, the UMA model packages in it, and a build with the
UMA oracle. The blocks are not run by the documentation tests.
Obtain and extract the archive as described in
Reproduce the paper. Its extracted root, which
holds results/ and data/uma/, is the --zenodo argument below. Do
not write the argument list by hand. run_uma_cells.py reads each
cell’s archived 0.5.0 band arguments from
results/gpridge-0.5.0-<set>-r1/<set>/<cell>/band/gprn.argv.json,
rewrites the output paths, and applies these overrides:
--converged-force 0.0514221
--linalg-threads 1
--kernel-threads 1
--gp-observation-archive off
--max-wall-seconds 600
--irc-certificate true
The 600-second limit covers the search. The IRC certificate walk begins after the search converges and is outside that wall budget.
The archived arguments use --linalg-mode library
(bench/uma/canonical_argv), not the default reproducible. Cells run
one at a time, pinned to one core (taskset) with address-space
randomisation off (setarch -R) and every thread pool at one.
PATH=$HOME/.pixi/bin:$PATH bench/determinism/build_uma.sh . build-uma
for run in 1 2; do
python3 bench/determinism/run_uma_cells.py --gprn build-uma/gprn \
--out runs/r$run --csv runs/r$run.csv --label r$run --core $((run + 1)) \
--zenodo /path/to/zenodo/extract --prefix .pixi/envs/scalapack
done
python3 bench/determinism/compare.py runs/r1.csv runs/r2.csv
build_uma.sh SRC BUILD builds gprn and libuma_engine.so in the
pixi scalapack environment (torch CPU, metatomic). Its install task puts
cbindgen in that environment; the host must provide gfortran, or
GPRIDGE_HOST_GFORTRAN must name it. Each replay needs a
new output directory and a new CSV, and existing results are kept. For a
subset, pass the same --cells FILE to the runner and to compare.py.
Check a package before blaming the search. check_package.py PACKAGE.pt2 GEOMETRY.con evaluates a package repeatedly on one
geometry and exits 1 when two outputs differ. A package exported with
OMP_NUM_THREADS above 1, by an exporter without ef558571, gives a
new output on every call. That commit is in the pinned rgpot
4a5a7321 (subprojects/rgpot.wrap). The wrap does not apply
aoti-deterministic-export.patch. No gprn argument list repeats on
such a package. The archived packages repeat bit for bit.
pixi run --locked -e scalapack python bench/determinism/check_package.py PACKAGE.pt2 GEOMETRY.con 5
Perturbed repeats¶
A change that moves only rounding cannot pass the byte-identical
comparison. bench/determinism/README.md describes the statistical
gate for it: endpoint_scales.py, perturb_uma_cells.py and
compare_perturbed.py, run on seeded displacements of both endpoints
of the same 44 cells. Read that file for the acceptance rules before
using the gate.
Where to read more¶
The surrogate loop for what the search computes.
The MPI how-to and the HPC how-to for rank and thread layouts.
Command-line reference and TOML key reference for every flag and key named here.