Skip to content
0:00 / 0:00

#julia#chainrules.jl#automaticdifferentiation

JuliaCon 2020 | ChainRules.jl | Frames Catherine White

The Julia Programming Language

91K subscribers • 17 videos on Hallway

YouTube

Intermediate. Assumes working knowledge.

2.5K views6 years ago1 recommendation

Programming languagesAI and machine learningNeural networks and deep learningTraining and serving models

Frames Catherine White explains ChainRules.jl, a project that allows Julia package authors to write custom sensitivities independent of specific automatic differentiation packages.

The ChainRules project allows package authors to write rules for custom sensitivities (sometimes called custom adjoints) in a way that is not dependent on any particular autodiff (AD) package. It allows authors of AD packages to access a wealth of prewritten custom sensitivities, saving them the effort of writing them all out themselves. ChainRules is the successor to DiffRules.jl and is the native rule system currently used by ForwardDiff2, Zygote and soon ReverseDiff A perhaps counterintuitive requirement for differentiable programming is easy hand-coded rules for determining derivatives. You might think: “I thought the whole point of differentiable programming was to use AD, so I didn’t have to write all these derivatives by hand.”. Indeed you don’t have to, but that doesn’t mean you shouldn't be allowed to, and it doesn’t mean you can't get advantages out of doing do. Custom sensitivities allow programmers to insert domain knowledge that no autodiff system could ever figure out. Further custom rules, let you work around any bugs in the AD system, and fix performance issues. So being able to write custom rules is important, and doing it once for every AD system is win on deduplicating effort. A secondary advantage of ChainRules is that it provides a set of differential types to be used by AD systems. The differential types provided by ChainRules are very expressive, more expressive in-fact than is required for any current AD system. These types allow ChainRules to act as a lingua franca between AD systems. If it is advantageous because of some properties of your system to AD one part with ForwardDiff2 (via forward-mode), another part with Zygote (via source code transformation reverse mode) and another via Nabla (via overloading tape-based reverse mode) then you can; and each part can understand the derivative types returned by the other. The ChainRules project has 3 packages: - ChainRulesCore.jl: the minimum stuff required to implement custom rules for your package. Think of it like RecipesBase for Plots.jl. It should be used by all packages wanting to support rules. - ChainRules.jl: a repository of rules for functions defined in Base and the Standard Libraries. This was separated out from ChainRulesCore to minimize load time. It should be used by AD packages wanting to consume rules. - ChainRulesTestUtils.jl: robust testing utilities based on finite differencing. Its a test-time dependency for packages defining rules. This talk will cover: - An introduction to AD, including terminology such as pullback, custom sensitivity etc. - The details the use and design of the ChainRules packages - An explanation of some of the open questions in autodiff and our resolutions to them including: natural vs structural derivatives, mutating reverse-mode AD, chunked AD / change of basis, one-to-one vs many-to-many relationships between differential and primal types. TimeStamps: Welcome! Help us add time stamps or captions to this video! See

Why it's here

1 person recommends this

What people say. Recommended as an excellent presentation on Julia's rich automatic differentiation ecosystem and the ChainRules abstraction.

u/activeXrayin r/ProgrammingLanguages • Recommends

On “Differentiable languages, featuring Python/Jax, Elixir/Nx, & Dex”

> My understanding is that in Julia these 2 features only come together in the Flux NN library. Not at all! Zygote maybe as it was developed in tandem with Flux, but Julia has an incredibly rich ecosystem of AD tools that exist completely tangentially to Flux. ChainRules.jl itself is a crazy cool package, which introduces an abstraction of sensitivities that people can build AD algos from. Lyndon did a great talk last year about it. But the idea is by construction, Julia lends itself really really well to AD. ForwardDiff is used extensively for differentiable programming and works fine on CUDA. In fact, DifferentialEquations.jl (the highest performance DE library right now) can paralleli…