Fix segfault when passing friendly tangents to "non-friendly" forward cache in 1.10 and formatting#983
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
|
@Technici4n the segfault is happening again, no clue why |
|
Here's the MWE for the segfault. It happens when we try to use using Mooncake: Config, zero_tangent, prepare_derivative_cache, value_and_derivative!!
struct SimplePair
x1::Float64
x2::Float64
end
f = (x, y) -> x * y + cos(x)
g = (sp::SimplePair) -> SimplePair(f(sp.x1, sp.x2), 2.0)
x, y = 5.0, 4.0
dx, dy = 3.0, 2.0
fx_sp = (g, SimplePair(x, y))
dfx_sp = (zero_tangent(g), SimplePair(dx, dy))
cache_sp_friendly = prepare_derivative_cache(
fx_sp...; config=Config(; friendly_tangents=true)
)
value_and_derivative!!(cache_sp_friendly, zip(fx_sp, dfx_sp)...) # works
cache_sp_unfriendly = prepare_derivative_cache(
fx_sp...; config=Config(; friendly_tangents=false)
)
value_and_derivative!!(cache_sp_unfriendly, zip(fx_sp, dfx_sp)...) # segfaults on 1.10 only |
|
Is the segfault maybe coming from calling an opaque closure with argument types that don't match the signature? Then it should hopefully go away with |
Maybe that was the root cause, I got it to go away by manually checking that the tangent types match the primal types inside provided |
Signed-off-by: Guillaume Dalle <[email protected]>
|
Are we good vis-a-vis failing tests? |
|
Yes, good. Same failures as the Mooncake 0.5 PR + a spurious |
|
Thank you for the quick fixup, let's get this released! |
… cache in 1.10 and formatting (#983)
#980 was merged before formatting passed