JuliaDiff / JuliaDiff/ChainRulesCore.jl

How to @opt_out of rules for methods in packages that don't use CRC

Open
#505 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Julia
Stars
267
Forks
66
PR merge metrics
No merged PRs in 30d

Description

Problem Statement

PDMats.jl doesn't utilise CRC, however, it has a decent chunk of code that needs to be opted out of. For example, this diag rule probably isn't what you want in order to differentiate this method of diag. Rather you should just differentiate through the method.

We're starting to use PDMats.jl in the JuliaGPs ecosystem and I realised that I have no idea how to opt out of stuff when we inevitably hit something we need to opt out of without convincing the maintainers of PDMats.jl to use CRC, and to write a load of additional code opting out.

An example of this kind of problem came up in Zygote recently: https://github.com/FluxML/Zygote.jl/issues/1106

Question

Do we have any options other than

  1. convincing PDMats maintainers to care about CRC, or
  2. putting opt-out code in the JuliaGPs ecosystem?

To my mind, neither of the above options are good. 2 is quite clearly bad (type piracy), and 1 also feels bad because we would just be adding the CRC dep in order to opt out of stuff (if they had written code which wasn't trivially differentiable, it would be a different matter).

edit: typo

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading the linked diag rule in src/rulesets/LinearAlgebra/structured.jl and the referenced method in PDMats.jl's src/scalmat.jl, then compare the related Zygote issue. Determine whether ChainRulesCore already supports a non-pirating opt-out for external methods; done would be a decided, documented approach or a clearly scoped API proposal.

Written by the indexing model from the issue text.

Assessment

Tech stack
julia
Domain
backend-api-design
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.