loading jld2 MPS data from older ITensor version

hi, just a little heads-up on a backwards incompatibility problem I stumbled upon (and how I fixed it), in case it’s useful for anyone:

I’ve been trying to access a .jld2 backup of an MPS - which I had saved using ITensors somewhere around 0.3.40 - with the latest ITensor (0.6.10), but when trying to access the data I was getting the following errors

┌ Warning: type ITensors.GenericTagSet{BitIntegers.UInt256,4} does not exist in workspace; reconstructing
└ @ JLD2 ~/.julia/packages/JLD2/twZ5D/src/data/reconstructing_datatypes.jl:621
┌ Warning: saved type Index{Int64} has field tags::JLD2.ReconstructedStatic{Symbol("GenericTagSet{BitIntegers.UInt256,4}"), (:data, :length), Tuple{StaticArraysCore.SVector{4, BitIntegers.UInt256}, Int64}}, but workspace type has field tags::ITensors.TagSets.GenericTagSet{BitIntegers.UInt256, 4}, and no applicable convert method exists; reconstructing
└ @ JLD2 ~/.julia/packages/JLD2/twZ5D/src/data/reconstructing_datatypes.jl:225
┌ Warning: read type Tuple{Vararg{T, N}} where {N, T} has a different number of parameters from type Tuple{Vararg{T, N}} where {N, T} in workspace; reconstructing
└ @ JLD2 ~/.julia/packages/JLD2/twZ5D/src/data/reconstructing_datatypes.jl:590
┌ Warning: some parameters could not be resolved for type NDTensors.Tensor{ComplexF64,2,NDTensors.Dense{ComplexF64, Vector{ComplexF64}},JLD2.ReconstructedStatic{Symbol("Tuple{Vararg{T, N}} where {N, T}{2,JLD2.ReconstructedStatic{Symbol(\"Index{Int64}\"), (:id, :space, :dir, :tags, :plev), Tuple{UInt64, Int64, ITensors.QuantumNumbers.Arrow, JLD2.ReconstructedStatic{Symbol(\"GenericTagSet{BitIntegers.UInt256,4}\"), (:data, :length), Tuple{StaticArraysCore.SVector{4, BitIntegers.UInt256}, Int64}}, Int64}}}"), (Symbol("1"), Symbol("2")), Tuple{JLD2.ReconstructedStatic{Symbol("Index{Int64}"), (:id, :space, :dir, :tags, :plev), Tuple{UInt64, Int64, ITensors.QuantumNumbers.Arrow, JLD2.ReconstructedStatic{Symbol("GenericTagSet{BitIntegers.UInt256,4}"), (:data, :length), Tuple{StaticArraysCore.SVector{4, BitIntegers.UInt256}, Int64}}, Int64}}, JLD2.ReconstructedStatic{Symbol("Index{Int64}"), (:id, :space, :dir, :tags, :plev), Tuple{UInt64, Int64, ITensors.QuantumNumbers.Arrow, JLD2.ReconstructedStatic{Symbol("GenericTagSet{BitIntegers.UInt256,4}"), (:data, :length), Tuple{StaticArraysCore.SVector{4, BitIntegers.UInt256}, Int64}}, Int64}}}}}; reading as NDTensors.DenseTensor{ComplexF64, 2, JLD2.ReconstructedStatic{Symbol("Tuple{Vararg{T, N}} where {N, T}{2,JLD2.ReconstructedStatic{Symbol(\"Index{Int64}\"), (:id, :space, :dir, :tags, :plev), Tuple{UInt64, Int64, ITensors.QuantumNumbers.Arrow, JLD2.ReconstructedStatic{Symbol(\"GenericTagSet{BitIntegers.UInt256,4}\"), (:data, :length), Tuple{StaticArraysCore.SVector{4, BitIntegers.UInt256}, Int64}}, Int64}}}"), (Symbol("1"), Symbol("2")), Tuple{JLD2.ReconstructedStatic{Symbol("Index{Int64}"), (:id, :space, :dir, :tags, :plev), Tuple{UInt64, Int64, ITensors.QuantumNumbers.Arrow, JLD2.ReconstructedStatic{Symbol("GenericTagSet{BitIntegers.UInt256,4}"), (:data, :length), Tuple{StaticArraysCore.SVector{4, BitIntegers.UInt256}, Int64}}, Int64}}, JLD2.ReconstructedStatic{Symbol("Index{Int64}"), (:id, :space, :dir, :tags, :plev), Tuple{UInt64, Int64, ITensors.QuantumNumbers.Arrow, JLD2.ReconstructedStatic{Symbol("GenericTagSet{BitIntegers.UInt256,4}"), (:data, :length), Tuple{StaticArraysCore.SVector{4, BitIntegers.UInt256}, Int64}}, Int64}}}}, NDTensors.Dense{ComplexF64, Vector{ComplexF64}}}

and so on, resulting in strange Reconstructed[...] structures that julia doesn’t know what to do with.

I guess this kind of stuff can happen when you move to a different major version (hope this is not a result of a messup from my part) , in any case I was able to get it to work again by adding to my code a

using ITensors.TagSets
ITensors.GenericTagSet = ITensors.TagSets.GenericTagSet

which is admittedly a hacky workaround but seems to be working, I can load the old data as MPS as expected.

thanks as always for the great work!

1 Like

Good to know, thanks. Yes, while we try with the HDF5 formats to keep it working across major version changes, with JLD2 it should be considered only as a “short term” storage format in principle, since it interacts with a lot of library internals as you can see from what you had to do above. I’m glad you got it to work anyway with just a simple fix.