Skip to Main Content

f2j

Built at Meta Global AI Developer Hackathon · Oct 26, 2026 · Remote

f2j — Demo video

Climate, weather, ocean and engineering models still run on Fortran written before GPUs existed. That code can’t run on GPUs, can’t be differentiated for calibration or machine learning, and the people who wrote it are retiring. Rewriting it by hand takes years, and nobody can prove the rewrite is right. f2j translates Fortran into JAX one routine at a time and checks each translation against the original. Muse Spark (muse-spark-1.3 on the Meta Model API) writes the code. The original Fortran, compiled with f2py, is the judge. Every candidate must pass five checks: it compiles it matches the Fortran to a relative tolerance of 1e-10 it gives the same results when batched with jax.vmap its gradients agree with finite differences of the Fortran it passes held-out tests the model never sees gcov shows that the tests actually reach the code. When a candidate fails, Muse Spark gets the exact mismatch plus a hint such as “output is transposed”, and tries again. Routines that can’t be translated safely, such as ones that keep hidden state, stay in Fortran behind a JAX callback, so the whole model still runs. On the repo’s shallow-water example, the live run with Muse Spark gave these results: 8 of 9 routines translated, each passing all five checks on its first try; the ninth stayed in Fortran by design 8 model calls, 51 seconds, $0.05 over 200 time steps, the JAX model stayed within 2 × 10⁻¹⁴ of the Fortran The translated model can then do things the Fortran never could: recover a physical parameter from data in five Gauss–Newton steps, using derivatives through the whole model run a 64-member ensemble about 4× faster per member on a laptop CPU You can try it in about two minutes with no API key: an offline replay mode reproduces the full pipeline, including the repair loop.

Team