JuliaDiff / JuliaDiff/ChainRulesTestUtils.jl

Supporting tests for mutating rules

Open
#35 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

I know mutating rules aren't fully supported yet, but I've started implementing some, following the guidelines in this tweet. To support testing mutating functions, I think only a few changes are needed:

  1. Because the mutating function might use the values of an input before overwriting it, it is only safe to call the function multiple times as the testers do on copies of the inputs. Specifically deep copies. So the idea is to only pass deep copies of inputs to the functions in the testers.
  2. Because the pullback must undo the mutation, after calling the pullback, check that the copies of the inputs that were passed to the rrule are approximately equal to the original inputs.

For an example of how this might work, see this working implementation.

Am I missing anything, or are there any objections to me preemptively making these changes?

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 comparing the existing testers with the working example in test/diffrules.jl. Confirm whether testers pass deep copies to mutating functions and verify after pullback that the copied inputs approximately match their originals; done means these checks support mutating-rule tests without breaking existing behavior.

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
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.