Differentiable Fortran with LFortran and Enzyme

Researchers are using LFortran and Enzyme to enable automatic differentiation in legacy Fortran, C, and C++ simulation code. This allows high-performance physics engines to be integrated into modern machine learning frameworks like JAX and PyTorch.
Why it matters
This technology bridges the gap between decades of validated scientific simulation code and modern AI pipelines, enabling more efficient research in fields like climate and aerospace.
What if you could backpropagate through existing Fortran, C, or C++ simulation code, embed it into JAX and torch, and use it as a high-performance differentiable physics engine? Turns out, you can — if you’re brave enough…
Decades of validated physics code in CFD, climate, aerospace, and nuclear sit behind a wall that modern ML pipelines can’t cross, because they don’t expose gradients. The usual answer is to rewrite it all in JAX or PyTorch. The alternative we explore here is to leave the code where it is and get exact gradients out anyway, thanks to some LLVM-level magic. This is possible because Enzyme applies autodiff at the LLVM IR level, so we can differentiate any code that compiles to LLVM!
Get smarter about the news
Sign up free for a feed built around what you actually care about, Dive Deeper research on any story, and the full text of every article.
Create free accountAlready have an account? Sign in