Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion pyadjoint/checkpointing.py
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,16 @@ def _(self, cp_action, progress_bar, functional=None, **kwargs):

# Handle the case for SingleMemoryStorageSchedule
if isinstance(self._schedule, SingleMemoryStorageSchedule):
if step > 1 and var not in self.tape.timesteps[step - 1].adjoint_dependencies:
# `var` is used by a block in this step, so the adjoint of
# this step may still need it as a linearisation point.
# Only clear once the adjoint dependencies have been
# revised by a reverse pass and `var` is provably not one
# of them; before that, keeping every dependency in memory
# is exactly what this schedule promises.
if (
current_step._revised_adj_deps
and var not in current_step.adjoint_dependencies
):
var.checkpoint = None
continue

Expand Down