2024-05-08
To access links or follow on your own device these slides can be found at:
jackatkinson.net/slides
Except where otherwise noted, these presentation materials are licensed under the Creative Commons Attribution-NonCommercial 4.0 International (CC BY-NC 4.0) License.
Vectors and icons by SVG Repo under CC0(1.0) or FontAwesome under SIL OFL 1.1
In ~1916 Lewis Fry Richardson1 attemted2 to compute a 1 day forecast by hand using partial differential equations3.
He went on to publish Weather Prediction by Numerical Process (Richardson 1922)
Images from the Met Office in the UK, Fair Use.
In Weather Prediction by Numerical Process (Richardson 1922) LFR envisaged a “Forecast Factory”.
He lived to see this realised, albeit in a different setting, on ENIAC1 by Charney, the von Neumans et al. in 1950.
ENIAC by US serviceperson, Public Domain.
The Forecast Factory by Stephen Conlin (1986), Fair Use.
Climate models are large, complex, many-part systems.
Subgrid processes are largest source of uncertainty
Microphysics by Sisi Chen Public Domain
Staggered grid by NOAA under Public Domain
Globe grid with box by Caltech under Fair use
Subgrid processes are largest source of uncertainty
Microphysics by Sisi Chen Public Domain
Staggered grid by NOAA under Public Domain
Globe grid with box by Caltech under Fair use
We typically think of Deep Learning as an end-to-end process;
a black box with an input and an output1.
Who’s that Pokémon?
\[\begin{bmatrix}\vdots\\a_{23}\\a_{24}\\a_{25}\\a_{26}\\a_{27}\\\vdots\\\end{bmatrix}=\begin{bmatrix}\vdots\\0\\0\\1\\0\\0\\\vdots\\\end{bmatrix}\] It’s Pikachu!
Neural Net by 3Blue1Brown under fair dealing.
Pikachu © The Pokemon Company, used under fair dealing.
Neural Net by 3Blue1Brown under fair dealing.
Pikachu © The Pokemon Company, used under fair dealing.
Many large scientific models are written in Fortran (or C, or C++).
Much machine learning is conducted in Python.
Mathematical Bridge by cmglee used under CC BY-SA 3.0
PyTorch, the PyTorch logo and any related marks are trademarks of The Linux Foundation.”
TensorFlow, the TensorFlow logo and any related marks are trademarks of Google Inc.
We consider 2 types:
Computational
Developer
iso_c_binding
.We will:
libtorch
C++ APIPython
env
Python
runtime
xkcd #1987 by Randall Munroe, used under CC BY-NC 2.5
Find it on :
pt2ts.py
aids users in saving PyTorch models to TorchscriptFind it on :
use, intrinsic :: iso_fortran_env, only : sp => real32
! Use the FTorch Library
use :: ftorch
implicit none
! Fortran variables
real(sp), dimension(1,3,244,244), target :: in_data
real(sp), dimension(1, 1000), target :: out_data
integer, parameter :: n_inputs = 1
integer :: in_layout(4) = [1,2,3,4]
integer :: out_layout(2) = [1,2]
! Torch Tensors
type(torch_tensor), dimension(1) :: in_tensors
type(torch_tensor) :: out_tensor
! Populate Fortran data
call random_number(in_data)
! Cast Fortran data to Tensors
! Create input/output tensors from the above arrays
in_tensors(1) = torch_tensor_from_array(in_data, in_layout, torch_kCPU)
out_tensor = torch_tensor_from_array(out_data, out_layout, torch_kCPU)
! Define a Torch module
type(torch_module) :: model
! Load in from Torchscript
model = torch_module_load('/path/to/saved/model.pt')
Cast Tensors to GPU in Fortran:
! Load in from Torchscript
model = torch_module_load('/path/to/saved/gpu/model.pt', torch_kCUDA, device_index=0)
! Cast Fortran data to Tensors
in_tensor(1) = torch_tensor_from_array(in_data, in_layout, torch_kCUDA, device_index=0)
out_tensor = torch_tensor_from_array(out_data, out_layout, torch_kCPU)
Derecho by NCAR
Dawn by Joe Bishop, with permission
Packaging:
When ML components are developed they typically have a:
normalisation routine
neural network architecture
de-normalisation routine
Enforcing of physical constraints
Several constituents to be transferred to host model.
Portability:
A neural net trained on a different model/dataset requires:
to function correctly.
Neural Network model trained in SAM2
To be re-deployed in CAM
Outputs are of the form \(\partial / \partial t\) so need to apply, convert, and difference.
The parameterisation:
The coupling:
MPI_Gather()
libtorch
available on the software stack
ICCS Research Software Engineers:
Previous Members:
FTorch:
MiMA
CESM
Get in touch: