Skip to content

Honor ran_seed in deterministic runs#452

Merged
krystophny merged 2 commits into
fix/ci-slow-test-gatesfrom
fix/deterministic-ran-seed
Jul 12, 2026
Merged

Honor ran_seed in deterministic runs#452
krystophny merged 2 commits into
fix/ci-slow-test-gatesfrom
fix/deterministic-ran-seed

Conversation

@krystophny

@krystophny krystophny commented Jul 11, 2026

Copy link
Copy Markdown
Member

Fixes #464

Risk tier

  • T0: docs, comments, small build metadata
  • T1: pure refactor, no behavior change intended
  • T2: local numerical logic
  • T3: physics, output behavior, coordinate convention
  • T4: parallelism, GPU, dependency, CI, or security-sensitive build logic

Correctness contract

Intended behavior change

ran_seed controls the Fortran random stream when deterministic=.true.. Equal seeds reproduce the stream; different seeds change it.

Behavior that must not change

Orbit equations, integrators, field evaluation, loss criteria, parallel dispatch, and deterministic replay for an explicitly fixed seed are unchanged.

Coordinate / unit conventions

No coordinate, unit, boundary, or symmetry convention changes.

Numerical invariants

Only sampled initial conditions may change. The historical NetCDF fixture now explicitly requests seed 42. The chartmap pipeline keeps its existing calculations, assertions, and plots.

Tests added

  • unit: namelist-level deterministic seed regression
  • integration: existing NetCDF orbit output, verification, and plot tests
  • system: full fo pipeline
  • golden record: not regenerated

Golden-record impact

  • unchanged
  • changed

Failure modes considered

Same-seed non-reproducibility, ignored distinct seeds, invalid orbit fixture sample, and plot-enabled chartmap runtime exceeding its former 60 s timeout.

Manual validation

The NetCDF fixture passes with its historical seed 42. The plot-enabled chartmap pipeline passes in 59.71 s with a 120 s timeout.

Verification

Test fails on main

fo test test_deterministic_seed
ERROR STOP different ran_seed values produce the same random stream
Summary: 0 passed, 1 failed

Test passes after fix

fo test test_deterministic_seed
test_deterministic_seed PASS 0.06s
Summary: 1 passed, 0 failed, 0 skipped

fo
Static: OK
Build: OK
Tests: OK
Lint: OK
All stages passed

@krystophny krystophny added tier/T3 physics or output behavior size/S review size up to 100 changed lines labels Jul 11, 2026
@krystophny krystophny force-pushed the fix/deterministic-ran-seed branch from d8c9352 to 915798b Compare July 12, 2026 01:05
@krystophny krystophny changed the base branch from main to fix/ci-slow-test-gates July 12, 2026 01:05
@krystophny krystophny force-pushed the fix/deterministic-ran-seed branch from bd9fa01 to 9c26d08 Compare July 12, 2026 15:20
@krystophny krystophny force-pushed the fix/ci-slow-test-gates branch from b8ccb2d to 89bf5a6 Compare July 12, 2026 15:44
@krystophny krystophny force-pushed the fix/deterministic-ran-seed branch from 9c26d08 to 6af10a4 Compare July 12, 2026 15:44
@krystophny krystophny merged commit d8506f9 into fix/ci-slow-test-gates Jul 12, 2026
7 checks passed
@krystophny krystophny deleted the fix/deterministic-ran-seed branch July 12, 2026 20:23
krystophny added a commit that referenced this pull request Jul 12, 2026
Re-lands #452 on `main`. That pull request was squash-merged into its
stacked
base `fix/ci-slow-test-gates` (#454), so `main` never received the fix.
This
branch cherry-picks the squash commit `d8506f9` onto current `main`
(`3cfba79`); it applied without conflicts.

Deterministic runs ignored `ran_seed` and always produced the default
stream,
so distinct seeds could not generate independent particle sets.
`params.f90`
now forwards the configured seed, `test_deterministic_seed.f90` checks
that
distinct seeds change the stream while the default seed reproduces the
previous one, and the orbit-output example input records the seed it
uses.

## Verification

### Test fails on main

`src/params.f90` reverted to `origin/main`, test kept:

```
$ fo test test_deterministic_seed
test_deterministic_seed                    FAIL       0.11s
Summary: 0 passed, 1 failed, 0 skipped (  0.11s)
```

### Test passes after fix

```
$ fo test test_deterministic_seed
test_deterministic_seed                    PASS       0.12s
Summary: 1 passed, 0 failed, 0 skipped (  0.12s)
```

`fo build` and `fo lint` pass on the branch (no new warnings; 0 unused
imports).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/S review size up to 100 changed lines tier/T3 physics or output behavior

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant