-
-
Notifications
You must be signed in to change notification settings - Fork 214
zygote broadcast type stability #1301
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
Comments
What it's doing is this: Zygote.jl/src/lib/broadcast.jl Lines 250 to 252 in 17a5673
julia> out = Zygote.dual_function(f_add).(PeriodicArray(rand(2,3)))
2×3 PeriodicArray{ForwardDiff.Dual{Nothing, Float64, 1}, 2}:
Dual{Nothing}(3.18449,1.0) Dual{Nothing}(3.32056,1.0) Dual{Nothing}(3.9397,1.0)
Dual{Nothing}(3.20766,1.0) Dual{Nothing}(3.20073,1.0) Dual{Nothing}(3.19711,1.0)
julia> y = map(x -> x.value, out)
2×3 Matrix{Float64}:
3.18449 3.32056 3.9397
3.20766 3.20073 3.19711 I am not sure why the second is FWIW, ChainRules uses https://github.com/JuliaDiff/ChainRules.jl/blob/main/src/rulesets/Base/broadcast.jl#L108-L114 which does not preserve such types, would be nice if it did too:
|
I'll try to make a pull request, I will also look a bit at the ChainRules case |
I cannot reproduce the chainrules case:
|
This was a bit obscure, sorry, but mine was using JuliaDiff/Diffractor.jl#89 . How did you get this error though? It might be the cause of some other problems, perhaps. (And can you post the stacktrace?) |
that error disappeared after restarting julia, so I'm just going to quietly ignore it, and hope it's not because I wrote a funky rule somewhere else. I can now reproduce the Diffractor thing :) |
I have a package that defines a simple utility Array type : https://github.com/maartenvd/MPSKit.jl/blob/diskarray/src/utility/periodicarray.jl
Zygote changes types when taking the derivative, which later on makes my backward rules fail. Here is a minimal example:
This type change causes failures, as it then calls rrule with a tangent type of PeriodicArray, but a (wrong) primal type of Matrix
The text was updated successfully, but these errors were encountered: