Cross-version validation — tier4_crossversion
Compare the current build against the older stable versions (v1.5, v2.0) and the analytic oracle, per b-shell.
This is the tier4_crossversion tier (see ../README.md):
on-demand, mixed hardware, needs the old binaries. It answers “do we still
match the historical stable versions?”. The analytic curve is the primary
oracle; the previous-version signals are a secondary historical overlay.
Contents
| file | what it is |
|---|---|
binaries.toml |
registry: version → {path, argstyle, note, expected_commit} for every known old build. Parsed with stdlib tomllib (python 3.11+). Paths are machine-specific; a missing binary is skipped, never fatal. |
../tools/build_old_version.py |
builds v1.5/v2.0 locally from this repo’s own git history — no external clone. git worktree add --detach checks out the release commit (found by bisecting VERSION_ID in src/constants.h), runs the historical compile.sh, caches the binary under old_binaries/<version>/ (gitignored). gen_reference.py calls this automatically the first time a version is needed and just reuses the cache after that (--force to rebuild). |
../tools/gen_reference.py |
run a chosen build on a per-version config at a fixed seed → freeze ../accuracy/reference_xv/<version>/<case>_DWI.txt + a MANIFEST.json entry. Refuses without a fixed positive --seed and --num-process. |
compare_versions.py |
load labelled _DWI files + a scheme (+ optional analytic .npy) → markdown report (per-shell mean S/S0, ADC, NRMSE-vs-reference); numpy-only, always produced. PNG plots only if matplotlib imports. |
confs/<version>/<case>.conf |
per-version configs (old unit convention) — see confs/README.md. Only free_diffusion is covered today. |
Frozen previous-version signals live under
../accuracy/reference_xv/ (tiny DWI text files +
MANIFEST.json; never trajectories).
Freeze a reference (gen_reference.py)
# Current build on the SI free-diffusion config (the verified mechanism):
python3 tests/tools/gen_reference.py --version current \
--config tests/accuracy/free_diffusion.conf \
--seed 12345 --num-process 1 --gpu 0 --case free_diffusion
# v1.5 / v2.0 -- built automatically from this repo's own history on first
# use (tests/tools/build_old_version.py), then cached and just reused:
python3 tests/tools/gen_reference.py --version v1.5 \
--config tests/crossversion/confs/v1.5/free_diffusion.conf \
--seed 12345 --num-process 1 --case free_diffusion
python3 tests/tools/gen_reference.py --version v2.0 \
--config tests/crossversion/confs/v2.0/free_diffusion.conf \
--seed 12345 --num-process 1 --case free_diffusion
- Determinism guard — refuses to run unless
--seedis a fixed positive integer and--num-processis given (a MC run is reproducible only for both fixed together; defaultseed -1is random). - Per-version configs are required for the old builds. They use different
.conf/unit conventions (scale_from_stu 1; voxel bounds always in mm) – do not feed a current SI config to v1.5/v2.0. Pass the matching config underconfs/<version>/;binaries.toml’sargstylepicks the invocation style (both v1.5 and v2.0, built from source here, take--conf). -
v1.5/v2.0 binaries build themselves. No path to hunt down, no external clone: the first
gen_reference.py --version v1.5 ...call builds it from this repo’s own history and caches it attests/crossversion/old_binaries/v1.5/MC-DC_Simulator(gitignored); every call after that reuses the cache. Force a rebuild withpython3 tests/tools/build_old_version.py --version v1.5 --force, or build ahead of time the same way. There is no v2.2 entry: that line is the current code (seeconfs/README.md). - Never freezes trajectories (
write_traj_fileforced to 0;write_txtforced to 1); only the ~2 KB_DWI.txtis copied. If a build wrote only.bfloat, it is converted to.txton freeze. - The
MANIFEST.jsonentry records:binary_path,git_commit(viaprovenance.git_commit— null when the binary is not inside a git repo, e.g. v2.0),version_string(parsed from*_simulation_info.txt; unreliable, hence the git commit),seed,num_process,N,T, and the scheme/conf/signalsha256.
Produce a report (compare_versions.py)
python3 tests/crossversion/compare_versions.py \
--scheme tests/accuracy/PGSE_sample_scheme.scheme \
--signal current=tests/accuracy/reference_xv/current/free_diffusion_DWI.txt \
--signal v1.5=tests/accuracy/reference_xv/v1.5/free_diffusion_DWI.txt \
--analytic cylinder_r5um_d0p6 \
--out report.md --plot-dir plots
- Markdown always, numpy-only: per-shell mean S/S0, per-shell ADC, and
NRMSE + max|Δ| vs a reference (
--ref, defaultanalyticif present, else the first signal). Styled like../benchmark/three_perm_spheres_report.md. - N cancels — S/S0 = signal / mean(signal[b0]), so signals from runs with
different walker counts are directly comparable (no
--n-walkers). - Plots are optional. If
matplotlibis importable (pip install .[viz]) it writes mean-S/S0-vs-b (linear + log) and ADC-vs-b PNGs; otherwise plots are skipped with a note in the report — never a crash. - Missing inputs degrade gracefully — a reference not frozen on this host, a wrong-length signal, or an unavailable analytic curve is skipped and noted, not fatal.
How to read the plots: the analytical reference is always a solid black line; colour encodes the simulator version; signals are never pooled across b-values — one series per shell.
Determinism caveats
A run is reproducible only for a fixed seed and fixed num_process.
Cross-version and CPU↔GPU results are never bit-exact (different RNGs —
std::mt19937_64 vs cuRAND Philox, and different generators across versions), so
this tier compares per-shell means within a loose statistical band, never for
equality.
CI
../../.github/workflows/crossversion.yml—workflow_dispatchonly, self-hosted: builds the current binary, freezes it withgen_reference.py, runscompare_versions.py, and uploads the report + PNGs as artifacts. v1.5/v2.0 build themselves from this repo’s history on the runner (needsgit,g++, a workinggit worktree).../../.github/workflows/nightly.yml— thetier3_analytic+gputiers on a self-hosted CUDA runner (not this tier, but the sibling on-demand GPU workflow).
What a real cross-version run needs from you
- v1.5 and v2.0 build themselves — no external binary to source or point
at.
gen_reference.py --version v1.5|v2.0 ...builds from this repo’s own history (tests/tools/build_old_version.py) on first use and reuses the cached binary after that. - A per-version config per case (the old unit conventions differ) — see
confs/README.md; onlyfree_diffusionexists today. Freeze each version’s<case>_DWI.txtwithgen_reference.py, commit them under../accuracy/reference_xv/<version>/, then runcompare_versions.py.