adjointcheck:A C++23 Library for Validation of Reverse Mode Differentiation Implementations. Application to WENO5 Schemes.
Abstract
Adjoint methods (reverse-mode automatic differentiation) are essential in computational science for gradient-based optimization, sensitivity analysis, and inverse problems. However, hand-coded adjoint operators are notoriously error-prone due to the complexity of reversing the control flow and correctly applying the chain rule. This challenge becomes particularly acute in the context of LLM-assisted code generation, where the ability to validate generated code without manual review is critical. This report presents adjointcheck, a modern C++23 library that provides rigorous, automated validation of adjoint implementations. The library offers two complementary verification methodologies: (1) Exact AD Validation using dual numbers, which provides machine-precision verification by comparing against forward-mode automatic differentiation, and (2) Taylor Convergence Testing, which verifies the asymptotic behavior of finite difference approximations for codes that cannot be templatized. We detail the mathematical foundations of both methods, the software architecture leveraging C++23 features such as std::mdspan, and demonstrate the library's effectiveness through the validation of an LLM-generated WENO5 flux scheme adjoint-a challenging test case from Computational Fluid Dynamics. As a foundational component of a broader design-pattern-driven LLM approach to automatic differentiation (to be detailed in a forthcoming companion report), adjointcheck enables trust in adjoint implementations without requiring manual code inspection.
Fields of Study & Subjects
Computational Fluid Dynamics and Aerodynamics
Advanced Numerical Methods in Computational Mathematics
Numerical Methods and Algorithms
Publication details
- Journal / source
- HAL
- Pages
- 25
- Publication date
- 1 January 2026
- Language
- EN