Reverse-mode automatic differentiation (autodiff) has been popularized by deep learning, but its ability to compute gradients is also valuable for interactive use cases such as bidirectional computer-aided design, embedded physics simulations, visualizing causal inference, and more. Unfortunately, the web is ill-served by existing autodiff frameworks, which use autodiff strategies that are unperformant on dynamic scalar programs, and pull in heavy dependencies that would result in unacceptable webpage sizes. This work introduces Rose, a lightweight autodiff framework for the web using a new hybrid approach to reverse-mode autodiff, blending conventional tracing and transformation techniques in a way that uses the host language for metaprogramming while also allowing the programmer to explicitly define reusable functions that compose a larger differentiable computation. We demonstrate the value of the Rose design by porting two differentiable physics simulations, and evaluate its performance on an optimization-based diagramming application, showing Rose outperforming the state-of-the-art in web-based autodiff by multiple orders of magnitude.
翻译:反向模式自动微分(autodiff)因深度学习而普及,但其计算梯度的能力对于交互式应用(如双向计算机辅助设计、嵌入式物理仿真、因果推理可视化等)同样具有重要价值。然而,现有自动微分框架难以适应网络环境——它们采用的自动微分策略在处理动态标量程序时性能欠佳,且引入的庞大依赖关系会导致不可接受的网页尺寸。本文提出Rose,一种轻量级网络自动微分框架,采用新颖的混合方法实现反向模式自动微分:将传统追踪与变换技术相结合,既利用宿主语言进行元编程,又允许程序员显式定义可复用的函数以组合出更大的可微分计算。我们通过移植两个可微分物理仿真验证了Rose设计的价值,并在基于优化的图表绘制应用中评估其性能,结果表明Rose在网络自动微分方面的性能比现有最先进技术高出多个数量级。