JuliaDiff / JuliaDiff/ReverseDiff.jl
wrong derivative with array concatenation
Nobody has claimed this yet.
- Dominant language
- Julia
- Stars
- 393
- Forks
- 60
- Avg merge
- 18h 24m
- Merged PRs (30d)
- 8
Description
My code used to work in ReverseDiff 1.2.0 but the current version (1.4.2) returns the wrong derivatives. I've stripped away everything to a MWE:
import ForwardDiff
import ReverseDiff
struct Test{TF}
a::TF
end
function func(x)
tvec = Test.(x[1:2])
a = [t.a for t in tvec]
return sum([a; x[3]])
end
x = [1.0, 2.0, 3.0]
J1 = ForwardDiff.gradient(func, x)
J2 = ReverseDiff.gradient(func, x)
The answer should be [1, 1, 1], but ReverseDiff gives [0, 0, 1]. If I revert back to 1.2 then it works as expected. Trying different versions it seems that from 1.3 onward this no longer works.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the minimal example using ForwardDiff.gradient and ReverseDiff.gradient on func, comparing ReverseDiff 1.2.0 with 1.3 and 1.4.2. Investigate the derivative path for the array concatenation in return sum([a; x[3]]); done means ReverseDiff.gradient returns [1, 1, 1] in the current version.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- julia
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 35/100