NLVS: Cache more adjoint solvers/forms and fix Hessian - #4638
NLVS: Cache more adjoint solvers/forms and fix Hessian#4638JHopeCollins wants to merge 8 commits into
Conversation
b89fa44 to
2d9bc78
Compare
|
Hi team! Excellent work and thanks for doing this. I just wanted to flag something before this lands so we don't end up pulling in opposite directions. I've got a small fix sitting on a branch against main that makes the adjoint replay clone the I was just about to do a PR for that on main. But since your work reorganises exactly that area and your refactor is the more structural and better change, I am thinking it's the natural place to do this properly rather than me landing a fix on main that you'd then have to unpick. So I am going to do PR targetting this one if you are OK. If not and you don't like the idea just tell me off and I wait for this to land and do my thing. |
|
Hi Sia, Thanks for raising this. It's a good point, I don't know how we haven't run into this before! |
It only is a problem if the object on appctx changes during taping, so whatever is in there is different at the end of taping and the first fwd block. in our case is a temperature (coming from a different solve) dependent viscosity. |
|
A quick heads-up since this PR is reshaping the same file: I have just opened #5175, which fixes #5172 by recording the projection's effective solver parameters on the |
6f6fd15 to
440f386
Compare
Hi Sia, thanks again for raising this. I think we should follow the same process as the |
442f29e to
62f3a75
Compare
62f3a75 to
a9adaa4
Compare
9fe7a29 to
7e1c34b
Compare
A bit of a doubling up on the already-present adj_sol on solver blocks.
* reduce nlvs adjoint test size * nlvs adjoint caching - bundle up recompute objects
* Remove explicit annotation on solve() We remove the explicit adjoint annotation on the bare solve() call, relying on the path through the NLVS as the single source of annotation. This simplifies and unifies the code paths, and will ideally allow us to remove the specialised solve blocks. * Add CachedSolverBlock to get_solve_blocks check I don't think this affects anything, but should be there as a convenience function (referenced in the "extract adjoint solutions" notebook). * Remove SolveLinearSystemBlock This is redundant now that it gets routed through the usual cached solver path. * Fix PDE-constrained optimisation notebook
* Handle MeshGeometry dependencies on cached solver blocks * Push subtraction out of derivative For whatever reason, derivative(-F, m, dm) has very different behaviour when passed through the adjoint -> action -> expand_derivatives chain compared to the non-negated variant. We just push subtraction to the dFdm_adj and dFdm_adj2 forms instead.
7e1c34b to
00d4a27
Compare
No description provided.