Warning: type ITensors.ITensorMPS.MPS does not exist in workspace; reconstructing

I previously stored an MPS (from v0.6.23 of the ITensors.jl package) in a JLD2 file. However, after updating to version 0.7, I’m unable to load it properly since the current type should be ITensorMPS.MPS.

My loading approach is as follows:

using JLD2, ITensors, ITensorMPS
path = "xxx.jld2"
jldopen(path, "r") do file
    ψ = file["ψ"]
end

Has anyone encountered a similar issue? How can I reconcile this problem and load the MPS correctly in the updated version?

Thanks in advance for your help!

My current solution is:

using JLD2, ITensors, ITensorMPS
path = "xxx.jld2"
jldopen(path, "r") do file
    ψ = file["ψ"]
    ψ = MPS(ψ.data)
end

I’m also aware that the official I/O approach uses the HDF5 format, where one can assign the MPS type during loading like this:

psi = read(f, "psi", MPS)

Should I stop storing MPS in JLD2 files and switch to the recommended HDF5 format?

Yes, I would recommend using HDF5 if you want longer-term portability, and if you do not need any of the features that JLD2 offers.

Thanks, Miles.
Also, I’ve found the official solution for using JLD2 with explicit type remapping:

using JLD2, ITensors, ITensorMPS
path = "xxx.jld2"
jldopen(path, "r"; typemap=Dict("ITensors.ITensorMPS.MPS" => MPS)) do file
    ψ = file["ψ"]
end

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.