arXivDaily arXiv每日学术速递 周一至周五更新
arXiv周末暂无论文更新,休息一下吧,周末愉快~~
arXiv 2507.12640cs.PL
收藏

函数式数组语言的对偶数反向自动微分

Dual-Numbers Reverse AD for Functional Array Languages

Tom Smeding, Mikołaj Konarski, Simon Peyton Jones, Andrew Fitzgibbon

AI总结:

本文提出在双数反向自动微分中高效支持多维数组,通过批量操作变换消除高阶性,并以符号解释构建端到端编译流水线,在几乎无性能开销的前提下实现对函数式数组语言的一阶化AD。

摘要:

标准的对偶数构造在前向模式自动微分(AD)中表现良好,并因其简单性而具有吸引力;最近,它也被适配到反向模式AD中,但在实际性能方面,尤其是在数组程序上,仍有很大改进空间。本文在双数反向模式AD中引入对多维数组的一等支持,且几乎没有性能开销。该算法由三个松散耦合的组件组成:一个保持语义的向量化代码变换(批量操作变换,简称BOT)、将基本的对偶数反向AD算法相当直接地提升到一个主要为一阶的数组语言,以及符号解释以实现端到端编译流水线。不幸的是,在此过程中我们失去了对偶数AD的一些良好的可泛化特性,最重要的是对高阶代码的支持。我们确实支持一些高阶数组组合子,但仅限于一组精心选择的组合子:'build'(逐元素数组构造)、'gather'和'scatter'。作为回报,BOT可以消除输入程序中(对AD而言)关键的高阶性,这意味着AD本质上面对的是一个一阶程序。这使得将对偶数提升为“对偶数组”的朴素技巧无需太多修改即可生效。

英文摘要:

The standard dual-numbers construction works well for forward-mode automatic differentiation (AD) and is attractive due to its simplicity; recently, it also has been adapted to reverse-mode AD, but practical performance, especially on array programs, leaves a lot to be desired. In this paper we introduce first-class support for multidimensional arrays in dual-numbers reverse-mode AD with little to no performance overhead. The algorithm consists of three loosely-coupled components: a semantics-preserving vectorisation code transformation (the bulk-operation transform or BOT), a fairly straightforward lifting of the basic dual-numbers reverse AD algorithm to a mostly first-order array language, and symbolic interpretation to achieve an end-to-end compilation pipeline. Unfortunately, we lose some of the nice generalisable aspects of dual-numbers AD in the process, most importantly support for higher-order code. We do support some higher-order array combinators, but only a carefully-chosen set: 'build' (elementwise array construction), 'gather' and 'scatter'. In return, the BOT can eliminate the essential (for AD) higher-orderness of the input program, meaning that AD gets essentially presented with a first-order program. This allows the naive trick of lifting dual numbers to "dual arrays" to work without much modification.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑