-
Notifications
You must be signed in to change notification settings - Fork 125
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
[ITensors] OpSum
to MPO
conversion type stability
#1184
Conversation
OpSum
to MPO
conversion type stability
[test ITensors mps] |
Run ITensors mps tests from comment trigger: failed ❌ |
1 similar comment
Run ITensors mps tests from comment trigger: failed ❌ |
[test ITensors mps] |
Run ITensors mps tests from comment trigger: failed ❌ |
1 similar comment
Run ITensors mps tests from comment trigger: failed ❌ |
Hi @mtfishman, thank you for feedback in my PR in #1183 Here is what I did on your ITensors.jl on ITensors_opsum_type_stability [?] is 📦 v0.3.41 via ஃ v1.9.3 via 🐍 v3.10.8
❯ git show --format='%h' --no-patch
bbecc8b6c
ITensors.jl on ITensors_opsum_type_stability [?] is 📦 v0.3.41 via ஃ v1.9.3 via 🐍 v3.10.8
❯ cat mpo_bench.jl
using ITensors
include("paulis.jl")
conserve_qns = false
@info "conserve_qns" conserve_qns
sites = siteinds("Qubit", N; conserve_qns)
os = ITensors.OpSum()
for p in paulis
coeff = rand()
global os
os += ITensors.Ops.op_term((coeff, p...))
end
@time MPO(os, sites)
@time MPO(os, sites)
@time MPO(os, sites)
ITensors.jl on ITensors_opsum_type_stability [?] is 📦 v0.3.41 via ஃ v1.9.3 via 🐍 v3.10.8
❯ julia mpo_bench.jl
┌ Info: conserve_qns
└ conserve_qns = false
28.424578 seconds (199.12 M allocations: 10.196 GiB, 6.61% gc time, 46.17% compilation time)
14.791576 seconds (168.27 M allocations: 8.186 GiB, 7.82% gc time)
15.261162 seconds (168.27 M allocations: 8.186 GiB, 7.64% gc time) My pull request #1183 is getting better results:
Unfortunately, I get an error when ITensors.jl on ITensors_opsum_type_stability [?] is 📦 v0.3.41 via ஃ v1.9.3 via 🐍 v3.10.8
❯ git show --format='%h' --no-patch
bbecc8b6c
ITensors.jl on ITensors_opsum_type_stability [?] is 📦 v0.3.41 via ஃ v1.9.3 via 🐍 v3.10.8
❯ cat mpo_bench.jl
using ITensors
include("paulis.jl")
conserve_qns = true
@info "conserve_qns" conserve_qns
sites = siteinds("Qubit", N; conserve_qns)
os = ITensors.OpSum()
for p in paulis
coeff = rand()
global os
os += ITensors.Ops.op_term((coeff, p...))
end
@time MPO(os, sites)
@time MPO(os, sites)
@time MPO(os, sites)
ITensors.jl on ITensors_opsum_type_stability [?] is 📦 v0.3.41 via ஃ v1.9.3 via 🐍 v3.10.8
❯ julia mpo_bench.jl
┌ Info: conserve_qns
└ conserve_qns = true
ERROR: LoadError: BoundsError: attempt to access 1×1 Matrix{Float64} at index [1, 2]
Stacktrace:
[1] getindex(::Matrix{Float64}, ::Int64, ::Int64)
@ Base ./essentials.jl:14
[2] svd_mpo(coefficient_type::Type, os::Sum{Scaled{ComplexF64, Prod{Op}}}, sites::Vector{Index{Vector{Pair{QN, Int64}}}}; mindim::Int64, maxdim::Int64, cutoff::Float64)
@ ITensors ~/work/fork/ITensors.jl/src/physics/autompo/opsum_to_mpo_qn.jl:134
[3] svd_mpo
@ ~/work/fork/ITensors.jl/src/physics/autompo/opsum_to_mpo_qn.jl:1 [inlined]
[4] mpo_specified_coefficient_type(coefficient_type::Type, os::Sum{Scaled{ComplexF64, Prod{Op}}}, sites::Vector{Index{Vector{Pair{QN, Int64}}}}; splitblocks::Bool, kwargs::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
@ ITensors ~/work/fork/ITensors.jl/src/physics/autompo/opsum_to_mpo_generic.jl:311
[5] mpo_specified_coefficient_type
@ ~/work/fork/ITensors.jl/src/physics/autompo/opsum_to_mpo_generic.jl:304 [inlined]
[6] MPO(os::Sum{Scaled{ComplexF64, Prod{Op}}}, sites::Vector{Index{Vector{Pair{QN, Int64}}}}; kwargs::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
@ ITensors ~/work/fork/ITensors.jl/src/physics/autompo/opsum_to_mpo_generic.jl:301
[7] MPO(os::Sum{Scaled{ComplexF64, Prod{Op}}}, sites::Vector{Index{Vector{Pair{QN, Int64}}}})
@ ITensors ~/work/fork/ITensors.jl/src/physics/autompo/opsum_to_mpo_generic.jl:300
[8] top-level scope
@ ./timing.jl:273
in expression starting at /Users/terasakisatoshi/work/fork/ITensors.jl/mpo_bench.jl:15 |
The code below is a MWE that reproduces the error above. using ITensors
N=4
paulis = [
["Z",1],
["Z",1,"Z",4],
["Z",2,"Z",3],
]
conserve_qns = true
@info "conserve_qns" conserve_qns
sites = siteinds("Qubit", N; conserve_qns)
os = ITensors.OpSum()
for p in paulis
coeff = rand()
global os
os += ITensors.Ops.op_term((coeff, p...))
end
@time MPO(os, sites) |
Thanks for checking @terasakisatoshi. I also noticed that bug. Let's just go ahead with your more minimal PR for now. I'll make some comments over there. |
Description
Supersedes #1183, with some additional code reorganization and cleanup.