Skip to content

Keep the indexed dat alive in the adjoint interpolation weight loop - #5785

Open
sghelichkhani wants to merge 1 commit into
mainfrom
sghelichkhani/interpolate-real-adjoint-weakref
Open

sghelichkhani wants to merge 1 commit into
mainfrom
sghelichkhani/interpolate-real-adjoint-weakref

Conversation

@sghelichkhani

Copy link
Copy Markdown
Contributor

The adjoint weight of an interpolation into a Real space is computed with an assignment that keeps only a weak reference to a temporary indexed dat, so the loop fails if the garbage collector frees the temporary first. This passes _weakref=False in _loop_target_nodes, as the sparsity loop in firedrake/assemble.py already does. The new test makes the collector run very often and fails on main every time.

Fixes #5783

AI-assisted with Claude Code.

For a Real target space the indexed dat in _loop_target_nodes has no
loop index, so the assignment kept only a weak reference to it. The
garbage collector could free the dat before the eager loop ran, which
raised a dead weakref error in the adjoint of an interpolation into R.
@sghelichkhani sghelichkhani added the LLM used An LLM was used in the production of this PR label Dec 6, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

LLM used An LLM was used in the production of this PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Adjoint interpolation into R fails with a dead weak reference after a garbage collection

1 participant