diff --git a/Project.toml b/Project.toml index 0373628..1f93bed 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.7" +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..dd3682b 100644 --- a/examples/01_parallel_mpo_sum_2d_hubbard_conserve_momentum.jl +++ b/examples/01_parallel_mpo_sum_2d_hubbard_conserve_momentum.jl @@ -4,15 +4,19 @@ rmprocs(setdiff(procs(), 1)) addprocs(2) @show nprocs() -@everywhere using ITensors +@everywhere using ITensorMPS @everywhere using ITensorParallel -using Random +@everywhere using ITensors +using LinearAlgebra: BLAS +using Random: Random +using Strided: Strided -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() +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 9fa3300..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,14 +1,18 @@ -using MPI +using MPI: MPI MPI.Init() -using ITensors +using ITensorMPS using ITensorParallel -using Random +using ITensors +using LinearAlgebra: BLAS +using Random: Random +using Strided: Strided -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() +BLAS.set_num_threads(1) +Strided.disable_threads() """ Run at the command line with 4 processes: @@ -84,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/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/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/src/ITensorParallel.jl b/src/ITensorParallel.jl index bad9968..2f6d0a9 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 ITensors: product, replaceind! +import ITensorMPS: disk, linkind, lproj, @@ -21,7 +22,6 @@ import ITensors.ITensorMPS: nsite, orthogonalize!, position!, - replaceind!, replacebond!, rproj, set_terms, diff --git a/test/Project.toml b/test/Project.toml index f645986..def603b 100644 --- a/test/Project.toml +++ b/test/Project.toml @@ -2,8 +2,11 @@ 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" +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")