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

drop adjoints for [i,r,b]fft() #1386

Merged
merged 4 commits into from
Mar 8, 2023

Conversation

trahflow
Copy link
Contributor

@trahflow trahflow commented Mar 6, 2023

Following the discussion in #1377 I'm dropping the adjoints for fft(), ifft(), rfft() etc.
since the rules for rfft() and irfft() were not correct and correct rules have since been added to AbstractFFTs in JuliaMath/AbstractFFTs.jl#58.

Note that this does not yet fully fix the issue, since the adjoints for multiplication/left division by a real fft AbstractFFTs.Plan are still incorrect.
There is an in-progress PR at AbstractFFTs to provide ChainRules for these:
JuliaMath/AbstractFFTs.jl#67

For now, the adjoints for multiplication/left divison by AbstractFFTs.Plan are kept, even though they lead to incorrect results for real forward and inverse ffts.

Note though that if the dims argument is not provided to fft() etc., the rules provided by JuliaMath/AbstractFFTs.jl#58 aren't actually hit, and the compilation will fail trying to differentiate a try/except block in AbstractFFTs.plan_fft()
This is still better than a silently incorrect result as in rfft() and irfft(), but a regression for fft() etc. (without the dims argument) where the rules defined in Zygote were seemingly correct.
(which is why I made this a draft. Opinions on this welcome!)

PR Checklist

  • Tests are added (or rather adapted/removed)
  • [ ] Documentation, if applicable

Partially addresses FluxML#1377

ChainRules for these
have been added in JuliaMath/AbstractFFTs.jl#58
@gaurav-arya
Copy link

gaurav-arya commented Mar 6, 2023

I've made #83 to handle the chain rules issue you noted!

@trahflow
Copy link
Contributor Author

trahflow commented Mar 6, 2023

Thanks!
I'll reset the relevant tests here once that is merged

@trahflow trahflow marked this pull request as ready for review March 8, 2023 14:34
@@ -27,7 +27,7 @@ Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"
ZygoteRules = "700de1a5-db45-46bc-99cf-38207098b444"

[compat]
AbstractFFTs = "0.5, 1.0"
AbstractFFTs = "1.3.1"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this be done?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bumping the compat version of a dependency to add a new min bound? That's perfectly fine as long as we're not suddenly breaking anything. We do it all the time for e.g. Flux -> NNlib.

@trahflow
Copy link
Contributor Author

trahflow commented Mar 8, 2023

I think the build error is unrelated (and will be fixed by #1387 )

Copy link
Member

@ToucheSir ToucheSir left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tests pass so LGTM. Thanks!

test/gradcheck.jl Outdated Show resolved Hide resolved
Co-authored-by: Brian Chen <[email protected]>
@CarloLucibello CarloLucibello merged commit 942ca6d into FluxML:master Mar 8, 2023
@trahflow trahflow deleted the drop-direct-fft-adjoints branch March 8, 2023 22:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants