JuliaDiff / JuliaDiff/ChainRulesTestUtils.jl

Test Linearity

Open
#120 2 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Julia
Stars
50
Forks
18
PR merge metrics
No merged PRs in 30d

Description

Pushforwards and pullbacks are requred to be linear operators.
Which formally is defined as φ(𝛼x) = 𝛼φ(x) and φ(a+b) = φ(a) + φ(b) for a,b,x differentials/vector space elements, and 𝛼 being a scalar.

A important collory of that is φ(0) = 0 where two 0s are the additive identity for the relivent vector spaces.
Which we can test with iszero(φ(zero(d)), since we always have access to a differential d, and all differentials must define zero and iszero.

Similarly we can test φ(𝛼x) = 𝛼φ(x) via φ(2d) == 2φ(d) since all differnetial define multiplication with a scalar. and we have one provided d.

We can't easily test φ(a+b) = φ(a) + φ(b) though, as we only have one differential.
We can test φ(d+d) = φ(d) + φ(d) but that is less interesting.
If we are generating them using rand_tangent we can easily generate another.
Though perhaps we should be insisting that things define the addition of there natural differentials with the structural differentials that rand_tangent will most often provide (though sometimes rand_tangent's structural differential will have extra nondifferentiable fields so we can't trust it, unless we insist the user does actually overload it).
Or we could avoid direct additon and do (primal + rand_tangent(d)) + d) though this is getting off-topic..
Possibly just skip that in initial implementation of this

The linear pullback can be extracted from the rrule via (f,primal...) -> (ds...) -> last(rrule(f, primal...))(ds...) (or equiv: (f,primal) -> last(rrule(f, primal))) The linear pushforward can be extracted from frulevia(f,primal) -> (ds...) -> frule(ds..., f, primal...)`

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

No file or test path is named. Start by reading the existing rand_tangent, rrule, and frule test utilities, then determine how pushforward and pullback linearity should be checked. Done means adding agreed tests for zero and scalar behavior, with additivity included only if the available differential generation supports it.

Written by the indexing model from the issue text.

Assessment

Tech stack
julia
Domain
testing-qa
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.