JuliaDiff / JuliaDiff/ForwardDiff.jl

Error with ForwardDiff 1 and QuadGK

Open
#785 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Julia
Stars
1k
Forks
160
PR merge metrics
No merged PRs in 30d

Description

Hi ForwardDiff team,

I observe an error when updating from ForwardDiff v0.10 to v1.x. The error occurs when differentiating through quadgk integration.

A MWE to reproduce the error is as follows:

using ForwardDiff
using QuadGK

delta = [ 1.0, 10.0 ]
chi = [ 0.03, 0.30 ]
S = inv([ exp(-chi_ * delta_) for delta_ in delta, chi_ in chi ])

g(x) = quadgk(t -> S*x, 0.0, 1.0)[1]

ForwardDiff.jacobian(g, zeros(2))

With ForwardDiff 1.3, I get the following error:

ERROR: LoadError: DomainError with 0.5:
integrand produced Dual{ForwardDiff.Tag{typeof(g), Float64}}(NaN,NaN,NaN) in the interval (0.0, 1.0)

Note that the code does not throw with ForwardDiff v0.10.39.

Also note that when changing the matrx S, e.g. adding a line S .+= 0.5 then above code also works with v1.3.

Would be great if you could have a look.

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 running the provided MWE with ForwardDiff 1.3 and QuadGK, then compare it with ForwardDiff v0.10.39. Investigate the differentiation path through quadgk and the effect of the matrix S values; done means the example no longer produces Dual NaN values or a DomainError.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.