Unlocking Gradients in Legacy Fortran Code with LFortran and Enzyme

Differentiable Fortran with LFortran and Enzyme

12dionhaefner💬 1
Unlocking Gradients in Legacy Fortran Code with LFortran and Enzyme

I explored how to backpropagate through decades of validated Fortran physics code without rewriting it in JAX or PyTorch. By combining LFortran and Enzyme at the LLVM level, we extract exact gradients from legacy simulations, turning them into differentiable layers for modern machine learning pipelines. While experimental and demanding, this approach bridges the gap between high-performance scientific computing and automatic differentiation.

"It's amazing to see that a stack combining some of the oldest and newest technologies can work together at all."

More from this day · 2026-07-14