-
-
Notifications
You must be signed in to change notification settings - Fork 212
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
Fix adjoint Iterators.product behavior with nothing #1170
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks great, thanks!
Could you add (at least some of) these tests to the tests?
If you can invent a function whose gradient
produces this error, that would also be nice to have in the tests.
Co-authored-by: Michael Abbott <32575566+mcabbott@users.noreply.github.com>
Thank you for reviewing the change! I can't seem to come up with a mwe of a gradient that leads to this error. The context in which this error arose is in computing a gradient for an electromagnetic simulation (specifically this one: https://github.com/lxvm/DeltaRCWA.jl/blob/1c445ab8d72129350de275ab782283d7ebac221e/scripts/zygote.jl#L41) where I used a product iterator to construct a matrix (the stacktrace from the gradient pointed to here: https://github.com/lxvm/DeltaRCWA.jl/blob/1c445ab8d72129350de275ab782283d7ebac221e/src/sheets.jl#L312). |
I see, the
and so a way to get the wrong answer is:
Thanks for tracking this down! |
Thank you for noticing those things! |
Co-authored-by: Michael Abbott <32575566+mcabbott@users.noreply.github.com>
The last test looks good! |
Thanks! |
Hi,
This PR fixes the issue illustrated below where a
DimesionMismatch
occurs depending on the position of nothing arguments to the pullback ofIterators.product
.I hope this PR enforces the desired behavior of the pullback in this edge case, but I don't know enough about Zygote to understand where the
nothing
arguments are originating from (I noticed this bug while trying to differentiate some other code).I can reference:
With this PR, the results of the tests defined above are: