cjfp-data / validation /NUMPY2_VALIDATION.md
santicas's picture
Mirror cjfp-data validation artifacts
c7c67ef verified
|
Raw History Blame Contribute Delete
7.1 kB

NumPy 2 scientific validation on the workstation

Run before merging PR #231, from jaxcosmo-autodiff at 9a9dc31 or a later reviewed revision. This is a merge gate. Keep the source checkout unchanged until the campaign finishes. After merging, a short smoke run on the merge revision can verify the final installation.

What is synced (checked 2026-11-03)

  • Local cjfp-data is at d6ded71, equal to origin/main after fetch.
  • dvc status validation/fisher.dvc reports unchanged local data; dvc status -c validation/fisher.dvc reports cache/remote in sync.
  • Source jaxcosmo-autodiff is at 9a9dc31, equal to its remote branch.
  • The maintained Fisher runners and 25 case configs are identical on that branch and origin/main (40eb918). All configured input paths resolve locally.
  • Runners/configs live in the source repo, not in a copied data-side suite. jobs_punch/ contains separate HPC sampling workflows.
  • The archived data contains 33 complete backend-pair runs and five incomplete attempts. Saved commits are 00bc6e3 and 5a091dd; the latter declared numpy<2. Exact historical NumPy/SciPy versions were not recorded.
  • Archived backends are CAMB 2.0.3 and CLASS 3.3.4.0. Current source pins CAMB 2.0.4 and CLASS 3.3.4.0. Existing dashboard failure 07.2.0.1 is a known pre-campaign failure, not evidence of a new NumPy 2 regression.

These are checks of the local repositories and their remotes. Run the steps below on the workstation to verify its checkouts and environment too.

1. Update the workstation and install the source environment

Use the actual workstation paths:

export SOURCE=/path/to/cfp-jaxcosmo
export DATA=/path/to/cjfp-data
git -C "$DATA" pull --ff-only
git -C "$SOURCE" switch jaxcosmo-autodiff
git -C "$SOURCE" pull --ff-only
uv sync --project "$SOURCE" --locked
# Only the Fisher baseline; no chains are needed:
(cd "$DATA" && bash scripts/fisher-data.sh download)
(cd "$DATA" && bash scripts/fisher-data.sh status)
bash "$DATA/scripts/run-fisher-validation.sh" --source "$SOURCE" --check

The preflight imports CAMB, CLASS and the package from the requested checkout, requires NumPy >=2.1,<2.3, resolves every case's YAML/common-spec/survey inputs, and prints package versions and Git status. Review any dirty source status. The CAMB/CLASS campaign does not require the jaxcosmo or emulators extras. The new launcher/runbook must be committed and published before these files are available through git pull on another machine.

2. Launch the campaign

Inside a persistent terminal (tmux or equivalent):

set -o pipefail
bash "$DATA/scripts/run-fisher-validation.sh" --source "$SOURCE" --run \
  --all --jobs 2 --omp-threads 4 2>&1 | tee numpy2-validation.log

This delegates to run_parallel_validations.sh, forces fresh calculations, and writes under validation/fisher/numpy2_<revision>_<UTC timestamp>_<pid>/. It records campaign_environment.json and the launch command there. Existing baseline directories are untouched. Two concurrent cases with four OpenMP threads each request eight OpenMP threads in total; additional library threading can affect actual CPU use. Keep the environment unchanged while it runs.

For an initial two-case smoke run, replace --all with --cases 05.1.0,05.2.0. Launch --all afterwards for the scientific merge gate. Each invocation creates its own campaign directory. A nonzero exit means at least one gate, calculation or report step failed; inspect the per-case logs. Successful unit tests (513 passed, one skipped on this branch) are supporting evidence, not a replacement for this campaign.

3. Compare with the archive, backend by backend

There are two different comparisons:

  1. The campaign's reports check CAMB versus CLASS for each configured model, probe and survey, with the existing 10% marginalized-error gate.
  2. The regression check compares old CAMB versus new CAMB, and separately old CLASS versus new CLASS, with identical scientific inputs. Two backends can drift together while their mutual comparison still passes.

For each case select a complete archived run and a new run with matching common specs, survey, solver precision, free-parameter steps, and power-spectrum prescription. Do not match only by directory hash: hashes contain machine paths. Do not select a newer but incomplete archived attempt.

Use the existing source comparator on an explicit same-backend pair. Set the two absolute specs-file paths, including their timestamps:

export OLD_SPEC=/absolute/archived/run/CosmicFish_v1.3.1_old_A__GCphWL_FM_specs.json
export NEW_SPEC=/absolute/new/run/CosmicFish_v1.3.1_new_A__GCphWL_FM_specs.json
export PAIR=$(mktemp -d)
# Stage sidecars alongside specs, because saved metadata contains old host paths.
for spec in "$OLD_SPEC" "$NEW_SPEC"; do
  stem="${spec%_specs.json}"
  ln -s "$spec" "$stem.txt" "$stem.paramnames" "$PAIR/"
done
uv run --no-sync --project "$SOURCE" python \
  "$SOURCE/scripts/validation/compare_fishers_in_dir.py" "$PAIR" \
  --pair "$(basename "$OLD_SPEC")" "$(basename "$NEW_SPEC")" \
  --fom-params Omegam,sigma8 --out "$PAIR/regression.json"

Select A or B from run_metadata.json's args.code_a/code_b; their order is reversed in some archived cases. Review parameter sets and fiducials before accepting the metrics: the comparator can align only the common parameters. Review Fisher Frobenius/diagonal differences, marginalized sigma ratios, FoM, and the recorded specs differences. This command reports metrics; it does not enforce a NumPy-regression acceptance threshold. The existing 10% CAMB/CLASS gate is not a justified tolerance for same-backend regression.

Old versus new results test the full software-stack upgrade. CAMB changed 2.0.3 to 2.0.4 and other dependencies/code changed too. If differences appear, isolate NumPy with the same scientific source/configs and matched backend, SciPy and other dependency versions in separate NumPy 1.26 and 2.2 environments (build compiled extensions for each environment). Do this in disposable environments/checkouts; the PR's declared NumPy requirement cannot simply be downgraded in place. Record both environments. Historical outputs alone cannot prove that a discrepancy is caused by NumPy.

4. Review and share results

Serve the new dashboard, substituting the campaign directory printed at launch (make fisher-serve serves the archived top-level dashboard):

python -m http.server 8001 --directory "$DATA/validation/fisher/numpy2_<campaign>"
# Open http://localhost:8001/dashboard/

Record per-case outcomes and old/new backend comparisons before merging. Explain pre-existing failures and investigate new failures or unexplained drift. After reviewing the data, the maintainer can run make fisher-upload in the data repo and commit/publish its updated validation/fisher.dvc manifest. That target includes the entire Fisher archive, including new campaign subdirs; review its scope first. Uploading and publishing are separate user actions.