arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2212.09801cs.PL
收藏

指称正确、纯函数式且高效的反向模式自动微分

Denotationally Correct, Purely Functional, Efficient Reverse-mode Automatic Differentiation

Mathieu Huot, Amir Shaikhha

AI总结:

本文提出一种经 unary form 中间表示编译的纯函数式反向模式微分,证明其语义正确、可高效生成梯度并支持模块化扩展。

摘要:

反向模式微分被用于优化,但它会引入引用,从而破坏底层程序的纯函数性,使其出了名地更难优化。我们提出了一种针对带数组操作的纯函数式语言的反向模式微分。这是首个可证明高效、纯函数式且指称正确的反向模式微分。我们证明了该变换在语义上是正确的,并验证了廉价梯度原则。受 PROP 和编译到范畴的启发,我们引入了一种新颖的中间表示,称之为“unary form”。我们的反向模式变换被分解为通过该中间表示进行的编译方案。通过在反向模式变换之后执行通用的部分求值优化,而非依赖手工推导的优化,我们获得了可证明高效的梯度。对于简单的一阶程序,所得输出程序类似于静态单赋值(SSA)代码。我们强调了方法的模块化,并展示了如何能够轻松地用更优化的原语丰富该语言,以满足实践中某些加速需求。

英文摘要:

Reverse-mode differentiation is used for optimization, but it introduces references, which break the purity of the underlying programs, making them notoriously harder to optimize. We present a reverse-mode differentiation on a purely functional language with array operations. It is the first one to deliver a provably efficient, purely functional, and denotationally correct reverse-mode differentiation. We show that our transformation is semantically correct and verifies the cheap gradient principle. Inspired by PROPs and compilation to categories, we introduce a novel intermediate representation that we call 'unary form'. Our reverse-mode transformation is factored as a compilation scheme through this intermediate representation. We obtain provably efficient gradients by performing general partial evaluation optimizations after our reverse-mode transformation, as opposed to manually derived ones. For simple first-order programs, the obtained output programs resemble static-single-assignment (SSA) code. We emphasize the modularity of our approach and show how our language can easily be enriched with more optimized primitives, as required for some speed-ups in practice.

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

↑