Skip to content

Which Instrument for Which Symptom

FlexMESA provides a layered set of diagnostics for localizing differences against upstream MESA 26.4.1, isolating non-determinism, and comparing standalone microphysics or oscillation outputs at the IEEE-754 binary64 level. Choosing the right instrument first saves full-trajectory reruns and prevents chasing downstream symptoms that originate earlier in a step or stage.

Diagnostic runs versus strict acceptance

Commands that accept --allow-unsupported-controls run past unported upstream &star_job or &controls keys for triage, whereas acceptance checks require strict control validation without ignored controls (flexmesa harness run). MESA reference overlays also run against a private scratch copy of $MESA_DIR (MESA_SKIP_OPTIONAL=t unless noted otherwise) so the pristine upstream tree stays untouched.


1. The Divergence Localization Ladder

When a test-suite case differs from MESA 26.4.1 or drifts between configurations, narrow the discrepancy from coarse trajectory behavior down to the first differing solver record, kernel call, or floating-point bit:

flowchart TD
    S["1. Trajectory check (flexmesa harness run / flexmesa trace)"] --> Q1{"First difference at model 1 or later?"}
    Q1 -- "Model 10+" --> B["2. Automated window search (flexmesa trace bisect)"]
    Q1 -- "Model 1..3" --> C["3. Solver step dump (flexmesa trace --compare)"]
    B --> C
    C --> Q2{"First differing record tag"}
    Q2 -- "STATE / DM / AUX" --> R["4a. Routine replay or pre-solver state tap (flexmesa-replay, oracles)"]
    Q2 -- "EQU / CALL dt / CORR / TRY" --> X["4b. Opt-in XTRA scalars and Jacobian blocks (run_stepdumps.py --xtra star)"]
    Q2 -- "Domain-specific (RSP, RLOF, GYRE, omega)" --> D["4c. Targeted domain wrapper (-Wl,--wrap, LD_PRELOAD, XTRA binary-rlo)"]

Work down this ladder from coarse trajectory to single routine:

  1. Confirm the trajectory and stage: determine whether the symptom is an unsupported control, a stage or step-count mismatch, an inlist interval artifact, or a numerical trajectory shift.
  2. Pinpoint the first differing model: avoid manually stepping through thousands of lines of LOGS/history.data when flexmesa trace bisect can binary-search monotonic stages using cached MESA step-dump bundles (mesa_stepdumps, mesa_stepdump_windows).
  3. Inspect the first differing record inside that model: flexmesa trace --compare checks zone-level solver inputs (STATE, DM, AUX, EQU) before Newton iteration records (CALL, CORR, NEWTON, FOLD, TRY, RESID) and reports IEEE-754 hex bit patterns plus ULP distances.
  4. Isolate the responsible routine or kernel: once the differing variable, zone, or auxiliary field is known, drop down to record/replay (flexmesa-replay), Jacobian block dumps (--xtra star paired with FLEXMESA_STEPDUMP_XTRA_JAC_ZONES), linker-wrapped capture hooks (pulse_export_tap, astero_track_tap, lina_dgeev_oracle), or standalone Fortran module oracles (benchmarks/fortran_mesa/*_oracles/).

2. Symptom-to-Instrument Decision Table

Observed symptom First instrument to run Primary entry point What it sees What it misses or caveat
History column drifts, stops early, or misses termination Harness / incremental trace flexmesa harness run --cases <suite>/<case> --early-stop-on-divergence (star only) or flexmesa trace <suite> <case> --out <dir> Manifest track tolerances, step counts, stage counts, termination code, ignored controls, and per-step LOGS/history.data or binary_history.data --early-stop-on-divergence checks single-stage star cases only; cannot pinpoint which solver record, zone, or kernel caused the first shift inside a step
First history column differs at model N (all printed columns, bit-exact) No integrated bit-exact trace history comparator yet (#969) Run flexmesa trace <suite> <case> --out <dir> and compare emitted LOGS/ externally against cached MESA runs/ history_compare interpolates manifest tolerance columns on a coordinate grid and omits non-manifest columns Full un-interpolated comparator (python -m flexmesa.testing.full_history_compare from PR #968 once merged; flexmesa diff runs CLI wrapper planned under #969, no diff runs CLI command exists yet)
Step count, dt limiter, or retry reason differs from MESA No matched step-decision tap on both sides yet (#961) FLEXMESA_STEP_TRACE + FLEXMESA_STEP_TRACE_FILE (plus FLEXMESA_DISABLE_RUNTIME_CACHE=1 for cache isolation) Per-attempt retry events, argmax residual summaries, timestep collapses, omega_mix warnings, and binary outer/implicit retries inside FlexMESA FlexMESA-only decimal (6e) JSONL with no paired MESA dt-limiter / retry-reason comparator yet (#961); must set FLEXMESA_STEP_TRACE_FILE under trace subprocesses
Relax result or saved .mod model differs (star_job relax / pre-evolve) No committed .mod bitwise comparator or relax phase taps yet (#962) Compare initial STATE records via flexmesa trace --compare <dump> once evolution starts, or inspect saved .mod files directly STATE captures zone arrays at the first solver call of each dumped model Cannot localize differences inside relax_* phases or between saved .mod cells before solver entry (#962)
RSP last-bit residual or nonlinear oscillation evolution differs No RSP step dump yet (#963, #837) benchmarks/fortran_mesa/lina_dgeev_oracle/ (initial LINA eigenproblem only) lina_dgeev_oracle/ isolates initial dgeev matrix inputs and eigenvectors for LINA Current stepdump_patch.py and trace --compare hook star_solver only, which is bypassed when RSP_flag is set; nonlinear rsp_step dumps are tracked in #963 / #837
Monotonic stage diverges ten or more models into evolution Automated step-dump bisection flexmesa trace bisect <suite>/<case> --work-dir <dir> First model m below first_diverging_step + 1 where zone inputs or solver records leave bit identity, reusing mesa_stepdumps and mesa_stepdump_windows Exempt exit codes (0 found, 4 no diff, 1 failed, 3 MESA needed, 5 restart unsupported); later stages (--stage > 1) apply to star cases only
First difference is at model 1..3, after an in-stage restart, or in a known window Solver step-dump comparison (local or GitHub Actions case-run.yml) flexmesa trace <suite> <case> --out <dir> --compare <dump>.stepdump [--stage S --occurrence K] or gh workflow run case-run.yml -f mode=compare ... Bit-level STATE, DM, AUX, EQU, CALL, CORR, NEWTON, FOLD, TRY, and RESID records plus ULP distances Does not enter RSP when RSP_flag is set (#963); skips XTRA and RESTART records without diffing them
Batch triage needed across many cached MESA step dumps First-divergence summary table python benchmarks/fortran_mesa/stepdumps/first_divergence_table.py --dumps <dir> Aggregated Markdown and JSON table of first divergence model, record, column, and ULP distance across cases or windows Skips secondary stages of binary and astero dumps; passes --allow-unsupported-controls without flagging diagnostic rows in Markdown
STATE matches, but EQU, CORR, TRY, or CALL dt differs Manual inspection of opt-in solver XTRA and Jacobian blocks (#962) run_stepdumps.py --xtra star alongside FLEXMESA_STEPDUMP_XTRA_JAC_ZONES MESA emits START_*, RESID0/RESID_*, CORR_*, and JAC_L/D/U; FlexMESA emits SCALAR_gradT_excess_alpha, JAC_L/D/U, and MLT_* only trace --compare skips all XTRA records and Rust omits START_*/RESID*/CORR_* (#962), so XTRA comparison is manual today
AUX (Peos, opacity, gradT, mlt_vc, chiRho, chiT, Cp) differs at matching STATE Routine record/replay capture benchmarks/fortran_mesa/replay/run_capture.py, FLEXMESA_REPLAY_TAP, and flexmesa-replay Exact bit-for-bit inputs and outputs on TDC, MLT, GETR, and EOS calls fed identically into both engines Captures TDC, MLT, GETR, and EOS only; does not intercept arbitrary star routines
Binary implicit RLOF mdot or bracket convergence differs Binary RLOF XTRA or instrumented fixture run_stepdumps.py --xtra binary-rlo --xtra-binary-models FIRST:LAST or benchmarks/fortran_mesa/binary_rlof_fixture/instrumented/run_instrumented.py MESA explicit vs. implicit mdot, f, bracket bounds (mdot_lo, mdot_hi), find0_quadratic/find0 fallback, and rate clamps FlexMESA has no binary-rlo XTRA emitter yet, so compare manual .xtra values against FlexMESA solver/RLO logs; requires --xtra-binary-models
Rotation omega or adjust1_omega differs across remeshes Recycled omega sequence comparator benchmarks/fortran_mesa/recycled_omega/mesa_omega_tap.patch + compare_omega_reads.py Out-of-range reads past the previous remesh (prev_nz_old), matched in remesh order per star Targets binary_other_irot remesh buffer reads only (rotmix_oracles/ covers 1D rotational diffusion coefficients)
Oscillation frequencies, mode order, GYRE/FGONG/OSC exports, or astero tracks differ Pulsation call tap, exporter dump, and multi-track wrapper benchmarks/fortran_mesa/gyre_pulse_data/compare_pulse_live_run.py, pulse_export_tap/, astero_track_tap/ Separates exporter differences from live evolution drift, tracks every GYRE/ADIPLS call (l, m, n_pg, hex frequency, inertia, growth rate), and preserves per-track astero histories Astero search cases write raw mode files via FLEXMESA_PULSE_TAP; export comparison requires compiled MESA tap run for pulse_export_tap
Mid-run #684 windows (windows_e2e.toml) or radial profileN.data files differ No committed E2E window runner (#964, under #684) or profile comparator (#963) yet Plan/inspect windows with scripts/windows/{plan_windows.py,make_window_inlist.py} and emit profiles via flexmesa trace --write-profiles windows_e2e.toml records CRC32-seeded window boundaries and .mod rules; --write-profiles writes profileN.data files Requires external/manual comparison until the window runner (#964, under #684) and profile comparator (#963) land
Single microphysics kernel (eos, kap, net, turb, atm, math, newuoa) shifts by 1 ULP or diverges Module-hex gate & standalone Fortran hex oracle suites python -m flexmesa.testing.module_hex_gate, benchmarks/fortran_mesa/*_oracles/, op_mono_*, math_hex_vectors/, newuoa/, and scripts/mesa_reference/run_module_hex_tests.py Checks 0-ULP agreement for probed modules against known_module_gaps.toml (declared gaps allowed), and captures LD_PRELOAD libgfortran_hex_tap.so bit vectors Tests isolated module/oracle inputs outside coupled evolution; unprobed modules are declared in known_module_gaps.toml
Gap ledger drift or non-determinism across thread counts / hosts Known-gaps gate & strict determinism audit python -m flexmesa.testing.known_gaps_gate --fail-on-imperative-skips and scripts/check_strict_determinism.py Checks bijective test-gap declarations vs. known_gaps.toml, math hex vectors, and 1-thread vs. multi-thread / cross-architecture bit identity Checks repeatability and gap hygiene across FlexMESA configurations rather than divergence against MESA

3. Exact Invocations by Workflow

Trajectory Triage (flexmesa harness, flexmesa trace)

Run a single case in strict mode while saving every accepted row to LOGS/history.data (or binary_history.data), or let harness run stop as soon as tracked history columns leave manifest bounds:

flexmesa trace star 1.3M_ms_high_Z --out run_out
flexmesa harness run --cases star/1.3M_ms_high_Z --early-stop-on-divergence

For multi-stage star cases whose rn script normally skips optional early stages under MESA_SKIP_OPTIONAL=t, keep default stage skipping to match stored references (--full-stages includes optional early stages for standalone runs). Pass --respect-intervals only when matching MESA's inlist history_interval instead of logging every step.

Generating and Comparing Solver Step Dumps

First generate a MESA 26.4.1 step dump in a private overlay under an empty --scratch directory (never modifying $MESA_DIR):

python benchmarks/fortran_mesa/stepdumps/run_stepdumps.py \
    --mesa-dir "$MESA_DIR" \
    --mesasdk-root "$MESASDK_ROOT" \
    --scratch m_scratch \
    --out m_dumps \
    --steps 3 \
    --cases star/1.3M_ms_high_Z

To target a later window in stage S at the K-th crossing of model F (reusing an already-built overlay with --reuse-overlay):

python benchmarks/fortran_mesa/stepdumps/run_stepdumps.py \
    --mesa-dir "$MESA_DIR" \
    --mesasdk-root "$MESASDK_ROOT" \
    --scratch m_scratch \
    --reuse-overlay \
    --out m_dumps \
    --stage 2 --first-model 1 --occurrence 2 --steps 3 \
    --cases star/make_planets

Compare FlexMESA against that MESA .stepdump file (use --ignore to mask downstream columns or record tags once a lower-priority mismatch is already understood):

flexmesa trace star make_planets --out fm_out --compare m_dumps/star/make_planets.stepdump
flexmesa trace star make_planets --out fm_out --compare m_dumps/star/make_planets.stepdump --ignore EQU xa

flexmesa trace --compare exits 0 if every compared record is bit-identical, 2 if a difference is found, and 1 if the run fails. For remote single-case or windowed step-dump comparisons without tying up a local workstation, dispatch .github/workflows/case-run.yml in compare mode (against cached mesa_stepdumps or a specific -f window=<id> from mesa_stepdump_windows, failing on exit status 2):

gh workflow run case-run.yml --ref <branch> \
    -f cases="star/high_z star/ns_h" -f mode=compare [-f window=<window_id>]

To summarize a local directory of dumps and mid-run windows into Markdown and JSON tables:

python benchmarks/fortran_mesa/stepdumps/first_divergence_table.py \
    --dumps m_dumps \
    --work table_scratch \
    --markdown-out first_div.md \
    --json-out first_div.json

Automated Step-Dump Bisection (flexmesa trace bisect)

When divergence begins deep inside a monotonic stage, run flexmesa trace bisect with a dedicated --work-dir (rerunning the same command resumes from state.json):

flexmesa trace bisect star/1.3M_ms_high_Z --work-dir bisect_work

If cached bundles (mesa_stepdumps, mesa_stepdump_windows) do not cover the remaining interval, either provide --mesa-dir, --mesasdk-root, and --mesa-scratch so bisect generates the missing MESA window automatically, or let it print the exact run_stepdumps.py command and exit with code 3. Note that unlike flexmesa trace --compare (0 identical, 2 differs, 1 error), flexmesa trace bisect uses its own exit codes (trace_bisect.py):

  • 0: first differing model found and report printed.
  • 1: a FlexMESA or MESA run failed or exceeded --timeout-sec / --max-rss-gb (partial dumps are not trusted; rerun with higher limits).
  • 3: a MESA window is needed and --mesa-dir was not supplied.
  • 4: every window up to the harness's diverging model agreed.
  • 5: the target stage restarts its model numbers in-process (for example relax followed by evolve); localize those cases window by window with flexmesa trace --compare --occurrence.

When comparing a candidate source tree in parallel or under a compute wrapper, pass --flexmesa-src <worktree>/src, --run-prefix, and --mesa-prefix, or --skip-bundle mesa_stepdumps mesa_stepdump_windows together with explicit --mesa-dumps directories.

Solver XTRA Scalars, Jacobian Blocks, and Binary RLO Diagnostics (Manual Inspection)

When a step dump flags EQU, CORR, or CALL dt at a matching input STATE, you can capture additional solver scalars and block-tridiagonal Jacobian matrices (JAC_L, JAC_D, JAC_U) on MESA via --xtra star, and Jacobian + MLT_* + SCALAR_gradT_excess_alpha records on FlexMESA via FLEXMESA_STEPDUMP_XTRA_JAC_ZONES:

python benchmarks/fortran_mesa/stepdumps/run_stepdumps.py \
    --mesa-dir "$MESA_DIR" \
    --mesasdk-root "$MESASDK_ROOT" \
    --scratch m_xtra_scratch \
    --out m_xtra_dumps \
    --xtra star \
    --xtra-zones 36,37,262,474:481 \
    --xtra-corr-zones 1,262,474:481 \
    --stage 2 --first-model 9 --steps 3 \
    --cases star/make_planets

FLEXMESA_STEPDUMP_XTRA_JAC_ZONES=1,262,474:481 \
    flexmesa trace star make_planets --out fm_out \
    --compare m_xtra_dumps/star/make_planets.stepdump

With FLEXMESA_STEPDUMP_XTRA_JAC_ZONES set, flexmesa trace --compare writes FlexMESA's step dump (including XTRA records) to fm_out/flexmesa.stepdump and prints skipped unknown record types: XTRA x... in the summary.

Manual XTRA inspection (#962)

flexmesa trace --compare skips and counts XTRA (and RESTART) lines without diffing them, and FlexMESA currently emits only SCALAR_gradT_excess_alpha, JAC_L/JAC_D/JAC_U, and MLT_* (no START_*, RESID0_*, RESID_*, or CORR_* records yet). Compare XTRA lines between m_xtra_dumps/star/<case>.stepdump and fm_out/flexmesa.stepdump manually, and match MLT_* derivatives by semantic variable rather than raw slot index because FlexMESA's internal 24-slot AD vector orders partials differently from MESA's 33-slot d1Array.

For implicit Roche-lobe overflow iterations in binary cases, capture binary/<case>.xtra on MESA across the target model range (FlexMESA has no binary-rlo XTRA emitter yet, so inspect the captured MESA .xtra iterations manually alongside binary step logs):

python benchmarks/fortran_mesa/stepdumps/run_stepdumps.py \
    --mesa-dir "$MESA_DIR" \
    --mesasdk-root "$MESASDK_ROOT" \
    --scratch m_rlo_scratch \
    --out m_rlo_dumps \
    --xtra binary-rlo \
    --xtra-binary-models 102:102 \
    --cases binary/wind_fed_bhhmxb

Routine Record/Replay (flexmesa-replay)

When zone-level AUX values (Peos, opacity, gradT, mlt_vc, chiRho, chiT, Cp) differ on matching STATE inputs, capture TDC, MLT, GETR, and EOS routine calls from MESA and replay them inside flexmesa-replay:

python benchmarks/fortran_mesa/replay/run_capture.py \
    --mesa-dir "$MESA_DIR" \
    --mesasdk-root "$MESASDK_ROOT" \
    --scratch replay_scratch \
    --out replay_out \
    --models 1 \
    --cases star/conserve_angular_momentum

cargo run --release -p flexmesa-replay -- replay_out/star/conserve_angular_momentum.replay

To compare routine-level captures directly between MESA and FlexMESA (writing FlexMESA's capture with FLEXMESA_REPLAY_TAP=<file>, optionally scoped by FLEXMESA_REPLAY_TAP_MODELS and FLEXMESA_REPLAY_TAP_FIRST):

FLEXMESA_REPLAY_TAP=fm.replay FLEXMESA_REPLAY_TAP_MODELS=1 \
    flexmesa trace star conserve_angular_momentum --out fm_out --max-steps 1

cargo run --release -p flexmesa-replay -- compare \
    replay_out/star/conserve_angular_momentum.replay fm.replay --all-diffs

Pulsation, Astero Tracks, Recycled omega, and Module Hex Oracles

  • Live oscillation calls (GYRE / ADIPLS): compare every mode call and emission label (l, m, n_pg) against MESA pulse_tap/modes.tsv:
python benchmarks/fortran_mesa/gyre_pulse_data/compare_pulse_live_run.py \
    --suite astero --case example_astero \
    --histories path/to/mesa_histories \
    --work pulse_work --out pulse_cmp.tsv
  • Pulse export isolation (GYRE / FGONG / OSC): capture exact star_info arrays entering export_pulse_data with benchmarks/fortran_mesa/pulse_export_tap/ (pulse_dump_tap.f90, pulse_dump_wrap.c).
  • Multi-track astero histories: preserve every run1_star objective evaluation without LOGS/history.data overwrites via benchmarks/fortran_mesa/astero_track_tap/run_tracks.sh.
  • Recycled omega reads past prev_nz_old: match remesh buffer reads in order across MESA and FlexMESA tap files:
python benchmarks/fortran_mesa/recycled_omega/compare_omega_reads.py \
    MESA_TAP.txt FLEXMESA_TAP.txt --limit 145
  • Standalone microphysics, module-hex gate, and gap-ledger gates: build module oracle TSV/hex vectors against $MESA_DIR using each subdirectory's Makefile (under benchmarks/fortran_mesa/*_oracles/, op_mono_*, math_hex_vectors/, newuoa/) or intercept all MESA <module>/test/ floating-point writes using scripts/mesa_reference/run_module_hex_tests.py. Check repository-level module-hex conformance against known_module_gaps.toml and bijective test-gap declarations with:

python -m flexmesa.testing.module_hex_gate --check-summary
python -m flexmesa.testing.known_gaps_gate --fail-on-imperative-skips
- Strict thread and cross-architecture determinism: check math_hex_vectors conformance and 1-thread vs. multi-thread history identity with scripts/check_strict_determinism.py:

python scripts/check_strict_determinism.py --json-out det_host_a.json
python scripts/check_strict_determinism.py --compare det_host_a.json det_host_b.json
  • Retry-cascade JSONL telemetry & cache bypass: enable FLEXMESA_STEP_TRACE (1-based starting step number) with FLEXMESA_STEP_TRACE_FILE so subprocess-guarded flexmesa trace runs append single-line JSON events rather than losing stderr, or pass FLEXMESA_DISABLE_RUNTIME_CACHE=1 to rule out derived runtime cache effects:
FLEXMESA_STEP_TRACE=780 FLEXMESA_STEP_TRACE_FILE=step_trace.jsonl \
    flexmesa trace star <case> --out fm_out
FLEXMESA_DISABLE_RUNTIME_CACHE=1 \
    flexmesa trace star <case> --out fm_nocache

4. Interpreting Output and Avoiding Common Traps

  1. Zone records come before solver records. In flexmesa trace --compare, zone arrays (STATE, DM, AUX, EQU) at a model's first solver call are compared before CALL, CORR, NEWTON, FOLD, TRY, and RESID. A timestep shift at the end of model m therefore shows up at model m + 1 first in STATE/EQU (and in CALL's dt line if zone arrays agree or are masked).
  2. Reading mismatch classifications cleanly:
  3. missing: one engine stopped early or wrote fewer models, zones, or solver iterations.
  4. zone: first zone-level bit mismatch in STATE, DM, AUX, or EQU; inspect the per-column summary to see whether all zones shifted uniformly or one localized shell moved.
  5. control: solver iteration structure diverged (CALL/CORR/TRY/RESID record tag or counter mismatch, such as an extra Newton iteration or line-search backtrack).
  6. value: identical solver step structure with differing binary64 bits; check ULP distance (1 ULP often points to operation ordering, fused multiply-add, or elementary math evaluation, while > 10^6 ULPs points to a missing term or sign).
  7. location: same scalar norm bits, different argmax (zone, index) tie-break.
  8. Hex bit patterns preserve signed zero and special values. Step dumps and hex taps print 16-digit IEEE-754 binary64 integers (0000000000000000 for +0.0 versus 8000000000000000 for -0.0, exact signaling/quiet NaN payloads). Treating -0.0 == +0.0 at decimal readout can miss sign-bit differences that propagate later through branch conditions.
  9. Understand MESA sizequ residual weights. When do_burn or do_mix is active, MESA's residual_norm (sizequ in star/private/solver_support.f90) adds chemistry equations twice (j > nvar_hydro), dividing by (nvar + nvar_chem) * nz. Comparing RESID_EQUSUM against RESID norms reproduces this weighting directly.
  10. Alignment rules when model numbers reset or overlap. In runs with relax phases before evolution, --first-model F --occurrence K counts both upward crossings of F and drops in model_number landing at or above F. For stage-by-stage dumps (--stage S), MESA numbers each ./rn executable that reaches star_solver by its RUN record; in multi-star or restarted outputs, avoid deduplicating solely on model_number.
  11. Guard private diagnostic edits strictly outside baselines. Never edit $MESA_DIR in place or keep unverified private run_star_extras.f90 edits in reference bundles; delete disposable scratch overlays after recording measurements.