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

Bug with new Zygote version 0.6.49 ? #7

Open
ErikLW opened this issue Nov 22, 2022 · 0 comments
Open

Bug with new Zygote version 0.6.49 ? #7

ErikLW opened this issue Nov 22, 2022 · 0 comments

Comments

@ErikLW
Copy link

ErikLW commented Nov 22, 2022

When using Zygote version 0.6.40 the gradient of the following function can be evaluated correctly:
'''
function nrmsqrt(A)
return @tensor res = A[1,2] * A'[2,1]
end
'''
However, if one uses the version 0.6.49 (latest) this does no longer work, producing the following error:
'''
Need an adjoint for constructor TensorKit.AdjointTensorMap{ComplexSpace, 3, 1, Trivial, Matrix{ComplexF64}, Nothing, Nothing}. Gradient is of type TensorMap{ComplexSpace, 3, 1, Trivial, Matrix{ComplexF64}, Nothing, Nothing}

Stacktrace:
[1] error(s::String)
@ Base ./error.jl:35
[2] (::Zygote.Jnew{TensorKit.AdjointTensorMap{ComplexSpace, 3, 1, Trivial, Matrix{ComplexF64}, Nothing, Nothing}, Nothing, false})(Δ::TensorMap{ComplexSpace, 3, 1, Trivial, Matrix{ComplexF64}, Nothing, Nothing})
@ Zygote ~/.julia/packages/Zygote/dABKa/src/lib/lib.jl:327
[3] (::Zygote.var"#2100#back#224"{Zygote.Jnew{TensorKit.AdjointTensorMap{ComplexSpace, 3, 1, Trivial, Matrix{ComplexF64}, Nothing, Nothing}, Nothing, false}})(Δ::TensorMap{ComplexSpace, 3, 1, Trivial, Matrix{ComplexF64}, Nothing, Nothing})
@ Zygote ~/.julia/packages/ZygoteRules/AIbCs/src/adjoint.jl:67
[4] Pullback
@ ~/.julia/packages/TensorKit/KbNYI/src/tensors/adjoint.jl:11 [inlined]
[5] (::typeof(∂(TensorKit.AdjointTensorMap{ComplexSpace, 3, 1, Trivial, Matrix{ComplexF64}, Nothing, Nothing})))(Δ::TensorMap{ComplexSpace, 3, 1, Trivial, Matrix{ComplexF64}, Nothing, Nothing})
@ Zygote ~/.julia/packages/Zygote/dABKa/src/compiler/interface2.jl:0
[6] Pullback
@ ~/.julia/packages/TensorKit/KbNYI/src/tensors/adjoint.jl:11 [inlined]
[7] (::typeof(∂(TensorKit.AdjointTensorMap)))(Δ::TensorMap{ComplexSpace, 3, 1, Trivial, Matrix{ComplexF64}, Nothing, Nothing})
@ Zygote ~/.julia/packages/Zygote/dABKa/src/compiler/interface2.jl:0
[8] Pullback
@ ~/.julia/packages/TensorKit/KbNYI/src/tensors/adjoint.jl:18 [inlined]
[9] (::typeof(∂(adjoint)))(Δ::TensorMap{ComplexSpace, 3, 1, Trivial, Matrix{ComplexF64}, Nothing, Nothing})
@ Zygote ~/.julia/packages/Zygote/dABKa/src/compiler/interface2.jl:0
...
'''

Replacing A'[2,1] with conj(A)[1,2] suprisingly works also with the latest version of Zygote.
Best wishes,
Erik

maartenvd added a commit that referenced this issue Nov 24, 2022
rrule for tr and adjoint. probably sovles #7?
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

No branches or pull requests

1 participant