From ea88fc6aca3dcaee774b1a988d6fa3d137b2e939 Mon Sep 17 00:00:00 2001 From: Miles Date: Mon, 25 Mar 2024 10:45:50 +0900 Subject: [PATCH 1/6] Fix ITensorMPS Ops test --- test/ITensorMPS/Ops/test_ops_mpo.jl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/ITensorMPS/Ops/test_ops_mpo.jl b/test/ITensorMPS/Ops/test_ops_mpo.jl index 0799e04fad..729abdee69 100644 --- a/test/ITensorMPS/Ops/test_ops_mpo.jl +++ b/test/ITensorMPS/Ops/test_ops_mpo.jl @@ -1,6 +1,7 @@ using Test using ITensors using ITensors.Ops +using ITensors: ITensorMPS using LinearAlgebra @testset "Ops to MPO" begin @@ -42,7 +43,7 @@ using LinearAlgebra ℋ_merged = OpSum() ℋ_merged += (4, "Z", 1) ℋ_merged += (3, "X", 2) - @test ITensors.sortmergeterms(ℋ) == ℋ_merged + @test ITensorMPS.sortmergeterms(ℋ) == ℋ_merged # Test with repeated terms s = siteinds("S=1/2", 1) From 7c648e37f9cc73005e5765fa0accba7cdf7278f4 Mon Sep 17 00:00:00 2001 From: Miles Date: Mon, 25 Mar 2024 10:48:54 +0900 Subject: [PATCH 2/6] Fix ITensorMPS related issue in ITensorGaussianMPS --- ITensorGaussianMPS/src/gmps.jl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ITensorGaussianMPS/src/gmps.jl b/ITensorGaussianMPS/src/gmps.jl index 7d39f01ecc..4c6fe7e89a 100644 --- a/ITensorGaussianMPS/src/gmps.jl +++ b/ITensorGaussianMPS/src/gmps.jl @@ -1,5 +1,5 @@ import Base: sortperm, size, length, eltype, conj, transpose, copy, * -using ITensors: alias +using ITensors: alias, ITensorMPS abstract type AbstractSymmetry end struct ConservesNfParity{T} <: AbstractSymmetry data::T @@ -177,8 +177,8 @@ end function quadratic_operator(os::OpSum) os = deepcopy(os) - #os = ITensors.sorteachterm(os, sites) - os = ITensors.sortmergeterms(os) + #os = ITensorMPS.sorteachterm(os, sites) + os = ITensorMPS.sortmergeterms(os) nterms = length(os) coefs = Vector{Number}(undef, nterms) From d4b48264dafa7d1e4f577dd1a7e7972c8c39212f Mon Sep 17 00:00:00 2001 From: Miles Date: Mon, 25 Mar 2024 12:22:41 +0900 Subject: [PATCH 3/6] Attempted fix of ITensorGPU dmrg error --- src/ITensorMPS/dmrg.jl | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/ITensorMPS/dmrg.jl b/src/ITensorMPS/dmrg.jl index 8bd94f6511..0739ed0ede 100644 --- a/src/ITensorMPS/dmrg.jl +++ b/src/ITensorMPS/dmrg.jl @@ -249,12 +249,11 @@ function dmrg( ## into `DeviceMemory`. This conversion line is here temporarily to fix that problem when it arises ## Adapt is only called when using CUDA backend. CPU will work as implemented previously. ## TODO this might be the only place we really need iscu if its not fixed. - phi::ITensor = if NDTensors.iscu(phi) && NDTensors.iscu(vecs[1]) - adapt(set_eltype(unwrap_array_type(phi), eltype(vecs[1])), vecs[1]) + if NDTensors.iscu(phi) && NDTensors.iscu(vecs[1]) + phi = adapt(ITensors.set_eltype(unwrap_array_type(phi), eltype(vecs[1])), vecs[1]) else - vecs[1] + phi = vecs[1] end - #phi::ITensor = vecs[1] ortho = ha == 1 ? "left" : "right" From de5f1185edd388b6d34116c9fb5325ea3a85fb29 Mon Sep 17 00:00:00 2001 From: Miles Date: Mon, 25 Mar 2024 15:55:08 +0900 Subject: [PATCH 4/6] Replace allequal in projmposum.jl for compabilitity with earlier Julia versions --- src/ITensorMPS/abstractprojmpo/projmposum.jl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/ITensorMPS/abstractprojmpo/projmposum.jl b/src/ITensorMPS/abstractprojmpo/projmposum.jl index c47ffc368f..c8b76add41 100644 --- a/src/ITensorMPS/abstractprojmpo/projmposum.jl +++ b/src/ITensorMPS/abstractprojmpo/projmposum.jl @@ -10,7 +10,7 @@ end copy(P::AbstractSum) = typeof(P)(copy.(terms(P))) function nsite(P::AbstractSum) - @assert allequal(nsite.(terms(P))) + @assert all(y -> y == nsite(first(terms(P))), nsite.(terms(P))) return nsite(first(terms(P))) end @@ -19,12 +19,12 @@ function set_nsite!(A::AbstractSum, nsite) end function length(A::AbstractSum) - @assert allequal(length.(terms(A))) + @assert all(y -> y == length(first(terms(A))), length.(terms(A))) return length(first(terms(A))) end function site_range(A::AbstractSum) - @assert allequal(Iterators.map(site_range, terms(A))) + @assert all(y -> y == site_range(first(terms(A))), Iterators.map(site_range, terms(A))) return site_range(first(terms(A))) end From 9bac2e6efe9d37a0eae3ad122ca8718ca21b9665 Mon Sep 17 00:00:00 2001 From: Miles Date: Mon, 25 Mar 2024 22:46:11 +0900 Subject: [PATCH 5/6] Implement suggested changes --- ITensorGaussianMPS/src/gmps.jl | 3 ++- src/ITensorMPS/abstractprojmpo/projmposum.jl | 7 ++++--- src/ITensorMPS/dmrg.jl | 6 +++--- test/ITensorMPS/Ops/test_ops_mpo.jl | 2 +- 4 files changed, 10 insertions(+), 8 deletions(-) diff --git a/ITensorGaussianMPS/src/gmps.jl b/ITensorGaussianMPS/src/gmps.jl index 4c6fe7e89a..6d2e3a8e96 100644 --- a/ITensorGaussianMPS/src/gmps.jl +++ b/ITensorGaussianMPS/src/gmps.jl @@ -1,5 +1,6 @@ import Base: sortperm, size, length, eltype, conj, transpose, copy, * -using ITensors: alias, ITensorMPS +using ITensors: alias +using ITensors.ITensorMPS: ITensorMPS abstract type AbstractSymmetry end struct ConservesNfParity{T} <: AbstractSymmetry data::T diff --git a/src/ITensorMPS/abstractprojmpo/projmposum.jl b/src/ITensorMPS/abstractprojmpo/projmposum.jl index c8b76add41..3d5d5d95d7 100644 --- a/src/ITensorMPS/abstractprojmpo/projmposum.jl +++ b/src/ITensorMPS/abstractprojmpo/projmposum.jl @@ -1,3 +1,4 @@ +using Compat: allequal abstract type AbstractSum end @@ -10,7 +11,7 @@ end copy(P::AbstractSum) = typeof(P)(copy.(terms(P))) function nsite(P::AbstractSum) - @assert all(y -> y == nsite(first(terms(P))), nsite.(terms(P))) + @assert allequal(nsite.(terms(P))) return nsite(first(terms(P))) end @@ -19,12 +20,12 @@ function set_nsite!(A::AbstractSum, nsite) end function length(A::AbstractSum) - @assert all(y -> y == length(first(terms(A))), length.(terms(A))) + @assert allequal(length.(terms(A))) return length(first(terms(A))) end function site_range(A::AbstractSum) - @assert all(y -> y == site_range(first(terms(A))), Iterators.map(site_range, terms(A))) + @assert allequal(Iterators.map(site_range, terms(A))) return site_range(first(terms(A))) end diff --git a/src/ITensorMPS/dmrg.jl b/src/ITensorMPS/dmrg.jl index 0739ed0ede..37885fcbb4 100644 --- a/src/ITensorMPS/dmrg.jl +++ b/src/ITensorMPS/dmrg.jl @@ -249,10 +249,10 @@ function dmrg( ## into `DeviceMemory`. This conversion line is here temporarily to fix that problem when it arises ## Adapt is only called when using CUDA backend. CPU will work as implemented previously. ## TODO this might be the only place we really need iscu if its not fixed. - if NDTensors.iscu(phi) && NDTensors.iscu(vecs[1]) - phi = adapt(ITensors.set_eltype(unwrap_array_type(phi), eltype(vecs[1])), vecs[1]) + phi = if NDTensors.iscu(phi) && NDTensors.iscu(vecs[1]) + adapt(ITensors.set_eltype(unwrap_array_type(phi), eltype(vecs[1])), vecs[1]) else - phi = vecs[1] + vecs[1] end ortho = ha == 1 ? "left" : "right" diff --git a/test/ITensorMPS/Ops/test_ops_mpo.jl b/test/ITensorMPS/Ops/test_ops_mpo.jl index 729abdee69..f7b42b30a4 100644 --- a/test/ITensorMPS/Ops/test_ops_mpo.jl +++ b/test/ITensorMPS/Ops/test_ops_mpo.jl @@ -1,7 +1,7 @@ using Test using ITensors using ITensors.Ops -using ITensors: ITensorMPS +using ITensors.ITensorMPS: ITensorMPS using LinearAlgebra @testset "Ops to MPO" begin From fb95bc5613c9dc8d6d4b1a6e1b20f80c6c8e479e Mon Sep 17 00:00:00 2001 From: Miles Date: Mon, 25 Mar 2024 22:51:17 +0900 Subject: [PATCH 6/6] Update comment trigger name --- .github/workflows/comment_trigger_test_itensors_mps.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/comment_trigger_test_itensors_mps.yml b/.github/workflows/comment_trigger_test_itensors_mps.yml index 3c29c51764..00a5f0fec2 100644 --- a/.github/workflows/comment_trigger_test_itensors_mps.yml +++ b/.github/workflows/comment_trigger_test_itensors_mps.yml @@ -9,7 +9,7 @@ on: jobs: test: name: Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }} - ${{ matrix.threads }} thread(s) - if: github.event.issue.pull_request && contains(github.event.comment.body, '[test ITensors mps]') + if: github.event.issue.pull_request && contains(github.event.comment.body, '[test ITensorMPS]') runs-on: ${{ matrix.os }} env: JULIA_NUM_THREADS: ${{ matrix.threads }}