JuliaDiff / JuliaDiff/ForwardDiff.jl
Perturbation Confusion II: The Tag Wars
Nobody has claimed this yet.
- Dominant language
- Julia
- Stars
- 1k
- Forks
- 160
- PR merge metrics
- No merged PRs in 30d
Description
@vtjnash was able to rewrite the classic perturbation confusion example into a form that thwarts ForwardDiff's tag generation:
julia> using ForwardDiff
julia> const D = ForwardDiff.derivative
derivative (generic function with 4 methods)
julia> struct Confuse
whoami::Bool
x
end
julia> function (c::Confuse)(xy)
if c.whoami
return xy * D(Confuse(false, xy), 1)
else
return c.x + xy
end
end
julia> D(Confuse(true, 0), 1) # this should be 1
2
Essentially, since the function type is constant whether or not the function recursively differentiates itself, ForwardDiff generates the same tag for the nested call that it generates for the outer call.
So it seems that sufficiently unique tags cannot be generated from local type information alone...
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
Start by reproducing the Julia REPL example in the issue and trace how ForwardDiff generates tags for the outer and nested derivative calls. The work is done when this recursive case produces the expected derivative of 1 and the tag collision is covered by a regression test.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- julia
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 20/100