-
Notifications
You must be signed in to change notification settings - Fork 632
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
Adjoint gradients in Near2Far change with the number of processes #1555
Comments
See #1547, which should hopefully fix this. |
Thank you, Alec. Near2Far computes far field from near field on the Yee lattice and no voxel-center averaging is needed, but #1547 aims for dealing with the case of yee_grid=False which involves voxel-center averaging. |
The other thing you could do is to add a The set of source locations and amplitudes should be the same regardless of the number of processes. (You might want to first shrink the near-to-far region in order to reduce the number of source points you need to examine, while making sure you still reproduce the bug.) |
Thanks Steven! I will follow your suggestions and do the checks |
After some experiments, I find that the assertion |
That's not good — can you do some more digging to print out the coordinates of |
Thank you, @mochen4. Here I am trying to illustrate this bug using an example with only one process. In the example below, the finite-difference gradients and the adjoint gradients are inconsistent, which happens when the monitor is at some special positions, e.g., one pixel away from the lateral PML region. In normal situations, the monitor is not entirely located there. The purpose of this example is merely to demonstrate the bug. In addition, the inconsistency may arise at new positions when the number of processes increases, implying that the unusual case here might be related to the case mentioned in the beginning of this issue. The code is as follows.
The result is as follows, which shows no linear correlation. The inconsistency is not restricted to the The inconsistency is absent when |
After some more digging, I found that in I only used one process in the experiment, and |
Can you print out the weight |
Also check that the |
It looks like |
@stevengj do you have any updates on this fix? It might be worth it to add as a PR to see if checks are passing (and to check against other PRs). |
@mochen4, weren't you working on this at some point? |
If I remember correctly, |
The adjoint gradients in the Near2Far class change with the number of mpi processes. The test was based on the example code at Near2Far Optimization with Epigraph Formulation, with the objective function replaced by
The adjoint gradients were calculated as
I ran the code with 1, 16, and 32 mpi processes. Their relative differences are as follows. The horizontal axis labels different pixels in the design region, and the vertical axis represents the relative differences w.r.t. the 1-process adjoint gradients, namely,
16-process adjoint gradients / 1-processes adjoint gradients − 1
and32-processes adjoint gradients / 1-processes adjoint gradients − 1
.If we take the absolute value and plot them in the log scale, we can see that the differences are ubiquitous rather than limited to those spikes.
I also tested EigenmodeCoefficient, but did not see the variation of adjoint gradients among different numbers of processes.
The text was updated successfully, but these errors were encountered: