FTorch: a library for coupling PyTorch models to Fortran
Open Access
- 5 March 2025
- journal article
- Published by The Open Journal in Journal of Open Source Software
- Vol. 10 (107) , 7602
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.Keywords
This publication has 13 references indexed in Scilit:
- Interpretable Multiscale Machine Learning‐Based Parameterizations of Convection for ICONJournal of Advances in Modeling Earth Systems, 2024
- Uncertainty Quantification of a Machine Learning Subgrid‐Scale Parameterization for Atmospheric Gravity WavesJournal of Advances in Modeling Earth Systems, 2024
- A State-of-the-Art Review on Machine Learning-Based Multiscale Modeling, Simulation, Homogenization and Design of MaterialsArchives of Computational Methods in Engineering, 2022
- Using Machine Learning at scale in numerical simulations with SmartSim: An application to ocean climate modelingJournal of Computational Science, 2022
- The State of FortranComputing in Science & Engineering, 2022
- Physics-informed machine learning: case studies for weather and climate modellingPhilosophical Transactions of the Royal Society A: Mathematical, Physical and Engineering Sciences, 2021
- Machine learning and the physical sciencesReviews of Modern Physics, 2019
- A parallel Fortran framework for neural networks and deep learningACM SIGPLAN Fortran Forum, 2019
- Deep learning to represent subgrid processes in climate modelsProceedings of the National Academy of Sciences, 2018
- Clouds, circulation and climate sensitivityNature Geoscience, 2015