JuliaDiff / JuliaDiff/ChainRulesTestUtils.jl

Better features for testing complex functions

Open
#31 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Would be good to update the version bound for FiniteDifferences to v0.10.0, which fixed some issues with handling complex numbers: https://github.com/JuliaDiff/FiniteDifferences.jl/pull/76.

To really test rrules with complex numbers with FD, we'll need to make sure the inputs/output/sensitivity types are correct. I think the rough logic we discussed is:

If the output is complex, then the "sensitivity" of the output must be complex, and the sensitivities of all inputs will be complex, so all inputs must be complex

This is just for FD; the rrule should be tested with the user-provided inputs.
I used this heuristic in this gist testing Zygote. However, cases like these when testing Zygote rely on other rrules, so this won't work with ChainRules. The only way I can think to handle this is for the rrule_test or _make_fdm_call to pass a modified version of the function to FiniteDifferences with modified inputs.

I haven't thought at all about what to do when the output is something besides a number or array. I assume these aren't supported by rrule_test. This proposal also doesn't handle cases where one wants to test rrules whose inputs are e.g. structured arrays, where FD will force the pulled back sensitivity to have the same structure as the inputs. See https://github.com/FluxML/Zygote.jl/issues/608#issuecomment-618904733 for an example.

Would be good also to test holomorphicness when complex numbers are involved, but I don't know much about this.

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 rrule_test and _make_fdm_call, then inspect the FiniteDifferences version bound and existing finite-difference test setup. The scope still needs agreement for complex input, output, and sensitivity types, as well as non-numeric outputs, structured arrays, and holomorphicness; done should include tests demonstrating the chosen behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
julia
Domain
testing-qa
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.