We present ForwardDiff, a Julia package for forward-mode automatic differentiation (AD) featuring performance competitive with low-level languages like C++. Unlike recently developed AD tools in other popular high-level languages such as Python and MATLAB, ForwardDiff takes advantage of just-in-time (JIT) compilation to transparently recompile AD-unaware user code, enabling efficient support for higher-order differentiation and differentiation using custom number types (including complex numbers). For gradient and Jacobian calculations, ForwardDiff provides a variant of vector-forward mode that avoids expensive heap allocation and makes better use of memory bandwidth than traditional vector mode. In our numerical experiments, we demonstrate that for nontrivially large dimensions, ForwardDiff's gradient computations can be faster than a reverse-mode implementation from the Python-based autograd package. We also illustrate how ForwardDiff is used effectively within JuMP, a modeling language for optimization. According to our usage statistics, 41 unique repositories on GitHub depend on ForwardDiff, with users from diverse fields such as astronomy, optimization, finite element analysis, and statistics.
This document is an extended abstract that has been accepted for presentation at the AD2016 7th International Conference on Algorithmic Differentiation.
FastAD: Expression Template-Based C++ Library for Fast and Memory-Efficient Automatic Differentiation
自动微分是一组有效且准确地计算由计算机程序表示的函数的导数的技术。然而,用于自动微分的现有C++库(例如,Adept、Stan Math Library)表现出大的内存消耗和运行时性能问题。本文介绍了FastAD,一个新的C++模板库的自动微分,克服了所有这些挑战,在现有的图书馆使用向量化,更简单的存储管理使用完全表达式模板的设计,和其他编译时优化,以消除一些运行时开销。基准测试表明,FastAD在各种测试用例(包括一些真实示例)中的执行速度比Adept快2-10倍,比Stan快2-19倍。
The Stan Math Library: Reverse-Mode Automatic Differentiation in C++
随着优化和统计推断中的计算挑战变得越来越困难,利用导数的算法变得越来越重要。然而,使这些算法如此强大的衍生物的实现是一个巨大的用户负担,这些算法的实用性关键取决于完全消除实现负担的自动微分等工具。Stan Math Library是一个C++反向模式的自动微分库,它被设计成可用的、广泛的和可扩展的、高效的、可扩展的、稳定的、可移植的和可再发行的,以促进这些算法的构建和利用。可用性是通过一个简单的直接接口和一个干净抽象的功能接口来实现的。广泛的内置库包括矩阵运算,线性代数,微分方程求解和最常见的概率函数的函数。可扩展性源于一个简单的面向对象的表达式框架,允许用户轻松地创建自定义函数。通过自定义存储管理、子表达式缓存、基于特征的元编程和表达式模板的组合来实现效率。复合函数的偏导数被惰性地评估以提高可伸缩性。通过在代数表达式中注意算术精度并在可能的情况下提供稳定的复合函数来实现稳定性。对于可移植性,该库是标准兼容的C++(03),并已在Windows,Mac OS X和Linux的所有主要编译器上进行了测试。
LVMT, ENPC, Institut Polytechnique de Paris, Univ Gustave Eiffel(巴黎高等路桥学院,巴黎理工学院,古斯塔夫·埃菲尔大学,LVMT实验室);BIFOLD – Berlin Institute for the Foundations of Learning and Data(柏林学习与数据基础研究所(BIFOLD));Machine Learning Group, Technical University of Berlin(柏林工业大学机器学习组)
A Review of automatic differentiation and its efficient implementation
导数在计算统计学中起着至关重要的作用,例如使用Hamilton Monte Carlo采样的贝叶斯推断和神经网络的训练。自动微分是自动计算导数的强大工具,比传统方法更可取,特别是在对复杂算法和数学函数进行微分时。然而,自动微分的实现需要一定的注意以确保效率。现代差异化软件包部署了广泛的计算技术,以提高适用性、运行时间和存储管理。这些技术包括操作重载、基于区域的内存和表达式模板。也有一些数学技术,可以产生高性能增益时,应用于复杂的算法。例如,半解析导数可以将数值求解和微分代数方程所需的运行时间减少几个数量级。开放的问题包括扩展目前的软件包,以提供更专业的例程,和有效的方法来执行高阶微分。
AbstractDifferentiation.jl: Backend-Agnostic Differentiable Programming in Julia
University of Basel(巴塞尔大学);Pumas-AI Inc.(普马斯人工智能公司);UNSW Canberra(新南威尔士大学堪培拉分校);Invenia Labs(因维尼亚实验室);Massachusetts Institute of Technology(麻省理工学院);Julia Computing Inc.(朱莉娅计算公司)
Sparser, Better, Faster, Stronger: Sparsity Detection for Efficient Automatic Differentiation
BIFOLD – Berlin Institute for the Foundations of Learning and Data(柏林学习与数据基础研究所);Technical University of Berlin(柏林工业大学);ENPC(巴黎高科路桥学校);Institut Polytechnique de Paris(巴黎综合理工学院);Univ Gustave Eiffel(古斯塔夫·埃菲尔大学)
AuTO: A Framework for Automatic differentiation in Topology Optimization
拓扑优化的一个关键步骤是求灵敏度。灵敏度的手动推导和实现可能非常费力且容易出错,特别是对于重要的目标、约束和材料模型。另一种方法是利用自动微分(AD)。虽然AD已经存在了几十年,并且也被应用于TO,但在很大程度上没有更广泛的采用。在这篇教育论文中,我们的目标是重新介绍AD for TO,并通过说明性代码使其易于访问。特别是,我们采用了JAX,一个高性能的Python库,用于自动计算用户定义的TO问题的敏感性。由此产生的框架,这里称为AuTO,说明通过几个例子,在遵守最小化,符合机制设计和微结构设计。
A C++ implementation of the discrete adjoint sensitivity analysis method for explicit adaptive Runge-Kutta methods enabled by automatic adjoint differentiation and SIMD vectorization
本文实现了一个面向自适应显式 Runge-Kutta 方法的 C++ 离散伴随灵敏度分析库,结合 AAD 与 SIMD 并行计算向量-Jacobian 乘积,性能略优于现有同类软件。
Automatic differentiation for Riemannian optimization on low-rank matrix and tensor-train manifolds
Marchuk Institute of Numerical Mathematics of the Russian Academy of Sciences(俄罗斯科学院马尔丘克计算数学研究所);HSE University(高等经济学院);Skolkovo Institute of Science and Technology(斯科尔科沃科学技术学院)
BIFOLD – Berlin Institute for the Foundations of Learning and Data(柏林学习与数据基础研究所);LVMT, ENPC, Institut Polytechnique de Paris, Univ Gustave Eiffel(法国国立路桥学校,巴黎理工学院,古斯塔夫·埃菲尔大学);Machine Learning Group, Technical University of Berlin(柏林工业大学机器学习组)