ITensors.jl
ITensors.jl copied to clipboard
`productMPS` not differentiable
sites = siteinds("Qubit", 3)
function f(x)
ψ = productMPS(sites, "0")
return x * inner(ψ,ψ)
end
f'(2.0)
Error:
ERROR: TypeError: in Type, in parameter, expected Type, got a value of type ITensor
Stacktrace:
[1] _pullback
@ ~/.julia/dev/ITensors/src/physics/sitetype.jl:106 [inlined]
[2] _pullback(ctx::Zygote.Context, f::Type{SiteType}, args::UInt128)
@ Zygote ~/.julia/packages/Zygote/Lw5Kf/src/compiler/interface2.jl:0
[3] _pullback
@ ~/.julia/dev/ITensors/src/physics/sitetype.jl:187 [inlined]
[4] _pullback(ctx::Zygote.Context, f::typeof(ITensors._sitetypes), args::TagSet)
@ Zygote ~/.julia/packages/Zygote/Lw5Kf/src/compiler/interface2.jl:0
[5] _pullback
@ ~/.julia/dev/ITensors/src/physics/sitetype.jl:190 [inlined]
[6] _pullback(ctx::Zygote.Context, f::typeof(ITensors._sitetypes), args::Index{Int64})
@ Zygote ~/.julia/packages/Zygote/Lw5Kf/src/compiler/interface2.jl:0
[7] _pullback
@ ~/.julia/dev/ITensors/src/physics/sitetype.jl:462 [inlined]
[8] _pullback(::Zygote.Context, ::ITensors.var"##state#927", ::Base.Iterators.Pairs{Union{}, Union{}, Tuple{}, NamedTuple{(), Tuple{}}}, ::typeof(state), ::Index{Int64}, ::String)
@ Zygote ~/.julia/packages/Zygote/Lw5Kf/src/compiler/interface2.jl:0
[9] _pullback
@ ~/.julia/dev/ITensors/src/physics/sitetype.jl:462 [inlined]
[10] _pullback
...
One thing to try to avoid this specific error is define:
@non_differentiable _sitetypes(::Any)
but likely there are other errors too.
I just realized that usually I wouldn't expect any variational parameters to be passed to productMPS so maybe it could just be marked with @non_differentiable. But I guess you might initial a product state from some angles.