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 perform poorly 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 comprise 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)因深度学习而普及,但其梯度计算能力在交互式应用场景中同样具有重要价值,例如双向计算机辅助设计、嵌入式物理仿真、因果推断可视化等。然而,现有自动微分框架难以适配Web环境:它们采用的自动微分策略在动态标量程序上性能低下,且依赖项臃肿,将导致网页体积超出可接受范围。本文提出Rose——一种面向Web的轻量级自动微分框架,采用新型混合式反向模式自动微分方法,将传统追踪与变换技术相融合。该方案既利用宿主语言实现元编程,又允许开发者显式定义可复用的函数以构建更大规模的可微分计算。我们通过移植两个可微分物理仿真系统验证了Rose设计的价值,并在基于优化的图表绘制应用中评估其性能,结果表明Rose在性能上超越当前最先进的Web自动微分框架数个数量级。