FTorch

FTorch is a library for coupling PyTorch models to Fortran. This is done by interfacing Fortran with the libtorch C++ backend underlying PyTorch, via the iso_c_binding module, which has been intrinsic to Fortran since the 2003 standard. It’s an interesting project to work on, as it involves working with code in Python, C, C++, and Fortran, amongst other languages, software frameworks, and tools used for testing, linting, scripting, and documentation.

Major contributions

I have been a core developer of FTorch since joining ICCS. Some major contributions of mine include:

  • Enabling running on multiple GPU devices.

  • Setting up and writing unit tests using the pFUnit unit test framework.

Project as Co-PI

Online training of large-scale Fortran-based hybrid computational science models, with applications in climate science

Co-PI with Jack Atkinson.

Development tasks

  • Set up online training in FTorch.

  • Expose PyTorch’s Autograd functionality in FTorch, meaning gradient values can be tracked across mathematical operations acting on Torch Tensors.

Community tasks

Project information

This work was done as an RSE at the Institute of Computing for Climate Science (ICCS). It was supported by both ICCS and by a joint grant from the Cambridge Centre for Data-Driven Discovery (C2D3) and ai@cam’s Accelerate Programme.

Resources

  • FTorch software description paper: [1].