Skip to content

Sum the adjoint of an assignment from a scalar over all ranks - #5780

Open
sghelichkhani wants to merge 1 commit into
releasefrom
sghelichkhani/assign-adjfloat-adjoint-parallel
Open

sghelichkhani wants to merge 1 commit into
releasefrom
sghelichkhani/assign-adjfloat-adjoint-parallel

Conversation

@sghelichkhani

Copy link
Copy Markdown
Contributor

FunctionAssignBlock summed the adjoint input only over the degrees of freedom that each rank owns, so in parallel the derivative with respect to an AdjFloat or a Real Function assigned to a Function was a partial sum on each rank. The sum now goes through the PETSc Vec, which reduces over the communicator, and this also corrects the Hessian action that uses the same code. The new tests are Taylor tests on 1 and 2 ranks. I also removed the deepcopy argument from Function.sub in the vector-valued Real branch, since Function.sub does not take it. A Taylor test cannot cover that branch yet because a vector-valued Real control fails with NotImplementedError in _ad_dot.

Fixes #5778

AI-assisted with Claude Code.

The adjoint of Function.assign from an AdjFloat or from a Function on R
added only the degrees of freedom that each rank owns, so in parallel each
rank got a partial derivative. Sum over the communicator with the PETSc Vec.

The vector-valued Real branch called Function.sub with a deepcopy argument
that Function.sub does not take. The sum does not need a copy.
@sghelichkhani sghelichkhani added the LLM used An LLM was used in the production of this PR label Dec 5, 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.

1 participant