JuliaDiff/ChainRules.jl
forward and reverse mode automatic differentiation primitives for Julia Base + StdLibs
What it solves
Software that performs automatic differentiation (AD) — computing derivatives of functions automatically — needs a standard way to define how to calculate those derivatives for each function. Without a shared standard, every AD tool would have to re-implement derivative rules from scratch. ChainRules provides that shared toolkit and a central, ready-made collection of derivative rules, especially for Julia's standard library, so AD tools can work consistently and efficiently.
How it works
The project is split into two layers. The lightweight core, ChainRulesCore.jl, contains the essential logic and interfaces. Package authors who want to add AD support to their own functions only need to depend on this small core to define new derivative rules (called rrules and frules). The main ChainRules.jl package is what users actually depend on directly: it re-exports all the core functionality and bundles in the full set of rules for Julia's standard library. The design is "control-inverted" — rule authors specify derivatives concisely, and the system only computes as much as the user requests. It also includes built-in propagation semantics with default implementations that let rule authors easily opt into optimizations like fusion, increment elision, and memoization.
Who it’s for
It's for two groups: developers building automatic differentiation (AD) tools in Julia who need a common foundation, and package authors who want to add derivative support to their own Julia packages without being tied to a specific AD implementation or needing to submit a pull request to ChainRules.
Highlights
- Supports forward, reverse, and mixed-mode differentiation without being coupled to any single AD implementation.
- Extensible: package authors can add derivative rules for their own functions by depending only on the lightweight ChainRulesCore.jl.
- Control-inverted design lets rule authors specify derivatives concisely, computing only as much as the user requests.
- Built-in propagation semantics with default implementations for common optimizations like fusion, increment elision, and memoization.
- Serves as the central, ready-to-use collection of derivative rules for Julia's standard library.
Related
- Project
- Project
- Project
- Project
- Project