Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Touchup adjoint test #214

Open
wants to merge 29 commits into
base: develop
Choose a base branch
from
Open

Touchup adjoint test #214

wants to merge 29 commits into from

Conversation

samhatfield
Copy link
Collaborator

The existing adjoint test program seems to check the following identity:

$$\langle \text{DIR\_TRANS}\left(\delta \text{INV\_TRANS}\left(X \right)\right), Y \rangle = \langle X, \text{INV\_TRANSAD}\left( \delta \text{DIR\_TRANSAD}\left( Y \right)\right) \rangle$$

Where $\delta$ is an arbitrary perturbation. $X$ and $Y$ are both spectral space variables filled with random numbers between -1 and +1.
The program has a number of issues:

  • The test has no assertion of the results, hence it doesn't do anything useful. It just prints the values without checking.
  • It lacks documentation so it isn't clear what it's doing. I figured out the above by studying the code.
  • The perturbation $\delta$ does nothing. The perturbation is only applied to the first NFLEVG fields of PGP. But because the INV_TRANS call that fills PGP includes vorticity and divergence (which are both zeroed in this test), the first NFLEVG fields correspond to these zero-valued vorticity values, so the multiplicative perturbation does nothing. This was probably an oversight of whoever wrote the code, but in any case I don't think a perturbation is needed, i.e. you can set $\delta=1$ in the equation above and it's still a proper test.
  • The program includes GSTATS calls, but we don't care about performance here, only correctness, so they aren't needed. A separate program should be created for benchmarking the adjoint code.
  • The test tests the inverse and direct transform together. This means that if the test fails, we don't know which one is causing it. Perhaps this doesn't matter so much.

This PR aims to resolve this and make the adjoint test actually useful.

I'll keep this as a draft for now while I think of any other ways the test could be improved.

@samhatfield samhatfield added enhancement New feature or request tidying Tidying up code or removing unused features labels Feb 18, 2025
We don't need performance measurements in a correctness test.
The perturbations were only applied to the first NLEVG fields, but these
fields were all zero (vorticity and divergence are ordered first and
they were always zero in the test).
There was no difference between repetitions so this was pointless.
With the previous value, 100, the test failed in the Github CI suite for
clang-12/Release and gnu-10/Debug.
@samhatfield samhatfield force-pushed the touchup_adjoint_test branch 2 times, most recently from 0b6df4f to 5127f6e Compare February 24, 2025 15:52
Some compilers were failing in the NPROC=2 case.
@samhatfield samhatfield force-pushed the touchup_adjoint_test branch from 2ad5794 to 2d9848e Compare March 7, 2025 09:58
@samhatfield samhatfield force-pushed the touchup_adjoint_test branch from 2d9848e to 6646215 Compare March 7, 2025 10:01
@samhatfield samhatfield force-pushed the touchup_adjoint_test branch from 6646215 to 66a60b0 Compare March 7, 2025 10:03
@samhatfield samhatfield force-pushed the touchup_adjoint_test branch from 21c4557 to 5a853a1 Compare March 7, 2025 10:42
@samhatfield samhatfield changed the title [DRAFT] Touchup adjoint test Touchup adjoint test Mar 7, 2025
@samhatfield
Copy link
Collaborator Author

Ready for review.

@samhatfield samhatfield marked this pull request as ready for review March 7, 2025 11:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request tidying Tidying up code or removing unused features
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant