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

Complex broadcasting AD gives nothing when using CUDA #1215

Closed
pawbz opened this issue Apr 28, 2022 · 2 comments
Closed

Complex broadcasting AD gives nothing when using CUDA #1215

pawbz opened this issue Apr 28, 2022 · 2 comments
Labels
CUDA All things GPU

Comments

@pawbz
Copy link

pawbz commented Apr 28, 2022

The following snippet works well on CPU i.e., it gives the correct gradient but fails on GPU.

using Zygote
y=complex.([4,1])
x=complex.([3,2])
function f1215(x, y) 
    x = 2 .* x
    return sum(abs2.(x .- y))
end 
gs = gradient(()-> f1215(x,y), Zygote.Params([x]))
gs[x] # returns nothing when x and y are on GPU

using CUDA
x = cu(x)
y = cu(y)

[Edited not to need Flux]

@pawbz pawbz changed the title Cannot compute gradients when using FFTW Issue with complex AD when using CUDA Apr 29, 2022
@mcabbott
Copy link
Member

mcabbott commented Apr 30, 2022

The gradient of broadcasting used for CuArrays doesn't handle complex numbers. It's a bit of a nasty surprise but nobody has got around to making it at least an error, or better to making it work.

Xref #961, #1121 among others.

Edit: this thread has a similar problem from CuArray{SVector}.

@mcabbott mcabbott changed the title Issue with complex AD when using CUDA Complex broadcasting AD gives nothing when using CUDA May 9, 2022
@mcabbott mcabbott added the CUDA All things GPU label Jul 4, 2022
@CarloLucibello
Copy link
Member

closed in #1324

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CUDA All things GPU
Projects
None yet
Development

No branches or pull requests

3 participants