JuliaDiff / JuliaDiff/Diffractor.jl

Not using "strong zeros" for deriatives of constant values

Open
#278 1 comment 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Julia
Stars
453
Forks
33
PR merge metrics
No merged PRs in 30d

Description

Compare:

julia> using Diffractor, Zygote

julia> var"'"(f) = Zygote.var"'"(f);

julia> exp'(Inf)
Inf

julia> exp''(Inf)
Inf

with

julia> var"'"(f) = Diffractor.PrimeDerivativeFwd(f);

julia> exp'(Inf)
Inf

julia> exp''(Inf)
NaN

You can see in the code_typed that it appears to be subtracting 0.0 * exp(x)^2 from the answer of 1.0 * exp(x), causing the NaN. Ideally this'd instead be 1.0 * exp(x) - ZeroTangent()*exp(x)^2 so that we don't get the NaN.

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 at Diffractor.PrimeDerivativeFwd and inspect the code_typed output for the exp derivatives shown in the Julia REPL examples. The issue is done when exp''(Inf) produces Inf rather than NaN, matching the Zygote comparison and preserving the strong-zero behavior described.

Written by the indexing model from the issue text.

Assessment

Tech stack
julia
Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.