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

Fix build_laplace_objective behaviour #115

Merged
merged 16 commits into from
Mar 21, 2022
Merged

Fix build_laplace_objective behaviour #115

merged 16 commits into from
Mar 21, 2022

Conversation

st--
Copy link
Member

@st-- st-- commented Mar 15, 2022

Resolves #109

@st-- st-- requested a review from willtebbutt March 15, 2022 12:36
Copy link
Member

@willtebbutt willtebbutt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM subject to patch bump and CI passing (I'm convinced by the test)

@st--
Copy link
Member Author

st-- commented Mar 15, 2022

Hm, I'm not quite sure how to fix the autodiff issues 😞 @willtebbutt any ideas ?

@willtebbutt
Copy link
Member

Hmmm a good place to start might be to figure out where the Core.Box is coming from, and why its length is being asked for. It doesn't look obviously like an AD-specific thing to me, although perhaps it is if things that aren't using AD are working properly?

@st--
Copy link
Member Author

st-- commented Mar 15, 2022

Hmmm a good place to start might be to figure out where the Core.Box is coming from, and why its length is being asked for. It doesn't look obviously like an AD-specific thing to me, although perhaps it is if things that aren't using AD are working properly?

That I can tell you: it's coming from the objective closure within build_laplace_objective!, because the externally-scoped f doesn't have a defined type, as it's nothing when first called and then Vector in subsequent calls (once it was first assigned in the line I added). The length comes from the map call in loglik_and_derivs.

@willtebbutt
Copy link
Member

Hmm okay. So is a Core.Box making its way into the call to map before it gets assigned then? So it this actually an AD issue, or is it just to do with ensuring that f is initialised by the time it's needed?

@st--
Copy link
Member Author

st-- commented Mar 16, 2022

Hmm okay. So is a Core.Box making its way into the call to map before it gets assigned then? So it this actually an AD issue, or is it just to do with ensuring that f is initialised by the time it's needed?

I'm getting less sure here, but it's definitely not an issue in the forward pass (and all the Boxes seem to get hidden away), but AD fails...

src/LaplaceApproximationModule.jl Outdated Show resolved Hide resolved
test/LaplaceApproximationModule.jl Outdated Show resolved Hide resolved
@codecov
Copy link

codecov bot commented Mar 18, 2022

Codecov Report

Merging #115 (0784872) into master (c751c05) will decrease coverage by 0.51%.
The diff coverage is 80.00%.

@@            Coverage Diff             @@
##           master     #115      +/-   ##
==========================================
- Coverage   94.13%   93.61%   -0.52%     
==========================================
  Files           5        5              
  Lines         324      329       +5     
==========================================
+ Hits          305      308       +3     
- Misses         19       21       +2     
Impacted Files Coverage Δ
src/LaplaceApproximationModule.jl 96.89% <80.00%> (-1.19%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update c751c05...0784872. Read the comment docs.

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
end

mutable struct LaplaceObjectiveCache
f::Union{Nothing,Vector}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would there be any significant gains from changing it to two fields, f::Vector and f_initialized::Bool or something like that?

Copy link
Member

@willtebbutt willtebbutt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@st-- st-- merged commit 490ece8 into master Mar 21, 2022
@st-- st-- deleted the st/fix_laplace_109 branch March 21, 2022 13:04
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

Successfully merging this pull request may close these issues.

Laplace Approximation intermediates
3 participants