Break OvertypedType -> BlockVariable -> OverloadedType reference cycle#194
Conversation
ce62640 to
b7821c1
Compare
|
I have tested this PR against the master branch for Burgers' equation using the following setup: 40,000 DoFs and 1,000 time steps. The first chart below shows results without checkpointing. The black line represents the master branch, and the blue line corresponds to the current PR: The second chart shows results using the |
|
Were the patches in firedrakeproject/firedrake#4033 also applied? Otherwise reference cycles might exist elsewhere. |
Not yet. Will be my next step. I will add here. |
|
Now using the firedrake branch from PR 4033: This PR against the pyadjoint master branch for Burgers' equation using the following setup: 40,000 DoFs and 1,000 time steps. The first chart below shows results without checkpointing. The black line represents the master branch, and the blue line corresponds to the current PR: The second chart shows results using the |
|
Can this please be checked for safety in the case of |
The pattern will lead to the |
Would it be better for that operation to instead just remove the block variables then? |
That's easy to add (the Note that this PR doesn't address #169, which requires the |
b9f2209 to
aeca579
Compare
aeca579 to
a6b460d
Compare
11975f4 to
b9c77db
Compare
…e cycle (#194) * Break OvertypedType -> BlockVariable -> OverloadedType reference cycle * Add OverloadedType.clear_block_variable * OverloadedType pickle fix, required by Firedrake EnsembleReducedFunctional




Use a
weakrefforOverloadedType.block_variable, accessed indirectly via aproperty. The result persists for as long as it is used elsewhere (e.g. on the tape, referenced by aControl, etc).Example use:
First line creates and then immediately destroys a
BlockVariable. Second line creates anotherBlockVariable, holding a reference to it, so that the third line references the sameBlockVariable. Net effect: attach a newBlockVariabletoot, hold two references onobject_0andobject_1, hold a weak reference onot.Could be optimized by adding an
OverloadedType.clear_block_variablemethod to replace the first line of the above examplewhich avoids the creation and immediate destruction of a
BlockVariable.