Skip to content

Forward all supported params to the Fortran run - #233

Merged
neuromechanist merged 1 commit into
mainfrom
228-param-forwarding
Aug 15, 2026
Merged

neuromechanist merged 1 commit into
mainfrom
228-param-forwarding

Conversation

@neuromechanist

Copy link
Copy Markdown
Member

Fixes the harness half of #228. The gate-design half (what to do about a non-reproducible reference) is separate and still open.

Problem

run_fortran_amica rewrote six hardcoded keys — files, outdir, max_iter, lrate, pdftype, num_mix_comps — and passed every other line of the template through untouched. Any other setting in the caller's params was honored on the Python side and silently ignored on the Fortran side.

params["do_newton"] = False therefore ran Python without Newton against a reference still using it. The harness already warns about params the NG backend cannot honor; the reverse direction was unguarded, and it is the direction that quietly makes a comparison uncontrolled. It bit me while investigating #228: an experiment I ran to rule out Newton was invalid and I did not notice until reading the writer.

This also matters now that block_size defaults to 8192 (#229) while the template says 512.

Fix

write_fortran_param_file forwards every param the binary accepts, rewriting the template line or appending when the template lacks it — the binary accepts 88 keywords, the shipped input.param lists 74.

The accepted set is parsed from amica15.f90's own case('...') arms rather than hardcoded, so it cannot drift from the binary being run. If the source is unavailable the filter disables itself rather than dropping settings.

Anything the binary does not accept is reported by name. device/seed/dtype configure our side only and are exempt, so the warning stays meaningful.

Three params.json spellings differ from the Fortran keyword and are aliased: num_mix→num_mix_comps, share_int→share_iter, maxrej→numrej. Booleans become 0/1.

Two bugs in my first cut, caught by testing

  • Params clobbered the harness's own files/outdir, pointing the reference run at the path from params.json. Overrides are now applied last.
  • I aliased max_decs→maxdecs, which is wrong: max_decs is the keyword, maxdecs only the internal variable. The alias made a supported key look unsupported.

Both are covered by tests.

Tests

pamica/tests/test_fortran_param_forwarding.py, 10 tests: do_newton and block_size forwarding (the two that motivated this), alias translation, appending keys absent from the template, overrides winning, untouched template values surviving, unsupported keys being reported, and Python-only keys staying quiet.

Note

This does not make the reference reproducible — it has no seed parameter, and that is the rest of #228.

@neuromechanist
neuromechanist merged commit 332563d into main Aug 15, 2026
7 checks passed
@neuromechanist
neuromechanist deleted the 228-param-forwarding branch August 15, 2026 23:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fortran reference binary is not reproducible; single-run parity gate is unstable

1 participant