Skip to content

Test that control checkpoints survive recompute#5157

Open
stephankramer wants to merge 4 commits into
releasefrom
skramer/fix-checkpoint-control-tests
Open

Test that control checkpoints survive recompute#5157
stephankramer wants to merge 4 commits into
releasefrom
skramer/fix-checkpoint-control-tests

Conversation

@stephankramer

Copy link
Copy Markdown
Contributor

Same as #5093

Changes to firedrake adjoint tests corresponding to this fix in pyadjoint: dolfin-adjoint/pyadjoint#257 (see #5093 for detailed description of changes)

Here based on release with a temporary change to use dolfin-adjoint/pyadjoint#257 in CI

Comment thread pyproject.toml Outdated
"pkgconfig",
"progress",
"pyadjoint-ad>=2026.4.0",
"pyadjoint-ad @ git+https://github.com/sghelichkhani/pyadjoint.git@sghelichkhani/fix-control-checkpoint-clearing",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

DROP BEFORE MERGE.

@dham dham marked this pull request as ready for review June 9, 2026 15:34
The clear-down assertions in _check_forward, _check_recompute, and
_check_reverse swept every block variable and required _checkpoint to
be None after recompute. That codified the pre-fix behaviour where
the checkpoint manager would silently clobber the control's checkpoint
during forward replay. Now that the manager goes through the
BlockVariable setter and respects the is_control guard, the control's
block variable legitimately retains the user-supplied value across
replays. The helpers now take an optional list of controls and skip
those block variables.

Also add a regression test for #5082: a
4-step model with J = sum(m**2) evaluated at m0 = 2 must have
derivative 16 (the bug produced 8 because the adjoint replay saw the
original m = 1).
The _control_bvs helper accepted either a Control or the underlying
overloaded variable, which is more flexible than the call sites need.
Standardise on the overloaded variable, which is available at every
call site (including before the Control is constructed), and update
the two multistep call sites that were passing a Control.
Point the dependency at sghelichkhani/fix-control-checkpoint-clearing
so CI exercises these test changes against the matching pyadjoint fix.
Reverts to the released pyadjoint once dolfin-adjoint/pyadjoint#257 is
merged and tagged.
@stephankramer stephankramer force-pushed the skramer/fix-checkpoint-control-tests branch from 5bf9d30 to 462e9b7 Compare June 11, 2026 09:45
Now that pyadjoint #257 has been merged
@stephankramer

Copy link
Copy Markdown
Contributor Author

Updated branch: @sghelichkhani 's 3 commits from #5093 on top of (now) release.

NOTE: last commit still needs undoing when fix in pyadjoint-ad has been released. Oh actually let me just repoint that to pyadjoint master for now.

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.

3 participants