From 5344b3c21a04eb728c2175ffdfce89544700f855 Mon Sep 17 00:00:00 2001 From: mtfishman Date: Mon, 25 Mar 2024 21:20:00 -0400 Subject: [PATCH 1/8] Update for ITensors.jl ITensorMPS submodule --- src/ITensorParallel.jl | 13 +++++++------ test/Project.toml | 1 + 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/ITensorParallel.jl b/src/ITensorParallel.jl index 574bdd3..bad9968 100644 --- a/src/ITensorParallel.jl +++ b/src/ITensorParallel.jl @@ -8,10 +8,12 @@ using MPI using ITensors using ITensors.NDTensors -using ITensors: AbstractSum, Algorithm, @Algorithm_str +using ITensors: Algorithm, @Algorithm_str +using ITensors.ITensorMPS: AbstractSum import Base: eltype, length, size -import ITensors: +import ITensors: product +import ITensors.ITensorMPS: disk, linkind, lproj, @@ -19,15 +21,14 @@ import ITensors: nsite, orthogonalize!, position!, - product, replaceind!, replacebond!, rproj, set_terms, terms -include(joinpath("partition", "partition.jl")) -include(joinpath("partition", "partition_sum_split.jl")) -include(joinpath("partition", "partition_chain_split.jl")) +include("partition/partition.jl") +include("partition/partition_sum_split.jl") +include("partition/partition_chain_split.jl") include("force_gc.jl") include("foldssum.jl") include("distributedsum.jl") diff --git a/test/Project.toml b/test/Project.toml index 4c67d29..f645986 100644 --- a/test/Project.toml +++ b/test/Project.toml @@ -2,6 +2,7 @@ ArgParse = "c7e460c6-2fb9-53a9-8c5b-16f535851c63" Compat = "34da2185-b29b-5c13-b0c7-acf172513d20" Distributed = "8ba89e20-285c-5b6f-9357-94700520ee1b" +ITensorParallel = "0fccfcd2-f061-4985-9740-339d3f86bfce" ITensors = "9136182c-28ba-11e9-034c-db9fb085ebd5" MPI = "da04e1cc-30fd-572f-bb4f-1f8673147195" Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c" From ecf76b88d57393472ad18d1a904e3a18ada3e589 Mon Sep 17 00:00:00 2001 From: mtfishman Date: Fri, 10 May 2024 15:27:00 -0400 Subject: [PATCH 2/8] Start using ITensorMPS.jl --- Project.toml | 4 +++- .../01_parallel_mpo_sum_2d_hubbard_conserve_momentum.jl | 3 ++- examples/02_mpi_mpo_sum_2d_hubbard_conserve_momentum.jl | 3 ++- examples/03_partition_2d_heisenberg.jl | 3 ++- src/ITensorParallel.jl | 7 ++++--- test/Project.toml | 1 + 6 files changed, 14 insertions(+), 7 deletions(-) diff --git a/Project.toml b/Project.toml index 0373628..de26d93 100644 --- a/Project.toml +++ b/Project.toml @@ -8,6 +8,7 @@ Accessors = "7d9f7c33-5ae7-4f3b-8dc6-eff91059b697" Compat = "34da2185-b29b-5c13-b0c7-acf172513d20" Distributed = "8ba89e20-285c-5b6f-9357-94700520ee1b" Folds = "41a02a25-b8f0-4f67-bc48-60067656b558" +ITensorMPS = "0d1a4710-d33b-49a5-8f18-73bdf49b47e2" ITensors = "9136182c-28ba-11e9-034c-db9fb085ebd5" MPI = "da04e1cc-30fd-572f-bb4f-1f8673147195" @@ -15,7 +16,8 @@ MPI = "da04e1cc-30fd-572f-bb4f-1f8673147195" Accessors = "0.1.26" Compat = "4.8" Folds = "0.2.8" -ITensors = "0.3.58" +ITensorMPS = "0.1" +ITensors = "0.3.58, 0.4, 0.5, 0.6" MPI = "0.20" julia = "1.6" diff --git a/examples/01_parallel_mpo_sum_2d_hubbard_conserve_momentum.jl b/examples/01_parallel_mpo_sum_2d_hubbard_conserve_momentum.jl index 6098f68..ddefc8e 100644 --- a/examples/01_parallel_mpo_sum_2d_hubbard_conserve_momentum.jl +++ b/examples/01_parallel_mpo_sum_2d_hubbard_conserve_momentum.jl @@ -4,8 +4,9 @@ rmprocs(setdiff(procs(), 1)) addprocs(2) @show nprocs() -@everywhere using ITensors +@everywhere using ITensorMPS @everywhere using ITensorParallel +@everywhere using ITensors using Random include(joinpath(pkgdir(ITensors), "examples", "src", "electronk.jl")) diff --git a/examples/02_mpi_mpo_sum_2d_hubbard_conserve_momentum.jl b/examples/02_mpi_mpo_sum_2d_hubbard_conserve_momentum.jl index 9fa3300..6468d18 100644 --- a/examples/02_mpi_mpo_sum_2d_hubbard_conserve_momentum.jl +++ b/examples/02_mpi_mpo_sum_2d_hubbard_conserve_momentum.jl @@ -1,7 +1,8 @@ using MPI MPI.Init() -using ITensors +using ITensorMPS using ITensorParallel +using ITensors using Random include(joinpath(pkgdir(ITensors), "examples", "src", "electronk.jl")) diff --git a/examples/03_partition_2d_heisenberg.jl b/examples/03_partition_2d_heisenberg.jl index df3f719..0c778d7 100644 --- a/examples/03_partition_2d_heisenberg.jl +++ b/examples/03_partition_2d_heisenberg.jl @@ -1,5 +1,6 @@ -using ITensors +using ITensorMPS using ITensorParallel +using ITensors function heisenberg_2d(nx, ny) lattice = square_lattice(nx, ny; yperiodic=false) diff --git a/src/ITensorParallel.jl b/src/ITensorParallel.jl index bad9968..ea008a0 100644 --- a/src/ITensorParallel.jl +++ b/src/ITensorParallel.jl @@ -4,16 +4,17 @@ using Accessors using Compat using Distributed using Folds -using MPI +using ITensorMPS using ITensors using ITensors.NDTensors +using MPI using ITensors: Algorithm, @Algorithm_str -using ITensors.ITensorMPS: AbstractSum +using ITensorMPS: AbstractSum import Base: eltype, length, size import ITensors: product -import ITensors.ITensorMPS: +import ITensorMPS: disk, linkind, lproj, diff --git a/test/Project.toml b/test/Project.toml index f645986..c9f946c 100644 --- a/test/Project.toml +++ b/test/Project.toml @@ -2,6 +2,7 @@ ArgParse = "c7e460c6-2fb9-53a9-8c5b-16f535851c63" Compat = "34da2185-b29b-5c13-b0c7-acf172513d20" Distributed = "8ba89e20-285c-5b6f-9357-94700520ee1b" +ITensorMPS = "0d1a4710-d33b-49a5-8f18-73bdf49b47e2" ITensorParallel = "0fccfcd2-f061-4985-9740-339d3f86bfce" ITensors = "9136182c-28ba-11e9-034c-db9fb085ebd5" MPI = "da04e1cc-30fd-572f-bb4f-1f8673147195" From 45585953f87f9aed6ac9b900172d4af6fab1fb40 Mon Sep 17 00:00:00 2001 From: Matt Fishman Date: Fri, 10 May 2024 15:42:53 -0400 Subject: [PATCH 3/8] Require ITensorMPS v0.1.4 --- Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index de26d93..f532b3c 100644 --- a/Project.toml +++ b/Project.toml @@ -16,7 +16,7 @@ MPI = "da04e1cc-30fd-572f-bb4f-1f8673147195" Accessors = "0.1.26" Compat = "4.8" Folds = "0.2.8" -ITensorMPS = "0.1" +ITensorMPS = "0.1.4" ITensors = "0.3.58, 0.4, 0.5, 0.6" MPI = "0.20" julia = "1.6" From e786365bbec14649eadc5ea10cdae47a7221bcf1 Mon Sep 17 00:00:00 2001 From: mtfishman Date: Fri, 10 May 2024 20:04:04 -0400 Subject: [PATCH 4/8] Fix example --- examples/02_mpi_mpo_sum_2d_hubbard_conserve_momentum.jl | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/examples/02_mpi_mpo_sum_2d_hubbard_conserve_momentum.jl b/examples/02_mpi_mpo_sum_2d_hubbard_conserve_momentum.jl index 6468d18..3f44549 100644 --- a/examples/02_mpi_mpo_sum_2d_hubbard_conserve_momentum.jl +++ b/examples/02_mpi_mpo_sum_2d_hubbard_conserve_momentum.jl @@ -5,8 +5,9 @@ using ITensorParallel using ITensors using Random -include(joinpath(pkgdir(ITensors), "examples", "src", "electronk.jl")) -include(joinpath(pkgdir(ITensors), "examples", "src", "hubbard.jl")) +electronk_path = joinpath(pkgdir(ITensors), "src", "lib", "ITensorMPS", "examples", "src") +include(joinpath(electronk_path, "electronk.jl")) +include(joinpath(electronk_path, "hubbard.jl")) ITensors.BLAS.set_num_threads(1) ITensors.Strided.disable_threads() From 8d4f1bed9933ff5e3521edeae4a0d12f0d774e6f Mon Sep 17 00:00:00 2001 From: mtfishman Date: Fri, 10 May 2024 20:43:57 -0400 Subject: [PATCH 5/8] Fix example --- examples/01_parallel_mpo_sum_2d_hubbard_conserve_momentum.jl | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/examples/01_parallel_mpo_sum_2d_hubbard_conserve_momentum.jl b/examples/01_parallel_mpo_sum_2d_hubbard_conserve_momentum.jl index ddefc8e..85d40ca 100644 --- a/examples/01_parallel_mpo_sum_2d_hubbard_conserve_momentum.jl +++ b/examples/01_parallel_mpo_sum_2d_hubbard_conserve_momentum.jl @@ -9,8 +9,9 @@ addprocs(2) @everywhere using ITensors using Random -include(joinpath(pkgdir(ITensors), "examples", "src", "electronk.jl")) -include(joinpath(pkgdir(ITensors), "examples", "src", "hubbard.jl")) +electronk_path = joinpath(pkgdir(ITensors), "src", "lib", "ITensorMPS", "examples", "src") +include(joinpath(electronk_path, "electronk.jl")) +include(joinpath(electronk_path, "hubbard.jl")) ITensors.BLAS.set_num_threads(1) ITensors.Strided.disable_threads() From 9825cdd5ea3533b2c92bf2240e0391353d5035b3 Mon Sep 17 00:00:00 2001 From: mtfishman Date: Fri, 10 May 2024 21:27:15 -0400 Subject: [PATCH 6/8] Fix imports --- src/ITensorParallel.jl | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/ITensorParallel.jl b/src/ITensorParallel.jl index ea008a0..2f6d0a9 100644 --- a/src/ITensorParallel.jl +++ b/src/ITensorParallel.jl @@ -13,7 +13,7 @@ using ITensors: Algorithm, @Algorithm_str using ITensorMPS: AbstractSum import Base: eltype, length, size -import ITensors: product +import ITensors: product, replaceind! import ITensorMPS: disk, linkind, @@ -22,7 +22,6 @@ import ITensorMPS: nsite, orthogonalize!, position!, - replaceind!, replacebond!, rproj, set_terms, From d7f721ec086826fb4a2890943c8b865ca06ee894 Mon Sep 17 00:00:00 2001 From: mtfishman Date: Sat, 11 May 2024 15:47:39 -0400 Subject: [PATCH 7/8] Namespace improvements --- ..._parallel_mpo_sum_2d_hubbard_conserve_momentum.jl | 8 +++++--- .../02_mpi_mpo_sum_2d_hubbard_conserve_momentum.jl | 12 +++++++----- examples/Project.toml | 8 ++++++++ test/Project.toml | 2 ++ test/test_mpi_example.jl | 12 +++++------- test/test_sequential_threaded_distributed_example.jl | 2 +- 6 files changed, 28 insertions(+), 16 deletions(-) create mode 100644 examples/Project.toml diff --git a/examples/01_parallel_mpo_sum_2d_hubbard_conserve_momentum.jl b/examples/01_parallel_mpo_sum_2d_hubbard_conserve_momentum.jl index 85d40ca..dd3682b 100644 --- a/examples/01_parallel_mpo_sum_2d_hubbard_conserve_momentum.jl +++ b/examples/01_parallel_mpo_sum_2d_hubbard_conserve_momentum.jl @@ -7,14 +7,16 @@ addprocs(2) @everywhere using ITensorMPS @everywhere using ITensorParallel @everywhere using ITensors -using Random +using LinearAlgebra: BLAS +using Random: Random +using Strided: Strided electronk_path = joinpath(pkgdir(ITensors), "src", "lib", "ITensorMPS", "examples", "src") include(joinpath(electronk_path, "electronk.jl")) include(joinpath(electronk_path, "hubbard.jl")) -ITensors.BLAS.set_num_threads(1) -ITensors.Strided.disable_threads() +BLAS.set_num_threads(1) +Strided.disable_threads() """ Run with: diff --git a/examples/02_mpi_mpo_sum_2d_hubbard_conserve_momentum.jl b/examples/02_mpi_mpo_sum_2d_hubbard_conserve_momentum.jl index 3f44549..26196db 100644 --- a/examples/02_mpi_mpo_sum_2d_hubbard_conserve_momentum.jl +++ b/examples/02_mpi_mpo_sum_2d_hubbard_conserve_momentum.jl @@ -1,16 +1,18 @@ -using MPI +using MPI: MPI MPI.Init() using ITensorMPS using ITensorParallel using ITensors -using Random +using LinearAlgebra: BLAS +using Random: Random +using Strided: Strided electronk_path = joinpath(pkgdir(ITensors), "src", "lib", "ITensorMPS", "examples", "src") include(joinpath(electronk_path, "electronk.jl")) include(joinpath(electronk_path, "hubbard.jl")) -ITensors.BLAS.set_num_threads(1) -ITensors.Strided.disable_threads() +BLAS.set_num_threads(1) +Strided.disable_threads() """ Run at the command line with 4 processes: @@ -86,7 +88,7 @@ function main(; if disk # Write-to-disk - mpo_sum_term = ITensors.disk(mpo_sum_term) + mpo_sum_term = ITensorMPS.disk(mpo_sum_term) end energy, psi = @time dmrg(mpo_sum_term, psi0; nsweeps, maxdim, cutoff, noise) diff --git a/examples/Project.toml b/examples/Project.toml new file mode 100644 index 0000000..dd55b29 --- /dev/null +++ b/examples/Project.toml @@ -0,0 +1,8 @@ +[deps] +Distributed = "8ba89e20-285c-5b6f-9357-94700520ee1b" +ITensorMPS = "0d1a4710-d33b-49a5-8f18-73bdf49b47e2" +ITensorParallel = "0fccfcd2-f061-4985-9740-339d3f86bfce" +ITensors = "9136182c-28ba-11e9-034c-db9fb085ebd5" +LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" +Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c" +Strided = "5e0ebb24-38b0-5f93-81fe-25c709ecae67" diff --git a/test/Project.toml b/test/Project.toml index c9f946c..def603b 100644 --- a/test/Project.toml +++ b/test/Project.toml @@ -5,6 +5,8 @@ Distributed = "8ba89e20-285c-5b6f-9357-94700520ee1b" ITensorMPS = "0d1a4710-d33b-49a5-8f18-73bdf49b47e2" ITensorParallel = "0fccfcd2-f061-4985-9740-339d3f86bfce" ITensors = "9136182c-28ba-11e9-034c-db9fb085ebd5" +LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" MPI = "da04e1cc-30fd-572f-bb4f-1f8673147195" Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c" +Strided = "5e0ebb24-38b0-5f93-81fe-25c709ecae67" Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" diff --git a/test/test_mpi_example.jl b/test/test_mpi_example.jl index 6f74747..5c10277 100644 --- a/test/test_mpi_example.jl +++ b/test/test_mpi_example.jl @@ -1,6 +1,6 @@ -using MPI +using MPI: MPI, mpiexec using ITensorParallel -using Test +using Test: @testset @testset "Test $(@__FILE__)" begin examples_dir = joinpath(pkgdir(ITensorParallel), "examples") @@ -18,10 +18,8 @@ using Test Ny = 4 nsweeps = 2 maxdim = 20 - mpiexec() do exe # MPI wrapper - run( - `$exe -n $(nprocs) $(Base.julia_cmd()) --threads $(Threads.nthreads()) $(joinpath(examples_dir, example_file)) --Nx $(Nx) --Ny $(Ny) --nsweeps $(nsweeps) --maxdim $(maxdim) --disk $(disk) --threaded_blocksparse $(threaded_blocksparse)`, - ) - end + run( + `$(mpiexec()) -n $(nprocs) $(Base.julia_cmd()) --threads $(Threads.nthreads()) $(joinpath(examples_dir, example_file)) --Nx $(Nx) --Ny $(Ny) --nsweeps $(nsweeps) --maxdim $(maxdim) --disk $(disk) --threaded_blocksparse $(threaded_blocksparse)`, + ) end end diff --git a/test/test_sequential_threaded_distributed_example.jl b/test/test_sequential_threaded_distributed_example.jl index e6d556f..d660878 100644 --- a/test/test_sequential_threaded_distributed_example.jl +++ b/test/test_sequential_threaded_distributed_example.jl @@ -1,5 +1,5 @@ using ITensorParallel -using Test +using Test: @testset @testset "Test $(@__FILE__)" begin examples_dir = joinpath(pkgdir(ITensorParallel), "examples") From 3f4cf8536a9e7da199f3b3d5f1dbed04dffacf97 Mon Sep 17 00:00:00 2001 From: Matt Fishman Date: Sat, 11 May 2024 15:49:05 -0400 Subject: [PATCH 8/8] Bump to ITensorMPS v0.1.7 --- Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index f532b3c..1f93bed 100644 --- a/Project.toml +++ b/Project.toml @@ -16,7 +16,7 @@ MPI = "da04e1cc-30fd-572f-bb4f-1f8673147195" Accessors = "0.1.26" Compat = "4.8" Folds = "0.2.8" -ITensorMPS = "0.1.4" +ITensorMPS = "0.1.7" ITensors = "0.3.58, 0.4, 0.5, 0.6" MPI = "0.20" julia = "1.6"