-
Notifications
You must be signed in to change notification settings - Fork 33
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
Use NaNMath #71
Use NaNMath #71
Conversation
Codecov Report
@@ Coverage Diff @@
## master #71 +/- ##
======================================
Coverage 61.9% 61.9%
======================================
Files 7 7
Lines 546 546
======================================
Hits 338 338
Misses 208 208
Continue to review full report at Codecov.
|
This causes the following problem julia> NaNMath.min(ForwardDiff.Dual{Float64}(1), ForwardDiff.Dual{Float64}(1))
ERROR: StackOverflowError:
Stacktrace:
[1] min(::ForwardDiff.Dual{Float64,Int64,0}, ::ForwardDiff.Dual{Float64,Int64,0}) at /Users/andreasnoack/.julia/packages/NaNMath/pEdac/src/NaNMath.jl:291 (repeats 80000 times)
julia> min(ForwardDiff.Dual{Float64}(1), ForwardDiff.Dual{Float64}(1))
Dual{Float64}(1) which can happen with |
@anriseth do you remember what part "could go wrong"? |
Hmm, no unfortunately not. I remember running into an issue where NaNs propagated through and the culprit may have been alphatmp in some weird edgecase. We can either revert the Namath operations which are unlikely to affect as many people as the Forwarddiff problems, or add an explicit check on NaN instead |
I tried to change |
Ah, that's annoying. Do any of the other line search methods work for you? |
The other searches don’t really work for Andreas, because they don’t have the initial finiteness backtracking step (it should just be included in the others as well) |
I may have misunderstood, but I thought they did? :) https://github.com/JuliaNLSolvers/LineSearches.jl/blob/master/src/hagerzhang.jl#L142 |
Oh that was added... did you try morethuente Andreas? |
I've locally defined LineSearches.jl/src/backtracking.jl Line 32 in fae0768
Since maxstep is initialized to Inf we get things like
julia> Inf/ForwardDiff.Dual{Float64}(1.0, 0.0)
Dual{Float64}(Inf,NaN) Initially, I thought I could work around this by flipping the I guess it might be difficult to get correct behavior for |
I can of course just set |
If I remember correctly Two possible ways around this:
If you remove the line checking for |
Correct - I introduced this As a stabilising mechanism. Could one just check whether maxstep is Inf and in that case skip this operation? |
Regarding the initial comment then I think it should be fixed by JuliaDiff/DiffRules.jl#31. Regarding the other issue then JuliaDiff/ForwardDiff.jl#386 might help here but it's still an option that is off by default. I'm not sure what the better solution is but at least I've been able to get things working now for my use case by specifying a finite |
In case something goes wrong during the interpolation step.