From f71bc6a9e9a5f5b506658eacb1cdaceab1b346be Mon Sep 17 00:00:00 2001 From: Miles Date: Fri, 12 Apr 2024 11:20:24 +0200 Subject: [PATCH 01/19] Fix some docs issues --- docs/settings.jl | 3 ++- docs/src/ITensorType.md | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/docs/settings.jl b/docs/settings.jl index 16f5056263..537502906d 100644 --- a/docs/settings.jl +++ b/docs/settings.jl @@ -1,4 +1,5 @@ -using Documenter, ITensors +using Documenter +using ITensors DocMeta.setdocmeta!(ITensors, :DocTestSetup, :(using ITensors); recursive=true) diff --git a/docs/src/ITensorType.md b/docs/src/ITensorType.md index e442341d75..ea8f3e1bc5 100644 --- a/docs/src/ITensorType.md +++ b/docs/src/ITensorType.md @@ -26,7 +26,7 @@ itensor(::Array{<:Number}, ::ITensors.Indices) ## QN BlockSparse Constructors ```@docs -ITensor(::Type{<:Number}, ::QN, ::ITensors.Indices) +ITensor(::Type{<:Number}, ::QN, ::ITensors.QNIndices) ITensor(::ITensors.AliasStyle, ::Type{<:Number}, ::Array{<:Number}, ::ITensors.QNIndices; tol=0) ITensor(::Type{<:Number}, ::UndefInitializer, ::QN, ::ITensors.Indices) ``` From 4e47691ae74162a58daa9c6d1e889d08e6b1b411 Mon Sep 17 00:00:00 2001 From: Miles Date: Fri, 12 Apr 2024 11:21:14 +0200 Subject: [PATCH 02/19] Create HDF5 package extension --- Project.toml | 3 +- docs/settings.jl | 2 +- docs/src/examples/ITensor.md | 11 ++++--- docs/src/examples/MPSandMPO.md | 10 +++--- ext/ITensorsHDF5Ext/ITensorMPS/mpo.jl | 27 +++++++++++++++++ ext/ITensorsHDF5Ext/ITensorMPS/mps.jl | 27 +++++++++++++++++ ext/ITensorsHDF5Ext/ITensorsHDF5Ext.jl | 14 +++++++++ ext/ITensorsHDF5Ext/index.jl | 42 ++++++++++++++++++++++++++ ext/ITensorsHDF5Ext/indexset.jl | 23 ++++++++++++++ ext/ITensorsHDF5Ext/itensor.jl | 36 ++++++++++++++++++++++ ext/ITensorsHDF5Ext/qn.jl | 25 +++++++++++++++ ext/ITensorsHDF5Ext/qnindex.jl | 29 ++++++++++++++++++ ext/ITensorsHDF5Ext/tagset.jl | 19 ++++++++++++ src/ITensorMPS/abstractmps.jl | 20 ++++++++++++ src/ITensorMPS/imports.jl | 1 - src/ITensorMPS/mpo.jl | 26 ---------------- src/ITensorMPS/mps.jl | 26 ---------------- src/imports.jl | 2 -- src/index.jl | 41 ------------------------- src/indexset.jl | 22 -------------- src/itensor.jl | 33 -------------------- src/qn/qn.jl | 24 --------------- src/qn/qnindex.jl | 28 ----------------- src/tagset.jl | 18 ----------- src/usings.jl | 1 - test/base/test_readwrite.jl | 4 ++- 26 files changed, 280 insertions(+), 234 deletions(-) create mode 100644 ext/ITensorsHDF5Ext/ITensorMPS/mpo.jl create mode 100644 ext/ITensorsHDF5Ext/ITensorMPS/mps.jl create mode 100644 ext/ITensorsHDF5Ext/ITensorsHDF5Ext.jl create mode 100644 ext/ITensorsHDF5Ext/index.jl create mode 100644 ext/ITensorsHDF5Ext/indexset.jl create mode 100644 ext/ITensorsHDF5Ext/itensor.jl create mode 100644 ext/ITensorsHDF5Ext/qn.jl create mode 100644 ext/ITensorsHDF5Ext/qnindex.jl create mode 100644 ext/ITensorsHDF5Ext/tagset.jl diff --git a/Project.toml b/Project.toml index e5927dd8af..61f67b77a4 100644 --- a/Project.toml +++ b/Project.toml @@ -11,7 +11,6 @@ Compat = "34da2185-b29b-5c13-b0c7-acf172513d20" Dictionaries = "85a47980-9c8c-11e8-2b9f-f7ca1fa99fb4" DocStringExtensions = "ffbed154-4ef7-542d-bbb7-c09d3a79fcae" Functors = "d9f16b24-f501-4c13-a1f2-28368ffc5196" -HDF5 = "f67ccb44-e63f-5c2f-98bd-6dc0ccc4ba2f" IsApprox = "28f27b66-4bd8-47e7-9110-e2746eb8bed7" KrylovKit = "0b1a1467-8014-51b9-945f-bf0ae24f4b77" LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" @@ -34,9 +33,11 @@ Zeros = "bd1ec220-6eb4-527a-9b49-e79c3db6233b" ZygoteRules = "700de1a5-db45-46bc-99cf-38207098b444" [weakdeps] +HDF5 = "f67ccb44-e63f-5c2f-98bd-6dc0ccc4ba2f" VectorInterface = "409d34a3-91d5-4945-b6ec-7529ddf182d8" [extensions] +ITensorsHDF5Ext = "HDF5" ITensorsVectorInterfaceExt = "VectorInterface" [compat] diff --git a/docs/settings.jl b/docs/settings.jl index 537502906d..7a8651bb18 100644 --- a/docs/settings.jl +++ b/docs/settings.jl @@ -1,4 +1,4 @@ -using Documenter +using Documenter using ITensors DocMeta.setdocmeta!(ITensors, :DocTestSetup, :(using ITensors); recursive=true) diff --git a/docs/src/examples/ITensor.md b/docs/src/examples/ITensor.md index 3cd1f4bd13..a64b5eaba0 100644 --- a/docs/src/examples/ITensor.md +++ b/docs/src/examples/ITensor.md @@ -501,6 +501,11 @@ UT = dag(C) * CT ## Write and Read an ITensor to Disk with HDF5 + + +!!! info + Make sure to install the HDF5 package to use this feature. (Run `julia> ] add HDF5` in the Julia REPL console.) + Saving ITensors to disk can be very useful. For example, you might encounter a bug in your own code, and by reading the ITensors involved from disk you can shortcut the process of @@ -520,7 +525,7 @@ from a calculation. To write it to an HDF5 file named "myfile.h5" you can use the following pattern: ```julia -using ITensors.HDF5 +using HDF5 f = h5open("myfile.h5","w") write(f,"T",T) close(f) @@ -531,8 +536,6 @@ or "Result Tensor" and doesn't have to have the same name as the reference `T`. Closing the file `f` is optional and you can also write other objects to the same file before closing it. -[*Above we did `using ITensors.HDF5` since HDF5 is already included as a dependency with ITensor. You can also do `using HDF5` but must add the HDF5 package beforehand for that to work.*] - **Reading an ITensor from an HDF5 File** Say you have an HDF5 file "myfile.h5" which contains an ITensor stored as a dataset with the @@ -540,7 +543,7 @@ name "T". (Which would be the situation if you wrote it as in the example above. To read this ITensor back from the HDF5 file, use the following pattern: ```julia -using ITensors.HDF5 +using HDF5 f = h5open("myfile.h5","r") T = read(f,"T",ITensor) close(f) diff --git a/docs/src/examples/MPSandMPO.md b/docs/src/examples/MPSandMPO.md index 8feb12a3ca..a9677dc25f 100644 --- a/docs/src/examples/MPSandMPO.md +++ b/docs/src/examples/MPSandMPO.md @@ -384,6 +384,9 @@ can be brought into orthogonal form by calling `psi = orthogonalize(psi, 1)`. ## Write and Read an MPS or MPO to Disk with HDF5 +!!! info + Make sure to install the HDF5 package to use this feature. (Run `julia> ] add HDF5` in the Julia REPL console.) + **Writing an MPS to an HDF5 File** Let's say you have an MPS `psi` which you have made or obtained @@ -391,7 +394,7 @@ from a calculation. To write it to an HDF5 file named "myfile.h5" you can use the following pattern: ```julia -using ITensors.HDF5 +using HDF5 f = h5open("myfile.h5","w") write(f,"psi",psi) close(f) @@ -402,8 +405,6 @@ or "Result MPS" and doesn't have to have the same name as the reference `psi`. Closing the file `f` is optional and you can also write other objects to the same file before closing it. -[*Above we did `using ITensors.HDF5` since HDF5 is already included as a dependency with ITensor. You can also do `using HDF5` but must add the HDF5 package beforehand for that to work.*] - **Reading an MPS from an HDF5 File** Say you have an HDF5 file "myfile.h5" which contains an MPS stored as a dataset with the @@ -411,7 +412,7 @@ name "psi". (Which would be the situation if you wrote it as in the example abov To read this ITensor back from the HDF5 file, use the following pattern: ```julia -using ITensors.HDF5 +using HDF5 f = h5open("myfile.h5","r") psi = read(f,"psi",MPS) close(f) @@ -436,7 +437,6 @@ H = MPO(os,sites) energy_psi = inner(psi',H,psi) ``` - Note the `MPS` argument to the read function, which tells Julia which read function to call and how to interpret the data stored in the HDF5 dataset named "psi". In the future we might lift the requirement of providing the type and have it be detected diff --git a/ext/ITensorsHDF5Ext/ITensorMPS/mpo.jl b/ext/ITensorsHDF5Ext/ITensorMPS/mpo.jl new file mode 100644 index 0000000000..09d10f1b02 --- /dev/null +++ b/ext/ITensorsHDF5Ext/ITensorMPS/mpo.jl @@ -0,0 +1,27 @@ +using ITensors: ITensor +using ITensors.ITensorMPS: MPO + +function HDF5.write(parent::Union{HDF5.File,HDF5.Group}, name::AbstractString, M::MPO) + g = create_group(parent, name) + attributes(g)["type"] = "MPO" + attributes(g)["version"] = 1 + N = length(M) + write(g, "rlim", M.rlim) + write(g, "llim", M.llim) + write(g, "length", N) + for n in 1:N + write(g, "MPO[$(n)]", M[n]) + end +end + +function HDF5.read(parent::Union{HDF5.File,HDF5.Group}, name::AbstractString, ::Type{MPO}) + g = open_group(parent, name) + if read(attributes(g)["type"]) != "MPO" + error("HDF5 group or file does not contain MPO data") + end + N = read(g, "length") + rlim = read(g, "rlim") + llim = read(g, "llim") + v = [read(g, "MPO[$(i)]", ITensor) for i in 1:N] + return MPO(v, llim, rlim) +end diff --git a/ext/ITensorsHDF5Ext/ITensorMPS/mps.jl b/ext/ITensorsHDF5Ext/ITensorMPS/mps.jl new file mode 100644 index 0000000000..3fefd8d7a7 --- /dev/null +++ b/ext/ITensorsHDF5Ext/ITensorMPS/mps.jl @@ -0,0 +1,27 @@ +using ITensors: ITensor +using ITensors.ITensorMPS: MPS + +function HDF5.write(parent::Union{HDF5.File,HDF5.Group}, name::AbstractString, M::MPS) + g = create_group(parent, name) + attributes(g)["type"] = "MPS" + attributes(g)["version"] = 1 + N = length(M) + write(g, "length", N) + write(g, "rlim", M.rlim) + write(g, "llim", M.llim) + for n in 1:N + write(g, "MPS[$(n)]", M[n]) + end +end + +function HDF5.read(parent::Union{HDF5.File,HDF5.Group}, name::AbstractString, ::Type{MPS}) + g = open_group(parent, name) + if read(attributes(g)["type"]) != "MPS" + error("HDF5 group or file does not contain MPS data") + end + N = read(g, "length") + rlim = read(g, "rlim") + llim = read(g, "llim") + v = [read(g, "MPS[$(i)]", ITensor) for i in 1:N] + return MPS(v, llim, rlim) +end diff --git a/ext/ITensorsHDF5Ext/ITensorsHDF5Ext.jl b/ext/ITensorsHDF5Ext/ITensorsHDF5Ext.jl new file mode 100644 index 0000000000..03dbfefb88 --- /dev/null +++ b/ext/ITensorsHDF5Ext/ITensorsHDF5Ext.jl @@ -0,0 +1,14 @@ +module ITensorsHDF5Ext + +using HDF5: HDF5, attributes, create_group, open_group, read, write + +include("index.jl") +include("itensor.jl") +include("qnindex.jl") +include("indexset.jl") +include("qn.jl") +include("tagset.jl") +include("ITensorMPS/mps.jl") +include("ITensorMPS/mpo.jl") + +end diff --git a/ext/ITensorsHDF5Ext/index.jl b/ext/ITensorsHDF5Ext/index.jl new file mode 100644 index 0000000000..213ddd86fb --- /dev/null +++ b/ext/ITensorsHDF5Ext/index.jl @@ -0,0 +1,42 @@ +using ITensors: Arrow, dim, dir, id, Index, plev, QNBlocks, space, tags, TagSet + +function HDF5.write(parent::Union{HDF5.File,HDF5.Group}, name::AbstractString, I::Index) + g = create_group(parent, name) + attributes(g)["type"] = "Index" + attributes(g)["version"] = 1 + write(g, "id", id(I)) + write(g, "dim", dim(I)) + write(g, "dir", Int(dir(I))) + write(g, "tags", tags(I)) + write(g, "plev", plev(I)) + if typeof(space(I)) == Int + attributes(g)["space_type"] = "Int" + elseif typeof(space(I)) == QNBlocks + attributes(g)["space_type"] = "QNBlocks" + write(g, "space", space(I)) + else + error("Index space type not recognized") + end +end + +function HDF5.read(parent::Union{HDF5.File,HDF5.Group}, name::AbstractString, ::Type{Index}) + g = open_group(parent, name) + if read(attributes(g)["type"]) != "Index" + error("HDF5 group or file does not contain Index data") + end + id = read(g, "id") + dim = read(g, "dim") + dir = Arrow(read(g, "dir")) + tags = read(g, "tags", TagSet) + plev = read(g, "plev") + space_type = "Int" + if haskey(attributes(g), "space_type") + space_type = read(attributes(g)["space_type"]) + end + if space_type == "Int" + space = dim + elseif space_type == "QNBlocks" + space = read(g, "space", QNBlocks) + end + return Index(id, space, dir, tags, plev) +end diff --git a/ext/ITensorsHDF5Ext/indexset.jl b/ext/ITensorsHDF5Ext/indexset.jl new file mode 100644 index 0000000000..0351d43f44 --- /dev/null +++ b/ext/ITensorsHDF5Ext/indexset.jl @@ -0,0 +1,23 @@ +using ITensors: Index, Indices + +function HDF5.write(parent::Union{HDF5.File,HDF5.Group}, name::AbstractString, is::Indices) + g = create_group(parent, name) + attributes(g)["type"] = "IndexSet" + attributes(g)["version"] = 1 + N = length(is) + write(g, "length", N) + for n in 1:N + write(g, "index_$n", is[n]) + end +end + +function HDF5.read( + parent::Union{HDF5.File,HDF5.Group}, name::AbstractString, T::Type{<:Indices} +) + g = open_group(parent, name) + if read(attributes(g)["type"]) != "IndexSet" + error("HDF5 group or file does not contain IndexSet data") + end + n = read(g, "length") + return T(Index[read(g, "index_$j", Index) for j in 1:n]) +end diff --git a/ext/ITensorsHDF5Ext/itensor.jl b/ext/ITensorsHDF5Ext/itensor.jl new file mode 100644 index 0000000000..93a694bd93 --- /dev/null +++ b/ext/ITensorsHDF5Ext/itensor.jl @@ -0,0 +1,36 @@ +using ITensors: IndexSet, inds, itensor, ITensor, storage +using NDTensors: + NDTensors, BlockSparse, Combiner, Dense, Diag, DiagBlockSparse, EmptyStorage + +function HDF5.write(parent::Union{HDF5.File,HDF5.Group}, name::AbstractString, T::ITensor) + g = create_group(parent, name) + attributes(g)["type"] = "ITensor" + attributes(g)["version"] = 1 + write(g, "inds", inds(T)) + return write(g, "storage", storage(T)) +end + +function HDF5.read( + parent::Union{HDF5.File,HDF5.Group}, name::AbstractString, ::Type{ITensor} +) + g = open_group(parent, name) + if read(attributes(g)["type"]) != "ITensor" + error("HDF5 group or file does not contain ITensor data") + end + # TODO: use Vector{Index} here? + inds = read(g, "inds", IndexSet) + + # check input file for key name of ITensor data + # ITensors.jl <= v0.1.x uses `store` as key + # whereas ITensors.jl >= v0.2.x uses `storage` as key + for key in ["storage", "store"] + if haskey(g, key) + stypestr = read(attributes(open_group(g, key))["type"]) + stype = eval(Meta.parse(stypestr)) + storage = read(g, key, stype) + return itensor(storage, inds) + end + end + return error("HDF5 file: $(g) does not contain correct ITensor data.\nNeither key + `store` nor `storage` could be found.") +end diff --git a/ext/ITensorsHDF5Ext/qn.jl b/ext/ITensorsHDF5Ext/qn.jl new file mode 100644 index 0000000000..f8d8da5039 --- /dev/null +++ b/ext/ITensorsHDF5Ext/qn.jl @@ -0,0 +1,25 @@ +using ITensors: maxQNs, modulus, name, QN, QNVal, val + +function HDF5.write(parent::Union{HDF5.File,HDF5.Group}, gname::AbstractString, q::QN) + g = create_group(parent, gname) + attributes(g)["type"] = "QN" + attributes(g)["version"] = 1 + names = [String(name(q[n])) for n in 1:maxQNs] + vals = [val(q[n]) for n in 1:maxQNs] + mods = [modulus(q[n]) for n in 1:maxQNs] + write(g, "names", names) + write(g, "vals", vals) + return write(g, "mods", mods) +end + +function HDF5.read(parent::Union{HDF5.File,HDF5.Group}, name::AbstractString, ::Type{QN}) + g = open_group(parent, name) + if read(attributes(g)["type"]) != "QN" + error("HDF5 group or file does not contain QN data") + end + names = read(g, "names") + vals = read(g, "vals") + mods = read(g, "mods") + mqn = ntuple(n -> QNVal(names[n], vals[n], mods[n]), maxQNs) + return QN(mqn) +end diff --git a/ext/ITensorsHDF5Ext/qnindex.jl b/ext/ITensorsHDF5Ext/qnindex.jl new file mode 100644 index 0000000000..742c0f1ba2 --- /dev/null +++ b/ext/ITensorsHDF5Ext/qnindex.jl @@ -0,0 +1,29 @@ +using ITensors: dims, QNBlock, QNBlocks + +function HDF5.write(parent::Union{HDF5.File,HDF5.Group}, name::AbstractString, B::QNBlocks) + g = create_group(parent, name) + attributes(g)["type"] = "QNBlocks" + attributes(g)["version"] = 1 + write(g, "length", length(B)) + dims = [block[2] for block in B] + write(g, "dims", dims) + for n in 1:length(B) + write(g, "QN[$n]", B[n][1]) + end +end + +function HDF5.read( + parent::Union{HDF5.File,HDF5.Group}, name::AbstractString, ::Type{QNBlocks} +) + g = open_group(parent, name) + if read(attributes(g)["type"]) != "QNBlocks" + error("HDF5 group or file does not contain QNBlocks data") + end + N = read(g, "length") + dims = read(g, "dims") + B = QNBlocks(undef, N) + for n in 1:length(B) + B[n] = QNBlock(read(g, "QN[$n]", QN), dims[n]) + end + return B +end diff --git a/ext/ITensorsHDF5Ext/tagset.jl b/ext/ITensorsHDF5Ext/tagset.jl new file mode 100644 index 0000000000..27d0f602dd --- /dev/null +++ b/ext/ITensorsHDF5Ext/tagset.jl @@ -0,0 +1,19 @@ +using ITensors: TagSet, tagstring + +function HDF5.write(parent::Union{HDF5.File,HDF5.Group}, name::AbstractString, T::TagSet) + g = create_group(parent, name) + attributes(g)["type"] = "TagSet" + attributes(g)["version"] = 1 + return write(g, "tags", tagstring(T)) +end + +function HDF5.read( + parent::Union{HDF5.File,HDF5.Group}, name::AbstractString, ::Type{TagSet} +) + g = open_group(parent, name) + if read(attributes(g)["type"]) != "TagSet" + error("HDF5 group '$name' does not contain TagSet data") + end + tstring = read(g, "tags") + return TagSet(tstring) +end diff --git a/src/ITensorMPS/abstractmps.jl b/src/ITensorMPS/abstractmps.jl index c4b98a2716..ce84d93cf7 100644 --- a/src/ITensorMPS/abstractmps.jl +++ b/src/ITensorMPS/abstractmps.jl @@ -699,6 +699,26 @@ function map(f::Function, M::AbstractMPS; set_limits::Bool=true) return map!(f, copy(M); set_limits=set_limits) end +import ITensors: + dag, + #dag!, + prime, + prime!, + setprime, + setprime!, + noprime, + noprime!, + swapprime, + swapprime!, + replaceprime, + replaceprime!, + addtags, + addtags!, + removetags, + removetags!, + settags, + settags! + for fname in ( :dag, :prime, diff --git a/src/ITensorMPS/imports.jl b/src/ITensorMPS/imports.jl index 8bb438cfe2..4c22e664c2 100644 --- a/src/ITensorMPS/imports.jl +++ b/src/ITensorMPS/imports.jl @@ -120,7 +120,6 @@ import ..ITensors: hascommoninds, hasqns, hassameinds, - HDF5, inner, isfermionic, maxdim, diff --git a/src/ITensorMPS/mpo.jl b/src/ITensorMPS/mpo.jl index 215d882363..d496e917a3 100644 --- a/src/ITensorMPS/mpo.jl +++ b/src/ITensorMPS/mpo.jl @@ -1,5 +1,4 @@ using Adapt: adapt -using HDF5: attributes, create_group, open_group using Random: Random """ @@ -1040,28 +1039,3 @@ function sample(rng::AbstractRNG, M::MPO) end return result end - -function HDF5.write(parent::Union{HDF5.File,HDF5.Group}, name::AbstractString, M::MPO) - g = create_group(parent, name) - attributes(g)["type"] = "MPO" - attributes(g)["version"] = 1 - N = length(M) - write(g, "rlim", M.rlim) - write(g, "llim", M.llim) - write(g, "length", N) - for n in 1:N - write(g, "MPO[$(n)]", M[n]) - end -end - -function HDF5.read(parent::Union{HDF5.File,HDF5.Group}, name::AbstractString, ::Type{MPO}) - g = open_group(parent, name) - if read(attributes(g)["type"]) != "MPO" - error("HDF5 group or file does not contain MPO data") - end - N = read(g, "length") - rlim = read(g, "rlim") - llim = read(g, "llim") - v = [read(g, "MPO[$(i)]", ITensor) for i in 1:N] - return MPO(v, llim, rlim) -end diff --git a/src/ITensorMPS/mps.jl b/src/ITensorMPS/mps.jl index d5bb6a1c06..fae378de69 100644 --- a/src/ITensorMPS/mps.jl +++ b/src/ITensorMPS/mps.jl @@ -1,5 +1,4 @@ using Adapt: adapt -using HDF5: attributes, create_group, open_group using NDTensors: using_auto_fermion using Random: Random @@ -1032,28 +1031,3 @@ end function expect(psi::MPS, op1::Matrix{<:Number}, ops::Matrix{<:Number}...; kwargs...) return expect(psi, (op1, ops...); kwargs...) end - -function HDF5.write(parent::Union{HDF5.File,HDF5.Group}, name::AbstractString, M::MPS) - g = create_group(parent, name) - attributes(g)["type"] = "MPS" - attributes(g)["version"] = 1 - N = length(M) - write(g, "length", N) - write(g, "rlim", M.rlim) - write(g, "llim", M.llim) - for n in 1:N - write(g, "MPS[$(n)]", M[n]) - end -end - -function HDF5.read(parent::Union{HDF5.File,HDF5.Group}, name::AbstractString, ::Type{MPS}) - g = open_group(parent, name) - if read(attributes(g)["type"]) != "MPS" - error("HDF5 group or file does not contain MPS data") - end - N = read(g, "length") - rlim = read(g, "rlim") - llim = read(g, "llim") - v = [read(g, "MPS[$(i)]", ITensor) for i in 1:N] - return MPS(v, llim, rlim) -end diff --git a/src/imports.jl b/src/imports.jl index 87f089ea1b..5af0320132 100644 --- a/src/imports.jl +++ b/src/imports.jl @@ -86,8 +86,6 @@ import ITensors.ContractionSequenceOptimization: import Adapt: adapt_structure, adapt_storage -import HDF5: read, write - import LinearAlgebra: axpby!, axpy!, diff --git a/src/index.jl b/src/index.jl index d9c390b0d6..a8f92376f2 100644 --- a/src/index.jl +++ b/src/index.jl @@ -674,44 +674,3 @@ function readcpp(io::IO, ::Type{Index}; format="v3") read(io, 8) # Read default IQIndexDat size, 8 bytes return Index(id, dim, dir, tags) end - -function HDF5.write(parent::Union{HDF5.File,HDF5.Group}, name::AbstractString, I::Index) - g = create_group(parent, name) - attributes(g)["type"] = "Index" - attributes(g)["version"] = 1 - write(g, "id", id(I)) - write(g, "dim", dim(I)) - write(g, "dir", Int(dir(I))) - write(g, "tags", tags(I)) - write(g, "plev", plev(I)) - if typeof(space(I)) == Int - attributes(g)["space_type"] = "Int" - elseif typeof(space(I)) == QNBlocks - attributes(g)["space_type"] = "QNBlocks" - write(g, "space", space(I)) - else - error("Index space type not recognized") - end -end - -function HDF5.read(parent::Union{HDF5.File,HDF5.Group}, name::AbstractString, ::Type{Index}) - g = open_group(parent, name) - if read(attributes(g)["type"]) != "Index" - error("HDF5 group or file does not contain Index data") - end - id = read(g, "id") - dim = read(g, "dim") - dir = Arrow(read(g, "dir")) - tags = read(g, "tags", TagSet) - plev = read(g, "plev") - space_type = "Int" - if haskey(attributes(g), "space_type") - space_type = read(attributes(g)["space_type"]) - end - if space_type == "Int" - space = dim - elseif space_type == "QNBlocks" - space = read(g, "space", QNBlocks) - end - return Index(id, space, dir, tags, plev) -end diff --git a/src/indexset.jl b/src/indexset.jl index a0420887c2..96400e68f0 100644 --- a/src/indexset.jl +++ b/src/indexset.jl @@ -925,25 +925,3 @@ function readcpp(io::IO, ::Type{<:Indices}; format="v3") end return is end - -function HDF5.write(parent::Union{HDF5.File,HDF5.Group}, name::AbstractString, is::Indices) - g = create_group(parent, name) - attributes(g)["type"] = "IndexSet" - attributes(g)["version"] = 1 - N = length(is) - write(g, "length", N) - for n in 1:N - write(g, "index_$n", is[n]) - end -end - -function HDF5.read( - parent::Union{HDF5.File,HDF5.Group}, name::AbstractString, T::Type{<:Indices} -) - g = open_group(parent, name) - if read(attributes(g)["type"]) != "IndexSet" - error("HDF5 group or file does not contain IndexSet data") - end - n = read(g, "length") - return T(Index[read(g, "index_$j", Index) for j in 1:n]) -end diff --git a/src/itensor.jl b/src/itensor.jl index 5b13376371..efa9249382 100644 --- a/src/itensor.jl +++ b/src/itensor.jl @@ -2114,36 +2114,3 @@ function readcpp(io::IO, ::Type{ITensor}; format="v3") throw(ArgumentError("read ITensor: format=$format not supported")) end end - -function HDF5.write(parent::Union{HDF5.File,HDF5.Group}, name::AbstractString, T::ITensor) - g = create_group(parent, name) - attributes(g)["type"] = "ITensor" - attributes(g)["version"] = 1 - write(g, "inds", inds(T)) - return write(g, "storage", storage(T)) -end - -function HDF5.read( - parent::Union{HDF5.File,HDF5.Group}, name::AbstractString, ::Type{ITensor} -) - g = open_group(parent, name) - if read(attributes(g)["type"]) != "ITensor" - error("HDF5 group or file does not contain ITensor data") - end - # TODO: use Vector{Index} here? - inds = read(g, "inds", IndexSet) - - # check input file for key name of ITensor data - # ITensors.jl <= v0.1.x uses `store` as key - # whereas ITensors.jl >= v0.2.x uses `storage` as key - for key in ["storage", "store"] - if haskey(g, key) - stypestr = read(attributes(open_group(g, key))["type"]) - stype = eval(Meta.parse(stypestr)) - storage = read(g, key, stype) - return itensor(storage, inds) - end - end - return error("HDF5 file: $(g) does not contain correct ITensor data.\nNeither key - `store` nor `storage` could be found.") -end diff --git a/src/qn/qn.jl b/src/qn/qn.jl index ee28ca5b8a..638b8d6dbb 100644 --- a/src/qn/qn.jl +++ b/src/qn/qn.jl @@ -399,27 +399,3 @@ function show(io::IO, q::QN) end return print(io, ")") end - -function write(parent::Union{HDF5.File,HDF5.Group}, gname::AbstractString, q::QN) - g = create_group(parent, gname) - attributes(g)["type"] = "QN" - attributes(g)["version"] = 1 - names = [String(name(q[n])) for n in 1:maxQNs] - vals = [val(q[n]) for n in 1:maxQNs] - mods = [modulus(q[n]) for n in 1:maxQNs] - write(g, "names", names) - write(g, "vals", vals) - return write(g, "mods", mods) -end - -function read(parent::Union{HDF5.File,HDF5.Group}, name::AbstractString, ::Type{QN}) - g = open_group(parent, name) - if read(attributes(g)["type"]) != "QN" - error("HDF5 group or file does not contain QN data") - end - names = read(g, "names") - vals = read(g, "vals") - mods = read(g, "mods") - mqn = ntuple(n -> QNVal(names[n], vals[n], mods[n]), maxQNs) - return QN(mqn) -end diff --git a/src/qn/qnindex.jl b/src/qn/qnindex.jl index 85a5774d2b..83bbbe78c4 100644 --- a/src/qn/qnindex.jl +++ b/src/qn/qnindex.jl @@ -545,31 +545,3 @@ function show(io::IO, i::QNIndex) n < length(space(i)) && println(io) end end - -function HDF5.write(parent::Union{HDF5.File,HDF5.Group}, name::AbstractString, B::QNBlocks) - g = create_group(parent, name) - attributes(g)["type"] = "QNBlocks" - attributes(g)["version"] = 1 - write(g, "length", length(B)) - dims = [block[2] for block in B] - write(g, "dims", dims) - for n in 1:length(B) - write(g, "QN[$n]", B[n][1]) - end -end - -function HDF5.read( - parent::Union{HDF5.File,HDF5.Group}, name::AbstractString, ::Type{QNBlocks} -) - g = open_group(parent, name) - if read(attributes(g)["type"]) != "QNBlocks" - error("HDF5 group or file does not contain QNBlocks data") - end - N = read(g, "length") - dims = read(g, "dims") - B = QNBlocks(undef, N) - for n in 1:length(B) - B[n] = QNBlock(read(g, "QN[$n]", QN), dims[n]) - end - return B -end diff --git a/src/tagset.jl b/src/tagset.jl index 4dd1b9325c..b506f4dcfd 100644 --- a/src/tagset.jl +++ b/src/tagset.jl @@ -348,21 +348,3 @@ function readcpp(io::IO, ::Type{TagSet}; format="v3") end return ts end - -function HDF5.write(parent::Union{HDF5.File,HDF5.Group}, name::AbstractString, T::TagSet) - g = create_group(parent, name) - attributes(g)["type"] = "TagSet" - attributes(g)["version"] = 1 - return write(g, "tags", tagstring(T)) -end - -function HDF5.read( - parent::Union{HDF5.File,HDF5.Group}, name::AbstractString, ::Type{TagSet} -) - g = open_group(parent, name) - if read(attributes(g)["type"]) != "TagSet" - error("HDF5 group '$name' does not contain TagSet data") - end - tstring = read(g, "tags") - return TagSet(tstring) -end diff --git a/src/usings.jl b/src/usings.jl index f1bb1cf284..66e02ac2b9 100644 --- a/src/usings.jl +++ b/src/usings.jl @@ -10,7 +10,6 @@ using ChainRulesCore using Compat using DocStringExtensions using Functors -using HDF5 using IsApprox using LinearAlgebra using NDTensors diff --git a/test/base/test_readwrite.jl b/test/base/test_readwrite.jl index 0720997d39..63e47c9965 100644 --- a/test/base/test_readwrite.jl +++ b/test/base/test_readwrite.jl @@ -1,4 +1,6 @@ -using ITensors, HDF5, Test +using HDF5 +using ITensors +using Test include(joinpath(@__DIR__, "utils", "util.jl")) From c8a85b4096edfa954c4a31b90b56a72d5cb1af57 Mon Sep 17 00:00:00 2001 From: Miles Date: Fri, 12 Apr 2024 11:34:43 +0200 Subject: [PATCH 03/19] Move imports --- src/ITensorMPS/abstractmps.jl | 39 +++++++++++++++++------------------ 1 file changed, 19 insertions(+), 20 deletions(-) diff --git a/src/ITensorMPS/abstractmps.jl b/src/ITensorMPS/abstractmps.jl index ce84d93cf7..ae4645fc79 100644 --- a/src/ITensorMPS/abstractmps.jl +++ b/src/ITensorMPS/abstractmps.jl @@ -1,5 +1,24 @@ using IsApprox: Approx, IsApprox using NDTensors: using_auto_fermion, scalartype, tensor +import ITensors: + dag, + #dag!, + prime, + prime!, + setprime, + setprime!, + noprime, + noprime!, + swapprime, + swapprime!, + replaceprime, + replaceprime!, + addtags, + addtags!, + removetags, + removetags!, + settags, + settags! abstract type AbstractMPS end @@ -699,26 +718,6 @@ function map(f::Function, M::AbstractMPS; set_limits::Bool=true) return map!(f, copy(M); set_limits=set_limits) end -import ITensors: - dag, - #dag!, - prime, - prime!, - setprime, - setprime!, - noprime, - noprime!, - swapprime, - swapprime!, - replaceprime, - replaceprime!, - addtags, - addtags!, - removetags, - removetags!, - settags, - settags! - for fname in ( :dag, :prime, From a1f50494be3f931a5bf4ad135797cf0b980d7203 Mon Sep 17 00:00:00 2001 From: Miles Date: Fri, 12 Apr 2024 11:34:56 +0200 Subject: [PATCH 04/19] Add HDF5 to weakdeps for Julia 1.6 --- Project.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/Project.toml b/Project.toml index 61f67b77a4..7ab208b437 100644 --- a/Project.toml +++ b/Project.toml @@ -73,4 +73,5 @@ ZygoteRules = "0.2.2" julia = "1.6" [extras] +HDF5 = "f67ccb44-e63f-5c2f-98bd-6dc0ccc4ba2f" VectorInterface = "409d34a3-91d5-4945-b6ec-7529ddf182d8" From cbadd5dc54ac1132567f35481a7ddff59a036d15 Mon Sep 17 00:00:00 2001 From: Miles Date: Fri, 12 Apr 2024 14:38:51 +0200 Subject: [PATCH 05/19] Add directsum to docs [no ci] --- docs/src/ITensorType.md | 1 + src/tensor_operations/tensor_algebra.jl | 2 ++ 2 files changed, 3 insertions(+) diff --git a/docs/src/ITensorType.md b/docs/src/ITensorType.md index ea8f3e1bc5..f95cec96d3 100644 --- a/docs/src/ITensorType.md +++ b/docs/src/ITensorType.md @@ -117,6 +117,7 @@ swapinds(::ITensor, ::Any...) ```@docs *(::ITensor, ::ITensor) dag(T::ITensor; kwargs...) +directsum(::Pair{ITensor},::Pair{ITensor},::Pair{ITensor},args...; kws...) exp(::ITensor, ::Any, ::Any) nullspace(::ITensor, ::Any...) ``` diff --git a/src/tensor_operations/tensor_algebra.jl b/src/tensor_operations/tensor_algebra.jl index 2f3444eb13..900b47cb97 100644 --- a/src/tensor_operations/tensor_algebra.jl +++ b/src/tensor_operations/tensor_algebra.jl @@ -396,6 +396,8 @@ Given a list of pairs of ITensors and indices, perform a partial direct sum of the tensors over the specified indices. Indices that are not specified to be summed must match between the tensors. +(Note: `Pair{ITensor}` in Julia is short for `Pair{ITensor,<:Any}` which means any pair `T => x` where `T` is an ITensor.) + If all indices are specified then the operation is equivalent to creating a block diagonal tensor. From 9bec5f09206d84efe4963a65d747b1183e0d26d4 Mon Sep 17 00:00:00 2001 From: Miles Date: Fri, 12 Apr 2024 15:38:18 +0200 Subject: [PATCH 06/19] Update version to 0.4.0 --- Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index 7ab208b437..59e8373b04 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "ITensors" uuid = "9136182c-28ba-11e9-034c-db9fb085ebd5" authors = ["Matthew Fishman ", "Miles Stoudenmire "] -version = "0.3.66" +version = "0.4.0" [deps] Adapt = "79e6a3ab-5dfb-504d-930d-738a2a938a0e" From eae864591c6acb06d2a687d5b03a26194719c84b Mon Sep 17 00:00:00 2001 From: Miles Date: Fri, 12 Apr 2024 16:46:34 +0200 Subject: [PATCH 07/19] Improve style of test_readwrite.jl --- test/base/test_readwrite.jl | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/test/base/test_readwrite.jl b/test/base/test_readwrite.jl index 63e47c9965..3e2251bfe9 100644 --- a/test/base/test_readwrite.jl +++ b/test/base/test_readwrite.jl @@ -1,6 +1,7 @@ -using HDF5 -using ITensors -using Test +@eval module $(gensym()) +using HDF5: h5open, read, write +using ITensors: Index, prime, randomITensor +using Test: @test, @testset include(joinpath(@__DIR__, "utils", "util.jl")) @@ -182,3 +183,5 @@ include(joinpath(@__DIR__, "utils", "util.jl")) # rm(joinpath(@__DIR__, "data.h5"); force=true) end + +end From 7e0bf0da37f1369ace422cf25f073ea9851f58cc Mon Sep 17 00:00:00 2001 From: Miles Date: Fri, 12 Apr 2024 16:48:32 +0200 Subject: [PATCH 08/19] Code style update --- ext/ITensorsHDF5Ext/itensor.jl | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/ext/ITensorsHDF5Ext/itensor.jl b/ext/ITensorsHDF5Ext/itensor.jl index 93a694bd93..f3c8fcb9b1 100644 --- a/ext/ITensorsHDF5Ext/itensor.jl +++ b/ext/ITensorsHDF5Ext/itensor.jl @@ -1,4 +1,4 @@ -using ITensors: IndexSet, inds, itensor, ITensor, storage +using ITensors: inds, itensor, ITensor, storage using NDTensors: NDTensors, BlockSparse, Combiner, Dense, Diag, DiagBlockSparse, EmptyStorage @@ -17,8 +17,7 @@ function HDF5.read( if read(attributes(g)["type"]) != "ITensor" error("HDF5 group or file does not contain ITensor data") end - # TODO: use Vector{Index} here? - inds = read(g, "inds", IndexSet) + inds = read(g, "inds", Vector{<:Index}) # check input file for key name of ITensor data # ITensors.jl <= v0.1.x uses `store` as key From 32123230e1a5b7098f2ee8e0923b8ec7d122d07e Mon Sep 17 00:00:00 2001 From: Miles Date: Fri, 12 Apr 2024 22:15:59 +0200 Subject: [PATCH 09/19] Move HDF5 using statements into source files --- ext/ITensorsHDF5Ext/ITensorMPS/mpo.jl | 1 + ext/ITensorsHDF5Ext/ITensorMPS/mps.jl | 1 + ext/ITensorsHDF5Ext/ITensorsHDF5Ext.jl | 2 -- ext/ITensorsHDF5Ext/index.jl | 1 + ext/ITensorsHDF5Ext/indexset.jl | 1 + ext/ITensorsHDF5Ext/itensor.jl | 1 + ext/ITensorsHDF5Ext/qn.jl | 1 + ext/ITensorsHDF5Ext/qnindex.jl | 1 + ext/ITensorsHDF5Ext/tagset.jl | 1 + 9 files changed, 8 insertions(+), 2 deletions(-) diff --git a/ext/ITensorsHDF5Ext/ITensorMPS/mpo.jl b/ext/ITensorsHDF5Ext/ITensorMPS/mpo.jl index 09d10f1b02..722d0be30d 100644 --- a/ext/ITensorsHDF5Ext/ITensorMPS/mpo.jl +++ b/ext/ITensorsHDF5Ext/ITensorMPS/mpo.jl @@ -1,3 +1,4 @@ +using HDF5: HDF5, attributes, create_group, open_group, read, write using ITensors: ITensor using ITensors.ITensorMPS: MPO diff --git a/ext/ITensorsHDF5Ext/ITensorMPS/mps.jl b/ext/ITensorsHDF5Ext/ITensorMPS/mps.jl index 3fefd8d7a7..45e479eb1a 100644 --- a/ext/ITensorsHDF5Ext/ITensorMPS/mps.jl +++ b/ext/ITensorsHDF5Ext/ITensorMPS/mps.jl @@ -1,3 +1,4 @@ +using HDF5: HDF5, attributes, create_group, open_group, read, write using ITensors: ITensor using ITensors.ITensorMPS: MPS diff --git a/ext/ITensorsHDF5Ext/ITensorsHDF5Ext.jl b/ext/ITensorsHDF5Ext/ITensorsHDF5Ext.jl index 03dbfefb88..f3c9db0376 100644 --- a/ext/ITensorsHDF5Ext/ITensorsHDF5Ext.jl +++ b/ext/ITensorsHDF5Ext/ITensorsHDF5Ext.jl @@ -1,7 +1,5 @@ module ITensorsHDF5Ext -using HDF5: HDF5, attributes, create_group, open_group, read, write - include("index.jl") include("itensor.jl") include("qnindex.jl") diff --git a/ext/ITensorsHDF5Ext/index.jl b/ext/ITensorsHDF5Ext/index.jl index 213ddd86fb..587f7c20ae 100644 --- a/ext/ITensorsHDF5Ext/index.jl +++ b/ext/ITensorsHDF5Ext/index.jl @@ -1,3 +1,4 @@ +using HDF5: HDF5, attributes, create_group, open_group, read, write using ITensors: Arrow, dim, dir, id, Index, plev, QNBlocks, space, tags, TagSet function HDF5.write(parent::Union{HDF5.File,HDF5.Group}, name::AbstractString, I::Index) diff --git a/ext/ITensorsHDF5Ext/indexset.jl b/ext/ITensorsHDF5Ext/indexset.jl index 0351d43f44..22e9886b67 100644 --- a/ext/ITensorsHDF5Ext/indexset.jl +++ b/ext/ITensorsHDF5Ext/indexset.jl @@ -1,3 +1,4 @@ +using HDF5: HDF5, attributes, create_group, open_group, read, write using ITensors: Index, Indices function HDF5.write(parent::Union{HDF5.File,HDF5.Group}, name::AbstractString, is::Indices) diff --git a/ext/ITensorsHDF5Ext/itensor.jl b/ext/ITensorsHDF5Ext/itensor.jl index f3c8fcb9b1..bca520406a 100644 --- a/ext/ITensorsHDF5Ext/itensor.jl +++ b/ext/ITensorsHDF5Ext/itensor.jl @@ -1,3 +1,4 @@ +using HDF5: HDF5, attributes, create_group, open_group, read, write using ITensors: inds, itensor, ITensor, storage using NDTensors: NDTensors, BlockSparse, Combiner, Dense, Diag, DiagBlockSparse, EmptyStorage diff --git a/ext/ITensorsHDF5Ext/qn.jl b/ext/ITensorsHDF5Ext/qn.jl index f8d8da5039..d7ae10d5c4 100644 --- a/ext/ITensorsHDF5Ext/qn.jl +++ b/ext/ITensorsHDF5Ext/qn.jl @@ -1,3 +1,4 @@ +using HDF5: HDF5, attributes, create_group, open_group, read, write using ITensors: maxQNs, modulus, name, QN, QNVal, val function HDF5.write(parent::Union{HDF5.File,HDF5.Group}, gname::AbstractString, q::QN) diff --git a/ext/ITensorsHDF5Ext/qnindex.jl b/ext/ITensorsHDF5Ext/qnindex.jl index 742c0f1ba2..996f2b4a17 100644 --- a/ext/ITensorsHDF5Ext/qnindex.jl +++ b/ext/ITensorsHDF5Ext/qnindex.jl @@ -1,3 +1,4 @@ +using HDF5: HDF5, attributes, create_group, open_group, read, write using ITensors: dims, QNBlock, QNBlocks function HDF5.write(parent::Union{HDF5.File,HDF5.Group}, name::AbstractString, B::QNBlocks) diff --git a/ext/ITensorsHDF5Ext/tagset.jl b/ext/ITensorsHDF5Ext/tagset.jl index 27d0f602dd..47d226e204 100644 --- a/ext/ITensorsHDF5Ext/tagset.jl +++ b/ext/ITensorsHDF5Ext/tagset.jl @@ -1,3 +1,4 @@ +using HDF5: HDF5, attributes, create_group, open_group, read, write using ITensors: TagSet, tagstring function HDF5.write(parent::Union{HDF5.File,HDF5.Group}, name::AbstractString, T::TagSet) From 881083300ea958390b85a031e88c2dade0d0e25c Mon Sep 17 00:00:00 2001 From: Miles Date: Fri, 12 Apr 2024 22:34:47 +0200 Subject: [PATCH 10/19] Fix merge error --- Project.toml | 1 - 1 file changed, 1 deletion(-) diff --git a/Project.toml b/Project.toml index 33bd8349b8..5ec3e26129 100644 --- a/Project.toml +++ b/Project.toml @@ -2,7 +2,6 @@ name = "ITensors" uuid = "9136182c-28ba-11e9-034c-db9fb085ebd5" authors = ["Matthew Fishman ", "Miles Stoudenmire "] version = "0.4.0" -version = "0.3.67" [deps] Adapt = "79e6a3ab-5dfb-504d-930d-738a2a938a0e" From aa4b72dbfa0eeaeda58dcb20a3228d8c9369219d Mon Sep 17 00:00:00 2001 From: Miles Date: Fri, 12 Apr 2024 22:48:57 +0200 Subject: [PATCH 11/19] Append 0.4 to ITensors compat entries in GaussianMPS and VisualizationBase --- ITensorGaussianMPS/Project.toml | 2 +- ITensorVisualizationBase/Project.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ITensorGaussianMPS/Project.toml b/ITensorGaussianMPS/Project.toml index e0405b157d..5ba722bc51 100644 --- a/ITensorGaussianMPS/Project.toml +++ b/ITensorGaussianMPS/Project.toml @@ -10,6 +10,6 @@ LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" [compat] Compat = "3.40.0, 4" -ITensors = "0.3.58" +ITensors = "0.3.58, 0.4" LinearAlgebra = "1.6" julia = "1.6" diff --git a/ITensorVisualizationBase/Project.toml b/ITensorVisualizationBase/Project.toml index 4783bc492a..06bf3407b3 100644 --- a/ITensorVisualizationBase/Project.toml +++ b/ITensorVisualizationBase/Project.toml @@ -20,7 +20,7 @@ AbstractTrees = "0.4" Compat = "3.40.0, 4" GeometryBasics = "0.4.1" Graphs = "1.4.1" -ITensors = "0.2.12, 0.3" +ITensors = "0.2.12, 0.3, 0.4" MetaGraphs = "0.7.1" NetworkLayout = "0.4.3" Statistics = "1" From d80af882050c3d859572968c27b65a4c0997b84f Mon Sep 17 00:00:00 2001 From: Miles Date: Sat, 13 Apr 2024 19:32:13 +0200 Subject: [PATCH 12/19] Bump patch versions of ITensorVisualizationBase and ITensorGaussianMPS [no ci] --- ITensorGaussianMPS/Project.toml | 2 +- ITensorVisualizationBase/Project.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ITensorGaussianMPS/Project.toml b/ITensorGaussianMPS/Project.toml index 5ba722bc51..4e81830424 100644 --- a/ITensorGaussianMPS/Project.toml +++ b/ITensorGaussianMPS/Project.toml @@ -1,7 +1,7 @@ name = "ITensorGaussianMPS" uuid = "2be41995-7c9f-4653-b682-bfa4e7cebb93" authors = ["Matthew Fishman and contributors"] -version = "0.1.4" +version = "0.1.5" [deps] Compat = "34da2185-b29b-5c13-b0c7-acf172513d20" diff --git a/ITensorVisualizationBase/Project.toml b/ITensorVisualizationBase/Project.toml index 06bf3407b3..9316ab33e1 100644 --- a/ITensorVisualizationBase/Project.toml +++ b/ITensorVisualizationBase/Project.toml @@ -1,7 +1,7 @@ name = "ITensorVisualizationBase" uuid = "cd2553d2-8bef-4d93-8a38-c62f17d5ad23" authors = ["Matthew Fishman and contributors"] -version = "0.1.5" +version = "0.1.6" [deps] AbstractTrees = "1520ce14-60c1-5f80-bbc7-55ef81b5835c" From a25236ef6ac563c5344fced78618fef377d5e712 Mon Sep 17 00:00:00 2001 From: Miles Date: Mon, 15 Apr 2024 21:22:08 -0400 Subject: [PATCH 13/19] Add NEWS.md entry for 0.4.0 [no ci] --- NEWS.md | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/NEWS.md b/NEWS.md index 52d994166d..24a164c055 100644 --- a/NEWS.md +++ b/NEWS.md @@ -6,6 +6,24 @@ Note that as of Julia v1.5, in order to see deprecation warnings you will need t After we release v1 of the package, we will start following [semantic versioning](https://semver.org). +ITensors v0.4.0 Release Notes +============================== + +This version removes HDF5 as a dependency and moves the HDF5 +read and write functions for ITensor, MPS, MPO, and other associated +types into a package extension. To enable ITensor HDF5 features, +install the HDF5 package and put `using HDF5` before `using ITensors` +in your code. + +Bugs (since v0.3.66): +- Fixes to CI (GLMakie and other workflows) +- Fix incorrect ITensor constructor declaration in docs + +Enhancements (since v0.3.66): +- Refactoring GPU extensions (#1365) +- Add directsum function to docs + + ITensors v0.3.22 Release Notes ============================== From b33fd458d44cb6590401c1407ba4b74b5f25edc7 Mon Sep 17 00:00:00 2001 From: Miles Date: Tue, 16 Apr 2024 10:52:38 -0400 Subject: [PATCH 14/19] Move 0.4 news entry to docs index page. Remove NEWS.md file. [no ci] --- NEWS.md | 851 ---------------------------------------------- docs/src/index.md | 2 + 2 files changed, 2 insertions(+), 851 deletions(-) delete mode 100644 NEWS.md diff --git a/NEWS.md b/NEWS.md deleted file mode 100644 index 24a164c055..0000000000 --- a/NEWS.md +++ /dev/null @@ -1,851 +0,0 @@ -This file is a (mostly) comprehensive list of changes made in each release of ITensors.jl. For a completely comprehensive but more verbose list, see the [commit history on Github](https://github.com/ITensor/ITensors.jl/commits/main). - -While we are in v0.x of the package, we will follow the convention that updating from v0.x.y to v0.x.(y+1) (for example v0.1.15 to v0.1.16) should not break your code, unless you are using internal/undocumented features of the code, while updating from `v0.x.y` to `v0.(x+1).y` might break your code, though we will try to add deprecation warnings when possible, such as for simple cases where the name of a function changes. - -Note that as of Julia v1.5, in order to see deprecation warnings you will need to start Julia with `julia --depwarn=yes` (previously they were on by default). Please run your code like this before upgrading between minor versions of the code (for example from v0.1.41 to v0.2.0). - -After we release v1 of the package, we will start following [semantic versioning](https://semver.org). - -ITensors v0.4.0 Release Notes -============================== - -This version removes HDF5 as a dependency and moves the HDF5 -read and write functions for ITensor, MPS, MPO, and other associated -types into a package extension. To enable ITensor HDF5 features, -install the HDF5 package and put `using HDF5` before `using ITensors` -in your code. - -Bugs (since v0.3.66): -- Fixes to CI (GLMakie and other workflows) -- Fix incorrect ITensor constructor declaration in docs - -Enhancements (since v0.3.66): -- Refactoring GPU extensions (#1365) -- Add directsum function to docs - - -ITensors v0.3.22 Release Notes -============================== - -Bugs: - -Enhancements: - -- `contract(::MPO, ::MPS)` rrule (#1025) - -ITensors v0.3.21 Release Notes -============================== - -Bugs: - -Enhancements: - -- Document the write_path option for dmrg (df2a665) -- Bump compats Functors 0.4, NDTensors 0.1.45 (#1031) -- Fix auto fermion system for non-QN tensors (#1027) -- MPOs constructed from sums of one-site operators now have bond dimension 2 (#1015) -- Update readwrite test (#1007) -- Generalize `inner(::MPO, ::MPS, ::MPO, ::MPS)` to other tag/prime conventions (#995) -- Fix variable declaration warnings (#994) -- Refactor (#980) -- Add Proj0, Proj1 aliases for ProjUp, ProjDn (3d84a5e) -- Define F operator for Qudit and Boson (#977) -- HDF5 Support for Diag Storage (#976) -- Allow user to set the path for disk (#975) - -ITensors v0.3.20 Release Notes -============================== - -Bugs: - -- Fix bug contracting rectangular Diag with Dense (#970) - -Enhancements: - -- `site_range` keyword for `truncate!` to only truncate part of an MPS (#971) -- Fix issue with tolerance in `lognorm` when checking that the inner product is real (#973) - -ITensors v0.3.19 Release Notes -============================== - -Bugs: - -- Fix bug in MPO(::OpSum, ...) when on-site operators have no blocks (#963) - -Enhancements: - -- Allow specifying non-uniform link dimensions in MPS constructors (#951) -- Add splitblocks keyword argument to `MPO(::OpSum, ...)` constructor, which defaults to `splitblocks=true` (#963) -- Allow specifying the element type of the output MPO with MPO(::Type, ::OpSum, ...), for example MPO(Float32, opsum, sites) to use single precision (#963) -- Improve overloading interface for "Qudit"/"Boson" types, overload `ITensors.op(::OpName"new_op", ::SiteType"Qudit", d::Int)` (#963) -- Fix typo in contraction sequence optimization code for some cases with empty indices (#965) -- Add keyword arguments support for `ITensors.state` (#964) -- Document and tweak the tolerance of the `nullspace` function (#960) -- Improve functionality for transferring data between CPU and GPU (#956) -- Fix `expect` and `correlation_matrix` for MPS on GPU (#956) -- Make sure QR and SVD preserve element type (i.e. single precision) in more cases (#956) -- Remove Sweeps object in examples and docs (#959) -- Pass kwargs through to truncate in Dense factorizations (#958) -- Optimize apply `rrule` for MPS/MPO by improving contraction sequence when contracting forward and reverse MPS/MPO (#955) -- Simplify the `rrule`s for priming and tagging MPS/MPO (#950) - -ITensors v0.3.18 Release Notes -============================== - -Bugs: - -- Extend `apply(::MPO, ::MPO)` to `apply(::MPO, ::MPO, ::MPO...)` (#949) -- Fix AD for `apply(::MPO, ::MPO)` and `contract(::MPO, ::MPO)` (#949) -- Properly use element type in `randomMPS` in the 1-site case (b66d1b7) -- Fix bug in `tr(::MPO)` rrule where the derivative was being multiplied twice into the identity MPO (b66d1b7) -- Fix directsum when specifying a single `Index` (#930) -- Fix bug in loginner when inner is negative or complex (#945) -- Fix subtraction bug in `OpSum` (#945) - -Enhancements: - -- Define "I" for Qudit/Boson type (b66d1b7) -- Only warn in `inner` if the result is `Inf` or `NaN` (b66d1b7) -- Make sure `randomITensor(())` and `randomITensor(Float64, ())` returns a Dense storage type (b66d1b7) -- Define `isreal` and `iszero` for ITensors (b66d1b7) -- Project element type of ITensor in reverse pass of tensor-tensor or scalar-tensor contraction (b66d1b7) -- Define reverse rules for ITensor subtraction and negation (b66d1b7) -- Define `map` for ITensors (b66d1b7) -- Throw error when performing eigendecomposition of tensor with NaN or Inf elements (b66d1b7) -- Fix `rrule` for `MPO` constructor by generalizing the `rrule` for the `MPS` constructor (#946) -- Forward truncation arguments to more operations in `rrule` for `apply` (#945) -- Add rrules for addition and subtraction of MPOs (#935) - -ITensors v0.3.17 Release Notes -============================== - -Bugs: - -Enhancements: - -- Add Zp as alias for operator Z+, etc. (#942) -- Export diag (#942) - -ITensors v0.3.16 Release Notes -============================== - -Bugs: - -Enhancements: - -- Define `nullspace` for ITensors (#929) - -ITensors v0.3.15 Release Notes -============================== - -Bugs: - -Enhancements: - -- Fix `randomMPS` and `svd` for `Float32`/`ComplexF32` (#926) - -ITensors v0.3.14 Release Notes -============================== - -Bugs: - -Enhancements: - -- Add backend `alg="directsum"` for MPS/MPO addition (#925) -- Add `alg="naive"` for MPO contraction (#925) -- Add `svd`/`eigen` option `cutoff<0` or `cutoff=nothing`, indicating that no truncation should be performed based on a cutoff (previously you could only specify `cutoff=0.0` which still truncated eigenvalues of 0) (#925) -- Fixes an issue that `mindim` wasn't be used in `eigen` (#925) -- Remove `OpSum` in favor of `Ops.OpSum` (#920) - -ITensors v0.3.13 Release Notes -============================== - -Bugs: - -Enhancements: - -- Implement `min_blockdim` keyword for blocksparse SVD (#923) -- Add support for non-zero flux MPOs to OpSum (#918) - -ITensors v0.3.12 Release Notes -============================== - -Bugs: - -Enhancements: - -- Fix `svd` and `qr` for empty input left or right indices (#917) -- Add support for defining MPOs from operators represented as matrices (#904) - -ITensors v0.3.11 Release Notes -============================== - -Bugs: - -Enhancements: - -- Introduce `removeqn` function for removing a specified quantum number (#915) -- Non-Hermitian `dmrg` (#913) -- Clean up QN `svd` code in `ITensors` by handling QN blocks better in `NDTensors` (#906) - -ITensors v0.3.10 Release Notes -============================== - -Bugs: - -Enhancements: - -- Update installation instructions for Julia 1.7. - -ITensors v0.3.9 Release Notes -============================= - -Bugs: - -Enhancements: - -- Haar random unitary gate and generalize identity operator to arbitrary number of sites (#903). -- Improve error messages for op. -- Return the original MPS/MPO when normalizing a zero MPS/MPO (#901). -- Allow Matrix representations for operators in `expect` and `correlation_matrix` (#902). - -ITensors v0.3.8 Release Notes -============================= - -Bugs: - -Enhancements: - -- Increase maximum TagSet size to 16 characters (#882) - -ITensors v0.3.7 Release Notes -============================= - -Bugs: - -- Fix for performance issue when applying gates that skip sites (#900). - -Enhancements: - -ITensors v0.3.6 Release Notes -============================= - -Bugs: - -- Fix bug in `op(opname, s::Vector{<:Index})` and `op(s::Vector{<:Index}, opname)`. - -Enhancements: - -ITensors v0.3.5 Release Notes -============================= - -Bugs: - -Enhancements: - -- Generalize `op` to handle `Matrix`/`String` inputs more generically (#899) - -ITensors v0.3.4 Release Notes -============================= - -Bugs: - -Enhancements: - -- Simplify rrules for Index manipulation of ITensors (#888) -- Add some helper functions like converting element types of ITensors (#898) - - `cu([A, B])` -> `[cu(A), cu(B)]` (same for `cpu`). - - `cu([[A, B], [C]])` -> `[[cu(A), cu(B)], [cu(C)]]` (same for `cpu`). - - `convert_eltype(T::Type, A::ITensor)` - convert the element type of an ITensor to `T`. - - `convert_leaf_eltype(T, A::MPS)` - convert the element types of the ITensors of an MPS/MPO. - - `convert_leaf_eltype(T, [[A, B], C])` - convert the element types of ITensors `A`, `B`, `C` in a nested data structure (useful for layered gate structures used in PastaQ). - - `contract(A::MPS)` - contract the ITensors of an MPS/MPO into an ITensor (previously we used `prod` for that but I think using ` contract` is clearer). - - `array(A::ITensor, i::Index, j::Index, ...)` - convert the ITensor to an Array, first permuting into the Index ordering `i, j, ...`. Previously I used `array(permute(A, i, j, ...))` for this but this is more convenient. - - `A(x)` as a simpler syntax for `apply(A::ITensor, x::ITensor)`, treating `A` as an operator from unprimed to primed indices. I've already defined this syntax for `MPO` and `MPS` and I think it is pretty nice. I was holding off on doing this for a while to see if there might be a better meaning for `A(B)` but - - Define `complex`, `real`, `imag`, and `conj` for MPS/MPO by applying them to the ITensors of the MPS/MPO. Maybe there is a better meaning for these, as in the MPS that is the real part of the MPS defined as a state? - -ITensors v0.3.3 Release Notes -============================= - -Bugs: - -Enhancements: - -- Add `copy` for `AbstractProjMPO` (#895) - -ITensors v0.3.2 Release Notes -============================= - -Bugs: - -Enhancements: - -- Introduce `set_nsite!` generic `AbstractProjMPO` function (#894) -- Factorize out `contract(::ProjMPO, ::ITensor)` (#893) - -ITensors v0.3.1 Release Notes -============================= - -Bugs: - -Enhancements: - -- Introduce `Algorithm` type for selecting algorithm backends (#886) - -ITensors v0.3.0 Release Notes -============================= - -Bugs: - -Enhancements: - -- Introduce `apply(::MPO, ::MPO)` (#880) -- Make automatic differentiation work for `contract(::ITensor...)` (#878) -- Deprecate automatically making indices match in `inner` and `outer` (#877) - - Add test for `apply(::MPO, ::MPS) = noprime(contract(::MPO, ::MPS))` and lazy version `Apply(::MPO, ::MPS)`. - - Define `isapprox(::AbstractMPS, ::AbstractMPS)`. -- correlation_matrix sites keyword (#868) - - Implement non-contiguous sites for correlation_matrix -- rrule for MPS(Vector{::ITensor}) (#865) - - `rrule` for constructing an `MPS` from a `Vector{ITensor}`. - - Improve `op(::OpName ,::SiteType"Qudit")` for handling two-body ops. - - Add support for storing a `Function` in an `op` in the format `(f, opame, support, (params...))`. -- Fix expect for complex MPS (#867) -- Get some AD working for LazyApply and Ops (#859) -- + and - in the op system (#857) -- Rename expect site_range keyword to sites (#858) - - Allow more general sites collections to be passed including single site number that maps to scalar outputs. - - Add ishermitian for ITensors - - Improve handling of types and non-Hermitian operators in expect - - Define ITensor transpose -- Improve Sweeps constructors with keyword arguments and default init (#856) -- rrules for apply(U, ::MPO), `(::MPO * ::MPO)`, `tr(::MPO)` (#852) -- Unification of PastaQ.gate and `ITensors.op`, new `OpSum` algebra functions (#843) -- Change minimal required Julia version from 1.3 to 1.6 (#849) - - Add default `maxdim=typemax(Int)` in `dmrg`. - -ITensors v0.2.16 Release Notes -============================== - -Bugs: - -- Fix `inner` `MPS` `rrule` for complex and QNs, add tests (#836) -- Fix differentation of apply(::ITensor, ::ITensor) (#831) -- Fix string indexing when setting elements (#826) - - Fix string indexing when setting elements, such as `T[i => "Up"] = 1.0`. - - Change `ITensor` `rrule` constructor signature from `typeof(ITensor)` to `Type{ITensor}`. - -Enhancements: - -- Define `diag(::Tensor)`, `diag(::ITensor)` (#837) -- Support indexing notation A[Up] (#839) -- Allow dividing by scalar ITensor (#838) -- Add `normalize[!](::MPS/MPO)` (#820) -- More flexible `state` syntax (overloading and calling) (#833) - - `state` defined with Index now should return an `ITensor`, for consistency with how `op` definitions work (this PR supports backwards compatibility for the now-deprecated syntax which returns a Vector that gets automatically converted to an ITensor -). - - Allow syntax like `state("Up", Index(2, "S=1/2"))` (previously only `state(Index(2, "S=1/2"), "Up")` worked). -- Define inner(::ITensor, ::ITensor) (#835) -- Add more compact kwarg sweeps syntax for DMRG (#834) -- Fix prime/tag rrule for MPS/MPO (#830) -- Simplify Dense AutoMPO Backend, output lower triangular MPO in dense case (#828) -- Fix `ITensor` `rrule` with `Array` reshaping (#824) -- Add Riemannian optimization example - -ITensors v0.2.15 Release Notes -============================== - -- Handle non-Hermitian `correlation_matrix` properly (#817) -- Fix ElecK state definitions in example. - -ITensors v0.2.14 Release Notes -============================== - -- Fix ITensor rrule and generalize ITensor to Array conversion (#818) -- Fix apply and inner rrules for complex and QN conserving MPS (#816) -- Change ordering that `op` definitions get called (#816) - -ITensors v0.2.13 Release Notes -============================== - -- Fix eltype promotion dividing ITensor by scalar (#813) -- Make getindex on EmptyStorage return EmptyNumber (#812) -- Add variational circuit optimization (#811) -- Expand ITensor development guide (#809) -- Add issue templates for all subdir packages (#808) -- Change randomMPS bond dim error to warning (#806) -- Add docs for enabling debug checks (#801) -- Remove ignore comments for JuliaFormatter (#799) -- Improve docstrings for apply and ITensor constructors (#797) -- FAQ on the relationship of ITensor to other tensor libraries (#795) -- Move ITensorVisualizationCore into ITensors module (#787) - -ITensors v0.2.12 Release Notes -============================== - -- Use registered subdir version of NDTensors (#780) - -ITensors v0.2.11 Release Notes -============================== - -- Fix bug when slicing a Dense Tensor with mixed ranges and integers (#775) -- Fix rrule for Array to ITensor constructor when forward and reverse indices are in different orders (#773) -- Fix MPO OpSum for operator names with unicode (#767) -- Lazy Op system (#769) -- Add ITensorNetworkMap (#764) -- Fix conj and scalar multiplication of EmptyStorage (#756) -- Fix the link for the qudit sitetype (#762) - -ITensors v0.2.10 Release Notes -============================== - -- Add ChainRules rules for basic reverse mode AD operations with ITensors (#761) - -ITensors v0.2.9 Release Notes -============================== - -- Fix test truncation test for Julia 1.7 (#755) -- Fix contraction ordering in correlation matrix (#754) - -ITensors v0.2.8 Release Notes -============================== - -- Fix bug in `permute` (and therefore `indpairs` and `tr(::ITensor)`) (#750) -- Add support for multisite operators and passing parameters into operators in `OpSum` (no support in `MPO` construction yet) (#749) -- Fix subtraction of term from `OpSum`. Add more unicode operator name aliases (#748) - -ITensors v0.2.7 Release Notes -============================== - -- Fix bug in threaded block sparse contraction, add CI tests for threading (#746) -- Limit `maxdim` in default ("densitymatrix") contract `MPO * MPS` code (#744) -- Add highlighting to ITensor paper bibtex in README (#738) -- Generalize `Array` -> `ITensor` constructor to allow `AbstractArray` (#737) -- Fix dispatch issue when indices input into ITensor constructor had abstract element types like `Vector{Index}` (#737) -- Pass kwargs in MPO contract (#733) -- Use Compat to make blas_get_num_threads simpler (#731) -- Generalize ITensor constructors to allow mixtures of collections of indices (`Tuple`s and `Vector`s) (#728) -- Add some more ITensor constructors like `ITensor([2.3])` and `ITensor(2.3, QN(), i', dag(i))` (#728) - -ITensors v0.2.6 Release Notes -============================== - -- Add Qudit site type with QNs as well as Boson alias (#727) -- Tighten accuracy cutoff for OpSum/AutoMPO (#726) -- Add support for complex data written by C++ ITensor for block sparse tensors (#724) - -ITensors v0.2.5 Release Notes -============================== - -- Fixed bug involving missing default case for state function (#719) -- Add support for reading complex ITensors written from C++ (#720) -- Fix HDF5 read compatilibity between ITensors v0.1 and v0.2 (#715) (@tschneider) -- Improve inference in NDTensors contraction and start writing a new precompile file (off by default) (#655) - -ITensors v0.2.4 Release Notes -============================== - -- Fix state function when overloading version that accepts an Index (#711) -- Started work on FAQs (#709) -- Add denseblocks definition for Diag storage (#710) -- Code examples about making an array from an ITensor, QR with postive R, and sampling an MPS (#705) -- Prepend site type functions with ITensors to make it clearer to users how they should write their own overloads (#704) -- Fix issue with Index arrow for QN case of `correlation_matrix` (#702) -- Add `sim(::Pair{<:Index})` (#701) -- Add `norm(::EmptyStorage)` (#699) - -ITensors v0.2.3 Release Notes -============================== - -- Add `denseblocks` to convert from `DiagBlockSparse` to `BlockSparse` storage (PR #693). -- Make A == B return false if ITensors A and B have different indices (PR #690). - -ITensors v0.2.2 Release Notes -============================== - -- Make Index non-broadcastable so you can do: `i = Index(2); i .^ (0, 1, 2)` (PR #689). -- Add interface `contract([A, [B, C]])` for recursively contracting a tensor network tree, equivalent to `contract([A, B, C]; sequence=[1, [2, 3]])` (PR #686). -- Allow plain integer tags, such as `Index(2, "1")` (PR #686). - -ITensors v0.2.1 Release Notes -============================== - -- Fix MPS product state constructor to use new state function system, and fix some incorrect site type overloads (for Fermion and S=1/2) (PR #685) -- Improve and update documentation in various places - -ITensors v0.2.0 Release Notes -============================== - -Breaking changes: ------------------ - -- Change QN convention of the Qubit site type to track the total number of 1 bits instead of the net number of 1 bits vs 0 bits (i.e. change the QN from +1/-1 to 0/1) (PR #676). -- Remove `IndexVal` type in favor of `Pair{<:Index}`. `IndexVal{IndexT}` is now an alias for `Pair{IndexT,Int}`, so code using `IndexVal` such as `IndexVal(i, 2)` should generally still work. However, users should change from `IndexVal(i, 2)` to `i => 2` (PR #665). -- Rename the `state` functions currently defined for various site types to `val` for mapping a string name for an index to an index value (used in ITensor indexing and MPS construction). `state` functions now return single-index ITensors representing various single-site states (PR #664). -- `maxlinkdim(::MPO/MPS)` returns a minimum of `1` (previously it returned 0 for MPS/MPO without and link indices) (PR #663). -- The `NDTensors` module has been moved into the `ITensors` package, so `ITensors` no longer depends on the standalone `NDTensors` package. This should only effect users who were using both `NDTensors` and `ITensors` seperately. If you want to use the latest `NDTensors` library, you should do `using ITensors.NDTensors` instead of `using NDTensors`, and will need to install `ITensors` with `using Pkg; Pkg.add("ITensors")` in order to use the latest versions of `NDTensors`. Note the current `NDTensors.jl` package will still exist, but for now developmentof `NDTensors` will occur within `ITensors.jl` (PR # 650). -- `ITensor` constructors from collections of `Index`, such as `ITensor(i, j, k)`, now return an `ITensor` with `EmptyStorage` (previously called `Empty`) storage instead of `Dense` or `BlockSparse` storage filled with 0 values. Most operations should still work that worked previously, but please contact us if there are issues (PR #641). -- ITensors now store a `Tuple` of `Index` instead of an `IndexSet` (PR #626). -- The ITensor type no longer has separate field `inds` and `store`, just a single field `tensor` (PR #626). -- The `IndexSet{T}` type has been redefined as a type alias for `Vector{T<:Index}` (which is subject to change to some other collection of indices, and likely will be removed in ITensors v0.3). Therefore it no longer has a type parameter for the number of indices, similar to the change to the `ITensor` type. If you were using the plain `IndexSet` type, code should generally still work properly. In general you should not have to use `IndexSet`, and can just use `Tuple` or `Vector` of `Index` instead, such as `is = (i, j, k)` or `is = [i, j, k]`. Priming, tagging, and set operations now work generically on those types (PR #626). -- ITensor constructors from Array now only convert to floating point for `Array{Int}` and `Array{Complex{Int}}`. That same conversion is added for QN ITensor constructors to be consistent with non-QN versions (PR #620) (@mtfishman). -- The tensor order type paramater has been removed from the `ITensor` type, so you can no longer write `ITensor{3}` to specify an order 3 ITensor (PR #591) (@kshyatt). - -Deprecations: ------------------ - -- `Index(::Int)` and `getindex(i::Index, n::Int)` are deprecated in favor of `Pair` syntax (using `i => 3` instead of `i(3)` or `i[3]`) (PR #665). -- `Base.iterate(i::Index, state = 1)` is deprecated in favor of `eachindval` (PR #665). -- Deprecate `MPO(::MPS)` in favor of `outer(::MPS, ::MPS)` (PR #663). -- Add `OpSum` as alternative (preferred) name to `AutoMPO` (PR #663). -- `noise!(::Sweeps, ...)` and `cutoff!(::Sweeps, ...)` are deprecated in favor of `setnoise!` and `setsweeps!` (PR #624). -- `emptyITensor(Any)` is deprecated in favor of `emptyITensor()` (PR #620). -- `store` is deprecated in favor of `storage` for getting the storage of an ITensor. Similarly `ITensors.setstore[!]` -> `ITensors.setstorage[!]` (PR #620). - -Bug fixes and new features: ------------------ - -- Fix bug when taking the exponential of a QN ITensor with missing diagonal blocks (PR #682). -- Generalize indexing to with `end` to allow arithmetic such as `A[i => end - 1, j => 2]` (PR #679). -- Allow Pair inputs in `swaptags` and `swapinds`, i.e. `swaptags(A, "i" => "j")` and `swapinds(A, i => j)` (PR #676). -- Fix negating of QN ITensor (PR #672) (@emstoudenmire). -- Add support for indexing into ITensors with strings, such as `s = siteind("S=1/2"); T = randomITensor(s); T[s => "Up"]` (indices must have tags that have `val` overloads) (PR #665). -- Add `eachindval(::Index)` and `eachval(::Index)` for iterating through the values of an Index (PR #665). -- Rename the `state` functions currently defined for various site types to `val` for mapping a string name for an index to an index value (used in ITensor indexing and MPS construction). `state` functions now return single-index ITensors representing various single-site states (PR #664). -- Out-of-place broadcasting on MPS that maps ITensors to ITensors like `2 .* psi` will return an MPS (previously it returned a `Vector{ITensor}`) (PR #663). -- Add `outer(psi::MPS, phi::MPS)::MPO -> |psi> |psi> isodd(n) ? "S+" : "S-") (PR #528). -* Add SiteType and op documentation. -* Add unexported function ITensors.examples_dir to get examples directory. - -ITensors v0.1.25 Release Notes -============================== -* Introduce imports.jl to organize import statements (PR #511). -* Add TRG and isotropic CTMRG examples (PR #511). -* Add example for 2D Hubbard model with momentum conservation around the cylinder (PR #511). -* Fix fermion string issue (PR #519) - -ITensors v0.1.24 Release Notes -============================== -* Generalize `tr(::MPO)` for MPOs with more an one pair of site indices per site (PR #509) -* Add `tr(::ITensor)` to trace pairs of indices of an ITensor (PR #509) -* Add stacktrace to warn tensor order (PR #498) - -ITensors v0.1.23 Release Notes -============================== -* Add lastindex(A::ITensor, n::Int) to define A[end, end]. (PR #495) -* Define hastags(A::ITensor, ts) and related functions. (PR #495) -* Fix some broadcasting. Add Hadamard product and division. (PR #495) -* Add tr(::MPO) (PR #492) -* Add docstrings and docs for apply(::Vector{ITensor}, ::MPS) (PR #492) -* Add docstrings for IndexSet set functions like commoninds, uniqueinds, etc. (PR #492) - -ITensors v0.1.22 Release Notes -============================== -* Add MPS/MPO circuit evolution with the apply function (PR #480) -* Improve MPS docs (PR #488) -* dense function for MPS/MPO (PR #483) -* MPO sampling (PR #486) -* Allow conserving Sz up or down in Fermion type (PR #482) -* Docstrings for siteinds method (PR #481) -* movesites function for MPS/MPO for permuting sites (PR #477) -* New Order value type for representing the order of a tensor at compile time (PR #475) -* Add generic "F" operator for non-fermion site types (PR #469) - -ITensors v0.1.21 Release Notes -============================== -* Add parity conservation to S=1/2 sitetype (PR #467) - * Add "ProjUp" and "ProjDn" operator definitions to S=1/2 site type. - * Change QN name "Pf" to "NfParity" - * Add keyword arguments to choose the QN names when making siteinds. -* Add ! as not syntax (PR #471) - * Add @ts_str macro for TagSet construction -* Add Sweeps constructor from matrix of parameters (PR #472) -* Add examples of input files (PR #473) - * Add native ITensors argument parsing with the argsdict() function. - * Add examples of using ITensors with input files and ArgParse.jl and argsdict(). - -ITensors v0.1.20 Release Notes -============================== -* Make ITensors compatible with Julia v1.3 (#468) -* New function filterinds, alias for inds (#466) -* Add QN ITensor from Array constructor (#464) - -ITensors v0.1.19 Release Notes -============================== - -* Add setindex!(::MPS, _, ::Colon) (PR #463) - * Set new limits to limits of input MPS -* Add macros for warn ITensor order (PR #461) - * Add macros for warn ITensor order - * Shorten warn ITensor order function name (breaking for anyone who - managed to use them in the short time they existed). -* Make map for MPS reset the orthogonality limits (PR #460) - * Makes map and map! reset the orthogonality limits by default. - * Add keyword argument set_limits to map and map! to let users turn -on and off setting the orthogonality limits (so it can be turned -off for cases like priming). - * Add orthogonalize, an out-of-place version of orthogonalize!. - * Add SiteType"S=\1/2" as an alias for SiteType"S=1/2". - -ITensors v0.1.18 Release Notes -============================== - -* Add functions for controlling warn itensor order (PR #458) -* Add pair syntax to mapprime, replacetags, and replaceinds (PR #459) - -ITensors v0.1.17 Release Notes -============================== - -* Miscellaneous new ITensor and MPS/MPO functionality (PR #457): - * Add `eachindex(T::ITensor)` to return an iterator over each cartesian -index of an ITensor (i.e. for an `d x d` ITensor, either `1:d^2` or -`(1,1), (1,2), ..., (d, d)`). For sparse ITensors, this includes -structurally zero and nonzero entries. - * Add `iterate(A::ITensor, args...)`, which allows using `for a in A -@show a end` to print all elements (zero and nonzero, for sparse -tensors). - * Add `setindex!(T::ITensor, x::Number, I::CartesianIndex)` to allow -indexing with a `CartesianIndex`, which is naturally returned by -functions like `eachindex`. - * Add `hasplev(pl::Int)` that returns a function `x -> hasplev(x, pl)` -(useful in functions like `map`). - * Add `hasind[s](i::Index)` that returns a function `x -> hasind[s](x, i)` -(useful in functions like `map`). - * Add `hascommoninds(A, B; kwargs...)` which returns true if `A` and `B` -have common indices. - * Add `findfirstsiteind(M::MPS/MPO, s::Index)` that returns which site -of the MPS/MPO has the site index `s`. - * Add `findfirstsiteinds(M::MPS/MPO, is)` that returns which site -of the MPS/MPO has the site indices `is`. - * Add `linkinds(::MPS/MPO)` that returns a vector of the link indices. - * Add `linkdim(::MPS/MPO, ::Int)` that returns the dimension of the -specified link, and nothing if there is no link found. - * Add `linkdims(::MPS/MPO)` that returns a vector of the link -dimensions. - * Fix a bug in `+(::MPST, ::MPST)` that the inputs were getting modified -(the inputs were getting orthogonalized and the prime levels were beging -modified). - * Add `productMPS(sites, state::Union{String, Int})` to create a uniform -MPS (for example, `productMPS(sites, "Up")` makes a state with all Up -spins). -* Add QR option for factorize (only Dense tensors so far). Used by default -if not truncation is requested (PR #427) - -ITensors v0.1.16 Release Notes -============================== - -* Update physics site definitions to user newer overload style (PR #453) -* Fix some issues with precompile_itensors.jl code and automatically test it (PR #452) - -ITensors v0.1.15 Release Notes -============================== - -* Add multi-site op support (PR #444) -* Update state system to be user-extensible using StateName (PR #449) -* Update siteinds system to be more easily extensible using `space` and `siteind` functions (PR #446) -* Remove parenthesis from AutoMPO syntax from tests and examples (PR #448) - -ITensors v0.1.14 Release Notes -============================== - -* Fix AutoMPO issue #440 (PR #445) -* Have ITensors.compile() compile QN DMRG (PR #442) -* Make linkind return nothing for all links outside the boundary of the MPS (PR #441) - -ITensors v0.1.13 Release Notes -============================== - -* New ITensors.compile() routine (PR #436, PR #439) -* Propagate keyword args through orthogonalize! (PR #438) -* Speed improvement to op (PR #435) -* Major improvements to op function system (PR #406) - -ITensors v0.1.12 Release Notes -============================== - -* HDF5 Support for QNITensors, QNIndex (PR #433) -* Add ProjMPO_MPS to exports - -ITensors v0.1.11 Release Notes -============================== - -* Add tests for contraction bug. Add tests for extended Spectrum definition (PR #432) -* Add ProjMPO_MPS to exports - -ITensors v0.1.10 Release Notes -============================== - -* Fix missing return statement in QNVal constructor (PR #431) - -ITensors v0.1.9 Release Notes -============================== - -* Fix bug with AutoMPO dimension in certain cases (PR #426) - -ITensors v0.1.8 Release Notes -============================== - -* Fix a bug in broadcast and in-place contraction (#425) - -ITensors v0.1.7 Release Notes -============================== - -* Add Unicode support for SmallStrings/Tags (PR #413) -* Speed up small ITensor contractions (PR #423) -* Add swapsites keyword argument to `replacebond` (PR #420) -* Change `flux(::AbstractMPS)` to return nothing in non-QN case (PR #419) - -ITensors v0.1.6 Release Notes -============================== - -* Allow user to control Arrow direction of combined Index in combiner (PR #417) -* Fix eigen for case when left/right indices had mixed Arrow directions (PR #417) -* Add exp for QN ITensor (PR #402) -* Add Advanced Usage Guide to docs (PR #387) - -ITensors v0.1.5 Release Notes -============================== - -* Fix bug with combiner (uncombining step) when combined Index is not the first one (PR #401) -* Add check to ProjMPO to ensure result of `product` is same order as input tensor (PR #390) - -ITensors v0.1.4 Release Notes -============================== - -* Add note to docs about requiring Julia 1.4 currently -* Improve error message for non-scalar input to `scalar` (PR #396) -* Export @TagType_str macro (PR #393) -* Fix `productMPS` for complex element type (PR #392) - -ITensors v0.1.3 Release Notes -============================== - -* Use NDTensors v0.1.3, which fixes a bug when taking the SVD of a complex QN ITensor. - -ITensors v0.1.2 Release Notes -============================== - -* Add functions `norm(::MPS)`, `norm(::MPO)`, `inner(::MPO, ::MPO)`, as well as `logdot`/`loginner` and `lognorm` for getting the logarithm of the inner product or norm between MPSs/MPOs. - diff --git a/docs/src/index.md b/docs/src/index.md index 6582cc5b61..85f230b300 100644 --- a/docs/src/index.md +++ b/docs/src/index.md @@ -29,6 +29,8 @@ Development of ITensor is supported by the Flatiron Institute, a division of the ## News +- April 16, 2024: ITensors.jl v0.4 has been released. This version removes HDF5 as a dependency (a breaking change) and moves the HDF5 read and write functions for ITensor, MPS, MPO, and other associated types into a package extension. To enable ITensor HDF5 features, install the HDF5 package and put `using HDF5` before `using ITensors` in your code. Other recent changes include support for multiple GPU backends using package extensions and support for the Observers.jl package (also through a package extension). + - March 25, 2022: ITensors.jl v0.3 has been released. The main breaking change is that we no longer support versions of Julia below 1.6. Julia 1.6 is the long term support version of Julia (LTS), which means that going forward versions below Julia 1.6 won't be as well supported with bug fixes and improvements. Additionally, Julia 1.6 introduced many improvements including syntax improvements that we would like to start using with ITensors.jl, which becomes challenging if we try to support Julia versions below 1.6. See [here](https://www.oxinabox.net/2021/02/13/Julia-1.6-what-has-changed-since-1.0.html) and [here](https://julialang.org/blog/2021/03/julia-1.6-highlights/) for some nice summaries of the Julia 1.6 release. - Jun 09, 2021: ITensors.jl v0.2 has been released, with a few breaking changes as well as a variety of bug fixes From 468b158f0cdcbcb251e3e11b4acf745789aff46f Mon Sep 17 00:00:00 2001 From: Miles Date: Tue, 16 Apr 2024 11:22:33 -0400 Subject: [PATCH 15/19] Fix Project.toml merge issues --- Project.toml | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) diff --git a/Project.toml b/Project.toml index 42a8213424..bf09abbce9 100644 --- a/Project.toml +++ b/Project.toml @@ -33,27 +33,13 @@ Zeros = "bd1ec220-6eb4-527a-9b49-e79c3db6233b" ZygoteRules = "700de1a5-db45-46bc-99cf-38207098b444" [weakdeps] -<<<<<<< HEAD -<<<<<<< HEAD -HDF5 = "f67ccb44-e63f-5c2f-98bd-6dc0ccc4ba2f" -VectorInterface = "409d34a3-91d5-4945-b6ec-7529ddf182d8" - -[extensions] -ITensorsHDF5Ext = "HDF5" -======= -======= -HDF5 = "f67ccb44-e63f-5c2f-98bd-6dc0ccc4ba2f" ->>>>>>> 1a866c163588d03a8321c85105437421b6a2daa4 Observers = "338f10d5-c7f1-4033-a7d1-f9dec39bcaa0" +HDF5 = "f67ccb44-e63f-5c2f-98bd-6dc0ccc4ba2f" VectorInterface = "409d34a3-91d5-4945-b6ec-7529ddf182d8" [extensions] ITensorsHDF5Ext = "HDF5" ITensorsObserversExt = "Observers" -<<<<<<< HEAD ->>>>>>> main -======= ->>>>>>> 1a866c163588d03a8321c85105437421b6a2daa4 ITensorsVectorInterfaceExt = "VectorInterface" [compat] From be4d2dde14df898b3df65eb1b2790fe3d122335b Mon Sep 17 00:00:00 2001 From: Miles Date: Tue, 16 Apr 2024 11:27:30 -0400 Subject: [PATCH 16/19] Improve news entry in docs. --- docs/src/index.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/src/index.md b/docs/src/index.md index 85f230b300..77ae8afc31 100644 --- a/docs/src/index.md +++ b/docs/src/index.md @@ -29,7 +29,7 @@ Development of ITensor is supported by the Flatiron Institute, a division of the ## News -- April 16, 2024: ITensors.jl v0.4 has been released. This version removes HDF5 as a dependency (a breaking change) and moves the HDF5 read and write functions for ITensor, MPS, MPO, and other associated types into a package extension. To enable ITensor HDF5 features, install the HDF5 package and put `using HDF5` before `using ITensors` in your code. Other recent changes include support for multiple GPU backends using package extensions and support for the Observers.jl package (also through a package extension). +- April 16, 2024: ITensors.jl v0.4 has been released. This version removes HDF5 as a dependency (a breaking change) and moves the HDF5 read and write functions for ITensor, MPS, MPO, and other associated types into a package extension. To enable ITensor HDF5 features, install the HDF5 package and put `using HDF5` together with `using ITensors` in your code. Other recent changes include support for multiple GPU backends using package extensions. - March 25, 2022: ITensors.jl v0.3 has been released. The main breaking change is that we no longer support versions of Julia below 1.6. Julia 1.6 is the long term support version of Julia (LTS), which means that going forward versions below Julia 1.6 won't be as well supported with bug fixes and improvements. Additionally, Julia 1.6 introduced many improvements including syntax improvements that we would like to start using with ITensors.jl, which becomes challenging if we try to support Julia versions below 1.6. See [here](https://www.oxinabox.net/2021/02/13/Julia-1.6-what-has-changed-since-1.0.html) and [here](https://julialang.org/blog/2021/03/julia-1.6-highlights/) for some nice summaries of the Julia 1.6 release. From 17ff8443adae759c0c53d77dac3ea44cd5ec5d5f Mon Sep 17 00:00:00 2001 From: Miles Date: Tue, 16 Apr 2024 14:18:18 -0400 Subject: [PATCH 17/19] Restore version 0.4.0 --- Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index bf09abbce9..e021ee01f5 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "ITensors" uuid = "9136182c-28ba-11e9-034c-db9fb085ebd5" authors = ["Matthew Fishman ", "Miles Stoudenmire "] -version = "0.4.1" +version = "0.4.0" [deps] Adapt = "79e6a3ab-5dfb-504d-930d-738a2a938a0e" From e1505a2f0b2a24589c8a0f4dbf42ab4005a4640e Mon Sep 17 00:00:00 2001 From: Miles Date: Tue, 16 Apr 2024 14:18:30 -0400 Subject: [PATCH 18/19] Remove unneeded imports --- src/ITensorMPS/abstractmps.jl | 19 ------------------- 1 file changed, 19 deletions(-) diff --git a/src/ITensorMPS/abstractmps.jl b/src/ITensorMPS/abstractmps.jl index ae4645fc79..c4b98a2716 100644 --- a/src/ITensorMPS/abstractmps.jl +++ b/src/ITensorMPS/abstractmps.jl @@ -1,24 +1,5 @@ using IsApprox: Approx, IsApprox using NDTensors: using_auto_fermion, scalartype, tensor -import ITensors: - dag, - #dag!, - prime, - prime!, - setprime, - setprime!, - noprime, - noprime!, - swapprime, - swapprime!, - replaceprime, - replaceprime!, - addtags, - addtags!, - removetags, - removetags!, - settags, - settags! abstract type AbstractMPS end From 048bf762cfef0076fd04d18103399411c4e35ab1 Mon Sep 17 00:00:00 2001 From: Miles Date: Tue, 16 Apr 2024 15:38:09 -0400 Subject: [PATCH 19/19] Update Project.toml Co-authored-by: Matt Fishman --- Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index e021ee01f5..d099639674 100644 --- a/Project.toml +++ b/Project.toml @@ -33,8 +33,8 @@ Zeros = "bd1ec220-6eb4-527a-9b49-e79c3db6233b" ZygoteRules = "700de1a5-db45-46bc-99cf-38207098b444" [weakdeps] -Observers = "338f10d5-c7f1-4033-a7d1-f9dec39bcaa0" HDF5 = "f67ccb44-e63f-5c2f-98bd-6dc0ccc4ba2f" +Observers = "338f10d5-c7f1-4033-a7d1-f9dec39bcaa0" VectorInterface = "409d34a3-91d5-4945-b6ec-7529ddf182d8" [extensions]