Rust版自动微分库,支持正反向模式,速度快且内存安全。
ad-trait: A Fast and Flexible Automatic Differentiation Library in Rust
- 通过泛型特质重载浮点数,实现灵活高效的自动微分。
- 在多语言对比中表现顶尖,正向模式支持SIMD加速。
- 已集成到机器人学库,适合需要快速优化的系统开发。
Rust语言在机器人学等领域具有高效与内存安全的优势,但其广泛应用受限于高质量自动微分(AD)工具的缺失。本文提出ad-trait,一个基于Rust的AD库,通过重载标准浮点类型,引入灵活的特质以高效累积求导所需信息。该库支持前向和反向模式自动微分,是首个同时提供两种模式的运算符重载式AD实现。利用Rust的性能特性,前向模式结合SIMD指令提升效率。基准测试表明,该库在多种编程语言中属于最快的AD实现之一。目前已被集成至基于Rust的机器人学库,并成功用于加速优化流程。文章最后讨论了其局限性与更广泛的影响。
原文摘要 · Abstract (English)
The Rust programming language is an attractive choice for robotics and related fields, offering highly efficient and memory-safe code. However, a key limitation preventing its broader adoption in these domains is the lack of high-quality, well-supported Automatic Differentiation (AD)-a fundamental technique that enables convenient derivative computation by systematically accumulating data during function evaluation. In this work, we introduce ad-trait, a new Rust-based AD library. Our implementation overloads Rust's standard floating-point type with a flexible trait that can efficiently accumulate necessary information for derivative computation. The library supports both forward-mode and reverse-mode automatic differentiation, making it the first operator-overloading AD implementation in Rust to offer both options. Additionally, ad-trait leverages Rust's performance-oriented features, such as Single Instruction, Multiple Data acceleration in forward-mode AD, to enhance efficiency. Through benchmarking experiments, we show that our library is among the fastest AD implementations across several programming languages for computing derivatives. Moreover, it is already integrated into a Rust-based robotics library, where we showcase its ability to facilitate fast optimization procedures. We conclude with a discussion of the limitations and broader implications of our work.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。