Skip to content

Verification & Benchmarks Overview

FlexMESA compares its numerical kernels, microphysics evaluators, linear solvers, and stellar evolution drivers against upstream Fortran MESA (release 26.4.1, commit c8c2026, Zenodo record 19722306) across four execution paths:

  1. Fortran Comparator (gfortran -O2 -fopenmp): Compiled against MESA r26.4.1 static archives in benchmarks/fortran_mesa/. Across the 28 benchmark workloads, 21 call MESA subroutines in all stages, 3 call MESA in Stages 0-1 and Reference Fortran in Stages 2-3 (auto_diff, mtx_tridiag, chem_comp), 3 combine MESA utilities with local loops (w5_diff_rot, w5_binary_rlof, w5_astero_seism), and 1 is standalone non-MESA Reference Fortran (w5_riemann_rsp2).
  2. Safe Rust (crates/flexmesa-*): Canonical implementation in NumericsMode::Strict (crlibm, no FMA contraction, 4-thread rayon pool).
  3. Python / PyO3 (flexmesa._rust): Zero-copy C-contiguous numpy.float64 bindings releasing the Python GIL.
  4. Python / JAX (@jax.jit & jax.vmap in float64): Derived XLA GPU kernels validated against Safe Rust strict mode (#166, DECISIONS #17, #23).

The acceptance pass rate against MESA 26.4.1 references currently stands at 96 / 106 passing cases (10 declared gaps, 0 awaiting reference runs; see Declared Known Gaps and Port Coverage Map).


Provenance & Representative MESA r26.4.1 Timings

  • Raw archive: benchmarks/raw/26.4.1/ (provenance.json, fortran_wave*.txt, rust_waves_1_to_5.txt, python_waves_1_to_5.json).
  • Capture timestamp (UTC): 2026-11-17T22:46:37Z (with clean fortran_wave3b.txt and fortran_wave4.txt rerun from a relative MESA_DIR layout at 2026-11-17T23:25:34Z on base commit b5b6abd).
  • Continuous verification: ci_continuous_verification = false (CI builds and tests Safe Rust, PyO3, and JAX without a MESA installation, so the Fortran comparators run offline on a workstation).
  • Host hardware: AMD Ryzen 7 9800X3D 8-Core Processor (16 logical cores, OMP_NUM_THREADS=4, RAYON_NUM_THREADS=4), NVIDIA GeForce RTX 5080, Linux x86_64.
  • Toolchains: MESA r26.4.1, SDK x86_64-linux-26.6.1, GNU Fortran (GCC) 15.2.0 (-O2 -fopenmp -cpp -ffree-form -ffree-line-length-none), rustc 1.100.0 (0ef1bc386 2026-11-09), Python 3.14.0, JAX 0.11.0 (gpu, jax_enable_x64=True).
  • Workload taxonomy (28 workloads, 84 (workload, N_zones) points): 21 full MESA r26.4.1 workloads, 3 mixed MESA 0-1 / Ref. Fortran 2-3 workloads (auto_diff, mtx_tridiag, chem_comp), 3 hybrid Reference Fortran workloads (w5_diff_rot, w5_binary_rlof, w5_astero_seism), and 1 standalone non-MESA Reference Fortran workload (w5_riemann_rsp2).

  • Checksum accounting: Across all 57 (workload, N_zones) operating points in Waves 1-3b, Safe Rust and Fortran match across all 9 printed significant digits. The full float64 Python checksums differ from the printed Fortran values by at most 4.84e-09, within the 5e-09 rounding of a 9-digit print. The 1D stellar-structure workloads diverge on all five cases: across all sizes the Rust and Fortran checksums differ by between 2.10e-06 and a factor of 12.6 (the star_remesh stages also time different work). Wave 5 w5_diff_rot diverges by 99.17% (#158).

  • Cases where Fortran is faster: At 4 threads, Fortran is faster than Safe Rust on interp_2d, mtx_tridiag (batch Thomas), ion_fe56, star_hydro_eqns, star_newton_step, w5_diff_rot, w5_binary_rlof, and w5_astero_seism. star_remesh is not listed either way: its Fortran stage times only set_mesh_function_data, while the Rust stage times the whole do_adjust_mesh.
Physics Domain Workload (\(N_{\mathrm{zones}}\)) Comparator Comparator 4t (\(\mu\mathrm{s}\)) Safe Rust 4t (\(\mu\mathrm{s}\)) JAX vmap Batch/4 (\(\mu\mathrm{s}\)) Scope & Result Notes
Turbulent Convection turb_tdc (4096) MESA r26.4.1 (all stages) 49494.47 2566.56 (19.28x) 391.66 (126.37x) MESA set_TDC; scalar f64 root + IFT (DualOrder1<6>)
Mixing Length Theory turb_mlt (4096) MESA r26.4.1 (all stages) 1797.47 300.97 (5.97x) 68.38 (26.29x) MESA set_MLT; closed-form cubic root + IFT tangents
Synthetic Photometry colors_sed (1024) MESA r26.4.1 (all stages) 25299.86 1619.97 (15.62x) 689.47 (36.69x) MESA colors; 32-gather stencil + precomputed Simpson weights
Model Atmospheres atm_table (4096) MESA r26.4.1 (all stages) 1954.16 255.46 (7.65x) 367.99 (5.31x) MESA atm_eval_table; pre-validated bicubic spline lookup
4D Tabulated EOS eos_4d (4096) MESA r26.4.1 (all stages) 2697.28 839.76 (3.21x) 333.70 (8.08x) MESA eosDT_get; sorted patch_lut + stack 16-channel blend
Analytical Skye EOS eos_skye (4096) MESA r26.4.1 (all stages) 16540.28 9525.61 (1.74x) 4202.59 (3.94x) MESA eosDT_get_component; OnceLock<NuclideCatalog> + AD
Nuclear Networks net_eval (4096) MESA r26.4.1 (all stages) 26085.18 5411.82 (4.82x) 5210.01 (5.01x) MESA net_get; real(qp) sums + thread-local buffers
2D Bicubic Spline interp_2d (4096) MESA r26.4.1 (all stages) 41.69 70.69 (0.59x) 318.67 (0.13x) MESA interp_evbicub_db; Fortran 4t faster; printed checksums identical
1D Hydro Equations star_hydro_eqns (1024) MESA r26.4.1 (all stages) 2962.80 13814.92 (0.21x) 541.21 (5.47x) MESA eval_equ; Fortran 4t faster; 1.60e-5 checksum diff
1D Stellar Evolution star_evolve_step (1024) MESA r26.4.1 (all stages) 235422.09 59578.93 (3.95x) 66017.92 (3.57x) Unequal dt = 100 s vs base.dt; checksum diff 7.48e-6
Riemann Hydro & RSP2 w5_riemann_rsp2 (1024) Ref. Fortran (non-MESA) 45.71 12.16 (3.76x) 323.75 (0.14x) Non-MESA Reference Fortran (bench_kernels_wave5.f90)

1. Foundational Numerics, Splines, Neutrinos & Convection

MESA 26.4.1 Wave 1 four-way runtime staircase for foundational numerics, splines, neutrinos, and convection

2. Composition Moments, Partial Ionization & Kurucz SED Photometry

MESA 26.4.1 Wave 2 four-way runtime staircase for composition moments, Fe56 ionization, and Kurucz SED synthesis

3. Analytical & Single-Table Equations of State (Ideal, HELM, PC, Skye)

MESA 26.4.1 Wave 3a four-way runtime staircase for Ideal, HELM, PC, and Skye equations of state

4. 4D Tabulated EOS, Opacities, Reaction Networks & Model Atmospheres

MESA 26.4.1 Wave 3b four-way runtime staircase for 4D EOS, opacity, reaction rates, networks, and atmospheres

5. 1D Stellar Structure, Henyey Solver & Coupled Evolution Step

MESA 26.4.1 four-way runtime staircase for 1D stellar structure, Henyey Newton step, remeshing, and coupled evolution

6. Reference Fortran Comparator vs. FlexMESA (w5_*, Hybrid & Non-MESA)

Wave 5 four-way runtime comparison against Reference Fortran hybrid and non-MESA comparators


Reproducing the Benchmarks Locally

Run the standalone Rust benchmark binary, Python/JAX suite, or (when a local MESA 26.4.1 build is installed) the Fortran comparator drivers:

# 1. Safe Rust Waves 1-5 CLI table (`--quick` runs N_zones=8 smoke pass)
cargo run --release -p flexmesa-bench --bin run_rust_benchmarks -- --quick

# 2. Fortran comparator against a local MESA 26.4.1 checkout
make -C benchmarks/fortran_mesa MESA_DIR=/path/to/mesa run
from flexmesa import bench

# Quick 128-zone Wave 1 PyO3 / JAX timing pass
records = bench.run_all_wave1_benchmarks(
    zone_counts=(128,), n_warmup=1, n_repeats=2
)
for rec in records[:3]:
    print(
        f"{rec.workload:12s} n_zones={rec.n_zones:4d} "
        f"stage0={rec.stage0.median_us:8.2f} us "
        f"checksum={rec.checksum:.8e}"
    )

For all 28 benchmark workload tables, see Kernel Performance Scorecards. For tolerance rules and documented discrepancies, see Tolerance & Discrepancy Ledger.