cs.MSMar 17, 2026

Implementation of tangent linear and adjoint models for neural networks based on a compiler library tool

Authors: Sa Xiao, Hao Jing, Honglu Sun, Haoyu Li

Organizations: State Key Laboratory of Severe Weather Meteorological Science and Technology (LaSW), Beijing, China · CMA Earth System Modeling and Prediction Centre (CEMC), Beijing, China

Abstract

This paper presents TorchNWP, a compilation library tool for the efficient coupling of artificial intelligence components and traditional numerical models. It aims to address the issues of poor cross-language compatibility, insufficient coupling flexibility, and low data transfer efficiency between operational numerical models developed in Fortran and Python-based deep learning frameworks. Based on LibTorch, it optimizes and designs a unified application-layer calling interface, converts deep learning models under the PyTorch framework into a static binary format, and provides C/C++ interfaces. Then, using hybrid Fortran/C/C++ programming, it enables the deployment of deep learning models within numerical models. Integrating TorchNWP into a numerical model only requires compiling it into a callable link library and linking it during the compilation and linking phase to generate the executable. On this basis, tangent linear and adjoint model based on neural networks are implemented at the C/C++ level, which can shield the internal structure of neural network models and simplify the construction process of four-dimensional variational data assimilation systems. Meanwhile, it supports deployment on heterogeneous platforms, is compatible with mainstream neural network models, and enables mapping of different parallel granularities and efficient parallel execution. Using this tool requires minimal code modifications to the original numerical model, thus reducing coupling costs. It can be efficiently integrated into numerical weather prediction models such as CMA-GFS and MCV, and has been applied to the coupling of deep learning-based physical parameterization schemes (e.g., radiation, non-orographic gravity wave drag) and the development of their tangent linear and adjoint models, significantly improving the accuracy and efficiency of numerical weather prediction.

Explore similar work

CardsList
  1. The Neural Compiler: Program-to-Network Translation for Hybrid Scientific Machine Learning

    May 21, 2026Lucas ShenemanDifferentiable ProgrammingScientific ML

  2. The importance of tensor handling and implementation of physics-informed DeepONets

    Oct 15, 2026Nahum Banks, Gustavo A. M. de Almeida, Sergio MaldonadoPhysics-Informed Neural OperatorsPDE Operator Learning

  3. Hybrid coupling with numerics-informed neural networks and the overlapping Schwarz alternating method

    Sep 15, 2026George Chumbipuma, Irina Tezaur, Alejandro Diaz +1Neural PDE SolversPDE Solving