Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error with QuadGK 2.11 and Zygote #117

Open
sschlenkrich opened this issue Sep 2, 2024 · 3 comments
Open

Error with QuadGK 2.11 and Zygote #117

sschlenkrich opened this issue Sep 2, 2024 · 3 comments

Comments

@sschlenkrich
Copy link

Hi,

I maintain a Julia package for Monte Carlo simulation in the finance domain. We use QuadGK in conjunction with Zygote.

The new QuadGK 2.11 seems to cause the following error: Compiling Tuple{typeof(QuadGK.cachedrule), Type{Float64}, Int64}: try/catch is not supported. See also

https://github.com/frame-consulting/DiffFusion.jl/actions/runs/10649757211/job/29520331450

It all worked well with earlier versions of QuadGK.

Any chance you could have a look and fix it?

@stevengj
Copy link
Member

stevengj commented Sep 2, 2024

We might have to add a custom ChainRule, since I can't eliminate the new trycatch without eliminating thread-safety. For now, maybe you could just do

using ChainRulesCore
@non_differentiable QuadGK.cachedrule(Any...)

to prevent Zygote from trying to differentiate through that function (which in fact is not differentiable, nor is it necessary for the derivative, so Zygote is just wasting effort with it).

You could also use QuadGK via Integrals.jl, which has custom chain rules already.

(It would be good for us to add a custom ChainRule anyway, since the new eval_segbuf feature allows us to evaluate derivatives much more accurately and efficiently than was previously possible.)

@sschlenkrich
Copy link
Author

sschlenkrich commented Sep 2, 2024

Thansks a lot for quick response!

Your suggestion with flagging the problematic function as non-differentiable works for me.

@stevengj
Copy link
Member

stevengj commented Sep 3, 2024

Re-opening because this should ideally be fixed in QuadGK.

@stevengj stevengj reopened this Sep 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants