Litcius/Paper detail

FTorch: a library for coupling PyTorch models to Fortran

Jack Atkinson, Athena Elafrou, Elliott Kasoar, Joseph G. Wallwork, Thomas Meltzer, S. F. Clifford, Dominic Orchard, Christopher Edsall

2025The Journal of Open Source Software9 citationsDOIOpen Access PDF

Abstract

In the last decade, machine learning (ML) and deep learning (DL) techniques have revolutionised many fields within science, industry, and beyond. Researchers across domains are increasingly seeking to combine ML with numerical modelling to advance research. This typically brings about the challenge of programming language interoperation. PyTorch (Paszke et al., 2019) is a popular framework for designing and training ML/DL models whilst Fortran remains a language of choice for many high-performance computing (HPC) scientific models. The FTorch library provides an easy-to-use, performant, cross-platform method for coupling the two, allowing users to call PyTorch models from Fortran. FTorch is open-source, open-development, and well-documented with minimal dependencies. A central tenet of its design, in contrast to other approaches, is that FTorch removes dependence on the Python runtime (and virtual environments). By building on the LibTorch backend (written in C++ and accessible via an API), it allows users to run ML models on both CPU and GPU architectures without needing to port code to device-specific languages.

Topics & Concepts

FortranComputer scienceProgramming languageParallel computingComputational scienceCoupling (piping)Python (programming language)EngineeringMechanical engineeringModel Reduction and Neural NetworksParallel Computing and Optimization TechniquesScientific Computing and Data Management