Searcharxiv⌕ Search

arXiv · 2610.26694

CuAD: Source-to-Source Automatic Differentiation of CUDA Kernels for Discrete Adjoints in Computational Fluid Dynamics

Abstract

Discrete adjoint methods give the sensitivities that aerodynamic design and data assimilation require, but they remain hard to obtain for flow solvers that run on graphics processors. This paper presents CuAD, a source-to-source automatic differentiation tool that reads CUDA kernels and writes their tangent and adjoint versions as ordinary CUDA source. Its reverse mode is organised around the GPU thread and exploits the structure of flow-solver kernels: pure accumulations need no tape, the remaining intermediate values are recomputed rather than stored, and adjoint updates are atomic only where several threads reach the same memory. We evaluate CuAD on four kernels from simple flow models: a viscous Burgers residual, a two-dimensional advection-diffusion residual, a quasi-one-dimensional Euler residual and a Biot-Savart summation over point vortices. All generated derivatives agree with finite differences and pass adjoint dot-product tests to round-off, while the adjoint kernels cost two to six times the primal kernels. Compared with the compiler-based tool Clad under the same compiler, CuAD gives identical results at identical cost on the stencil kernels and is 16 to 470 times faster on the summation kernel because it stores no tape. A steady Burgers study shows that in single precision the adjoint gradient of a finite-difference Jacobian reaches errors of 45 to 75 per cent once the condition number grows to $2.5\times10^{5}$, whereas the CuAD Jacobian keeps the error below $5\times10^{-5}$. Four applications complete the evaluation: adjoint fields of the Burgers shock, the sensitivity of a scalar sensor in a cellular vortex, the inverse design of a transonic nozzle whose area is recovered to $2\times10^{-8}$, and an unsteady adjoint of the roll-up of a vortex sheet over 400 time steps.

Explore related subjects

Keep this discovery

Explore connections, maps & timelines

BibTeXRIS

Seunghyun Joo. 2026-10-19. CuAD: Source-to-Source Automatic Differentiation of CUDA Kernels for Discrete Adjoints in Computational Fluid Dynamics. https://arxiv.org/abs/2610.26694

Cite the original work for its findings. Save a collection to share your selection of sources.

KEEP EXPLORING

Related papers

IRENE: a fluId layeR finitE-elemeNt softwarE

We present a finite-element software library, IRENE, which allows to solve numerically the dynamics of a viscous fluid layer embedded in three-dimensional space. Unlike finite-element libraries present in the literature, IRENE can handle two-dimensional open surfaces with a wide range of boundary conditions, and inter-surface obstacles with any shapes, and is built upon the user-friendly and versatile finite element computational software (FEniCS). Also, the library can describe a wide range of physical regimes--both low-Reynolds-number and inertia-dominated ones--capturing the complex coupling between in-plane flows, out-of-plane deformations, surface tension, and elastic response. We validate IRENE against known analytical and numerical results, and demonstrate its capabilities through physical examples. Overall, IRENE provides a versatile and efficient tool for understanding fluid-layer dynamics on multiple physical scales, from flows of lipidic membranes on a microscopic level, to fluid flows on a macroscopic scale, to atmospheric air flows on a planetary level.

physics.flu-dyn↗

Coarse-grained local available potential energy

The available potential energy (APE) of a fluid can be defined locally in space, providing useful insights into both the energetics and dynamics of stratified flows ranging from three-dimensional turbulence to planetary scale circulations. Here we develop a framework for considering the multi-scale evolution of the local APE using a spatial filtering, or coarse-graining, approach. A scale decomposition valid generally for filters with both horizontal and vertical support is proposed, and shown to admit a construction in terms of a series of band-passed energies. The physical interpretation of the decomposition is discussed, and evolution equations for the APE at scales larger, and smaller, than the filtering scale are derived --- including the cross-scale APE flux term. These results can be paired with existing frameworks for coarse-grained kinetic energy, offering the potential for examining a complete energy cycle that accounts for conversions between both spatial scales and energy reservoirs. An illustrative example of the application of this approach to a simulation of three-dimensional Kelvin-Helmholtz instability is provided, including an exact formulation of the scale-dependent instability energy budgets, and the distribution of terms such as cross-scale transfers and APE dissipation in physical space.

physics.flu-dyn↗

A real-variable unidirectional reduction of deep-water gravity waves

A unidirectional reduction of the deep-water surface gravity wave problem is derived in physical space using real variables. By employing a near-identity canonical transformation, cubic interactions are eliminated from the Hamiltonian, resulting in a bidirectional system analogous to the 1D Zakharov equation. An exact factorization of the linear dynamics then selects the rightward-propagating branch, which is carried to second order in the wave steepness, yielding a single nonlocal evolution equation with full linear dispersion. The model admits an exact monochromatic solution whose reconstructed surface elevation is the third-order Stokes wave, and a multiple-scales analysis recovers the Dysthe envelope equation complete with its nonlocal mean-flow term. The equation also admits exact breather solutions, whose profiles agree closely with those of the super compact equation. Dropping the sub-leading nonlinear terms that vanish on the resonant manifold provides a more compact variant suitable for analytical study. Numerical comparisons show that both formulations track the fully nonlinear Euler dynamics closely through modulational-instability recurrence and broadband focusing up to moderate wave steepness.

physics.flu-dyn↗