From eba5e17423d31bba12db576324a2260253357a27 Mon Sep 17 00:00:00 2001 From: Karl Pierce Date: Sat, 12 Oct 2024 19:54:12 -0400 Subject: [PATCH] [NDTensors] [ITensors] Require Julia 1.10 and above (#1539) * Require Julia 1.10 and above * Fixes for Julia 1.11, update CI to use Julia version 1.10 and 1.11 --- .../main_test_itensors_base_macos_windows.yml | 2 +- .github/workflows/test_itensormps_ubuntu.yml | 2 +- .../workflows/test_itensors_base_ubuntu.yml | 2 +- .github/workflows/test_ndtensors.yml | 2 +- NDTensors/Project.toml | 4 +- .../lib/BlockSparseArrays/test/test_basics.jl | 51 ++++++++---- .../LabelledNumbers/src/labelledunitrange.jl | 11 +++ NDTensors/test/Project.toml | 4 +- Project.toml | 4 +- jenkins/Dockerfile | 2 +- jenkins/Jenkinsfile | 78 ++++++++++++++++++- src/lib/ITensorMPS/test/Project.toml | 1 + src/lib/ITensorMPS/test/base/Project.toml | 1 + src/lib/ITensorMPS/test/base/test_mpo.jl | 9 ++- test/Project.toml | 1 + 15 files changed, 138 insertions(+), 36 deletions(-) diff --git a/.github/workflows/main_test_itensors_base_macos_windows.yml b/.github/workflows/main_test_itensors_base_macos_windows.yml index a92e581dd6..f9f39d16fd 100644 --- a/.github/workflows/main_test_itensors_base_macos_windows.yml +++ b/.github/workflows/main_test_itensors_base_macos_windows.yml @@ -14,7 +14,7 @@ jobs: strategy: matrix: version: - - '1.6' + - 'lts' - '1' os: # - windows-latest # windows tests are failing for an unknow reason, disable for now diff --git a/.github/workflows/test_itensormps_ubuntu.yml b/.github/workflows/test_itensormps_ubuntu.yml index fb81c37280..cf80a2a8b3 100644 --- a/.github/workflows/test_itensormps_ubuntu.yml +++ b/.github/workflows/test_itensormps_ubuntu.yml @@ -16,7 +16,7 @@ jobs: strategy: matrix: version: - - '1.6' + - 'lts' - '1' os: - ubuntu-latest diff --git a/.github/workflows/test_itensors_base_ubuntu.yml b/.github/workflows/test_itensors_base_ubuntu.yml index d185c5de56..7004dae0f7 100644 --- a/.github/workflows/test_itensors_base_ubuntu.yml +++ b/.github/workflows/test_itensors_base_ubuntu.yml @@ -16,7 +16,7 @@ jobs: strategy: matrix: version: - - '1.6' + - 'lts' - '1' os: - ubuntu-latest diff --git a/.github/workflows/test_ndtensors.yml b/.github/workflows/test_ndtensors.yml index 67a46f39b0..1f3f4c8be1 100644 --- a/.github/workflows/test_ndtensors.yml +++ b/.github/workflows/test_ndtensors.yml @@ -16,7 +16,7 @@ jobs: strategy: matrix: version: - - '1.6' + - 'lts' - '1' os: - ubuntu-latest diff --git a/NDTensors/Project.toml b/NDTensors/Project.toml index 5fa45ba4d6..513114881e 100644 --- a/NDTensors/Project.toml +++ b/NDTensors/Project.toml @@ -1,7 +1,7 @@ name = "NDTensors" uuid = "23ae76d9-e61a-49c4-8f12-3f1a16adf9cf" authors = ["Matthew Fishman "] -version = "0.3.44" +version = "0.3.45" [deps] Accessors = "7d9f7c33-5ae7-4f3b-8dc6-eff91059b697" @@ -91,7 +91,7 @@ TimerOutputs = "0.5.5" TupleTools = "1.2.0" VectorInterface = "0.4.2" cuTENSOR = "2" -julia = "1.6" +julia = "1.10" [extras] AMDGPU = "21141c5a-9bdb-4563-92ae-f87d6854732e" diff --git a/NDTensors/src/lib/BlockSparseArrays/test/test_basics.jl b/NDTensors/src/lib/BlockSparseArrays/test/test_basics.jl index 10f8d6e35d..a7797766d4 100644 --- a/NDTensors/src/lib/BlockSparseArrays/test/test_basics.jl +++ b/NDTensors/src/lib/BlockSparseArrays/test/test_basics.jl @@ -597,21 +597,31 @@ include("TestBlockSparseArraysUtils.jl") c = @view b[4:8, 4:8] @test c isa SubArray{<:Any,<:Any,<:BlockSparseArray} @test size(c) == (5, 5) - @test block_nstored(c) == 2 + # TODO: Fix in Julia 1.11 (https://github.com/ITensor/ITensors.jl/pull/1539). + @test block_nstored(c) == 2 broken = VERSION > v"1.11-" @test blocksize(c) == (2, 2) @test blocklengths.(axes(c)) == ([2, 3], [2, 3]) - @test size(c[Block(1, 1)]) == (2, 2) - @test c[Block(1, 1)] == a[Block(2, 2)[2:3, 2:3]] - @test size(c[Block(2, 2)]) == (3, 3) - @test c[Block(2, 2)] == a[Block(1, 1)[1:3, 1:3]] - @test size(c[Block(2, 1)]) == (3, 2) - @test iszero(c[Block(2, 1)]) - @test size(c[Block(1, 2)]) == (2, 3) - @test iszero(c[Block(1, 2)]) + # TODO: Fix in Julia 1.11 (https://github.com/ITensor/ITensors.jl/pull/1539). + @test size(c[Block(1, 1)]) == (2, 2) broken = VERSION ≥ v"1.11-" + # TODO: Fix in Julia 1.11 (https://github.com/ITensor/ITensors.jl/pull/1539). + @test c[Block(1, 1)] == a[Block(2, 2)[2:3, 2:3]] broken = VERSION ≥ v"1.11-" + # TODO: Fix in Julia 1.11 (https://github.com/ITensor/ITensors.jl/pull/1539). + @test size(c[Block(2, 2)]) == (3, 3) broken = VERSION ≥ v"1.11-" + # TODO: Fix in Julia 1.11 (https://github.com/ITensor/ITensors.jl/pull/1539). + @test c[Block(2, 2)] == a[Block(1, 1)[1:3, 1:3]] broken = VERSION ≥ v"1.11-" + # TODO: Fix in Julia 1.11 (https://github.com/ITensor/ITensors.jl/pull/1539). + @test size(c[Block(2, 1)]) == (3, 2) broken = VERSION ≥ v"1.11-" + # TODO: Fix in Julia 1.11 (https://github.com/ITensor/ITensors.jl/pull/1539). + @test iszero(c[Block(2, 1)]) broken = VERSION ≥ v"1.11-" + # TODO: Fix in Julia 1.11 (https://github.com/ITensor/ITensors.jl/pull/1539). + @test size(c[Block(1, 2)]) == (2, 3) broken = VERSION ≥ v"1.11-" + # TODO: Fix in Julia 1.11 (https://github.com/ITensor/ITensors.jl/pull/1539). + @test iszero(c[Block(1, 2)]) broken = VERSION ≥ v"1.11-" x = randn(elt, 3, 3) c[Block(2, 2)] = x - @test c[Block(2, 2)] == x + # TODO: Fix in Julia 1.11 (https://github.com/ITensor/ITensors.jl/pull/1539). + @test c[Block(2, 2)] == x broken = VERSION ≥ v"1.11-" @test a[Block(1, 1)[1:3, 1:3]] == x a = BlockSparseArray{elt}([2, 3], [3, 4]) @@ -637,10 +647,13 @@ include("TestBlockSparseArraysUtils.jl") @test copy(b) == a @test blocksize(b) == (2, 2) @test blocklengths.(axes(b)) == ([4, 4], [4, 4]) - @test b[Block(1, 1)] == a[Block.(1:2), Block.(1:2)] - @test b[Block(2, 1)] == a[Block.(3:4), Block.(1:2)] - @test b[Block(1, 2)] == a[Block.(1:2), Block.(3:4)] - @test b[Block(2, 2)] == a[Block.(3:4), Block.(3:4)] + # TODO: Fix in Julia 1.11 (https://github.com/ITensor/ITensors.jl/pull/1539). + if VERSION < v"1.11-" + @test b[Block(1, 1)] == a[Block.(1:2), Block.(1:2)] + @test b[Block(2, 1)] == a[Block.(3:4), Block.(1:2)] + @test b[Block(1, 2)] == a[Block.(1:2), Block.(3:4)] + @test b[Block(2, 2)] == a[Block.(3:4), Block.(3:4)] + end c = @view b[Block(2, 2)] @test blocksize(c) == (1, 1) @test c == a[Block.(3:4), Block.(3:4)] @@ -669,13 +682,17 @@ include("TestBlockSparseArraysUtils.jl") @test copy(b) == a[J, J] @test blocksize(b) == (2, 2) @test blocklengths.(axes(b)) == ([4, 4], [4, 4]) - @test b[Block(1, 1)] == Array(a)[[7, 8, 5, 6], [7, 8, 5, 6]] + # TODO: Fix in Julia 1.11 (https://github.com/ITensor/ITensors.jl/pull/1539). + @test b[Block(1, 1)] == Array(a)[[7, 8, 5, 6], [7, 8, 5, 6]] broken = + VERSION ≥ v"1.11-" c = @views b[Block(1, 1)][2:3, 2:3] @test c == Array(a)[[8, 5], [8, 5]] - @test copy(c) == Array(a)[[8, 5], [8, 5]] + # TODO: Fix in Julia 1.11 (https://github.com/ITensor/ITensors.jl/pull/1539). + @test copy(c) == Array(a)[[8, 5], [8, 5]] broken = VERSION ≥ v"1.11-" c = @view b[Block(1, 1)[2:3, 2:3]] @test c == Array(a)[[8, 5], [8, 5]] - @test copy(c) == Array(a)[[8, 5], [8, 5]] + # TODO: Fix in Julia 1.11 (https://github.com/ITensor/ITensors.jl/pull/1539). + @test copy(c) == Array(a)[[8, 5], [8, 5]] broken = VERSION ≥ v"1.11-" end # TODO: Add more tests of this, it may diff --git a/NDTensors/src/lib/LabelledNumbers/src/labelledunitrange.jl b/NDTensors/src/lib/LabelledNumbers/src/labelledunitrange.jl index 2e4379daba..a82c666987 100644 --- a/NDTensors/src/lib/LabelledNumbers/src/labelledunitrange.jl +++ b/NDTensors/src/lib/LabelledNumbers/src/labelledunitrange.jl @@ -37,6 +37,17 @@ end labelled_getindex(a, index) = labelled(unlabel(a)[index], label(a)) +# This is required in Julia 1.11 and above since +# the generic `axes(a::AbstractRange)` definition was removed +# and replace with a generic `axes(a)` definition that +# is written in terms of `Base.unchecked_oneto`, i.e.: +# ```julia +# map(Base.unchecked_oneto, size(A)) +# ``` +# which returns a `Base.OneTo` instead of a `LabelledUnitRange`. +Base.axes(a::LabelledUnitRange) = Base.oneto.(size(a)) + +# TODO: Delete this definition, this should output a `Base.OneTo`. Base.OneTo(stop::LabelledInteger) = labelled(Base.OneTo(unlabel(stop)), label(stop)) # Fix ambiguity error with `AbstractRange` definition in `Base`. diff --git a/NDTensors/test/Project.toml b/NDTensors/test/Project.toml index 5244d98895..15787f7fbb 100644 --- a/NDTensors/test/Project.toml +++ b/NDTensors/test/Project.toml @@ -18,7 +18,6 @@ Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c" SafeTestsets = "1bc83da4-3b8d-516f-aca4-4fe02f6d838f" SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf" StridedViews = "4db3bf67-4bd7-4b4e-b153-31dc3fb37143" -TBLIS = "48530278-0828-4a49-9772-0f3830dfa1e9" TensorOperations = "6aa20fa7-93e2-5fca-9bc0-fbd0db3c71a2" Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" Zygote = "e88e6eb3-aa80-5325-afca-941959d7151f" @@ -30,5 +29,6 @@ Metal = "1.1.0" [extras] AMDGPU = "21141c5a-9bdb-4563-92ae-f87d6854732e" CUDA = "052768ef-5323-5732-b1bb-66c8b64840ba" -Metal = "dde4c033-4e86-420c-a63e-0dd931031962" cuTENSOR = "011b41b2-24ef-40a8-b3eb-fa098493e9e1" +Metal = "dde4c033-4e86-420c-a63e-0dd931031962" +TBLIS = "48530278-0828-4a49-9772-0f3830dfa1e9" diff --git a/Project.toml b/Project.toml index 0e9b91a39e..4feba3d861 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.6.19" +version = "0.6.20" [deps] Adapt = "79e6a3ab-5dfb-504d-930d-738a2a938a0e" @@ -73,7 +73,7 @@ TupleTools = "1.2" VectorInterface = "0.4" Zeros = "0.3.0" ZygoteRules = "0.2.2" -julia = "1.6" +julia = "1.10" [extras] ChainRulesCore = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4" diff --git a/jenkins/Dockerfile b/jenkins/Dockerfile index c677086f2f..e2367a8c01 100644 --- a/jenkins/Dockerfile +++ b/jenkins/Dockerfile @@ -13,4 +13,4 @@ RUN apt-get update && \ ARG JULIA=1.6 RUN curl -s -L https://julialang-s3.julialang.org/bin/linux/x64/${JULIA}/julia-${JULIA}-latest-linux-x86_64.tar.gz | \ - tar -C /usr/local -x -z --strip-components=1 -f - + tar -C /usr/local -x -z --strip-components=1 -f - \ No newline at end of file diff --git a/jenkins/Jenkinsfile b/jenkins/Jenkinsfile index 5ac7f6a62b..4fd308d59a 100644 --- a/jenkins/Jenkinsfile +++ b/jenkins/Jenkinsfile @@ -7,7 +7,7 @@ pipeline { stages { stage('GPU Testing') { parallel { - stage('NDTensorsCUDAExt julia-1.10') { + stage('NDTensorsCUDAExt julia-lts') { options { timeout(time: 45, unit: 'MINUTES') } @@ -31,7 +31,31 @@ pipeline { ''' } } - stage('NDTensorscuTENSORExt julia-1.10') { + stage('NDTensorsCUDAExt julia-1') { + options { + timeout(time: 45, unit: 'MINUTES') + } + agent { + dockerfile { + label 'gpu&&v100' + filename 'Dockerfile' + dir 'jenkins' + additionalBuildArgs '--build-arg JULIA=1.11' + args '--gpus "device=1"' + } + } + environment { + HOME = pwd(tmp:true) + OMP_NUM_THREADS = 4 + JULIA_NUM_THREADS = 4 + } + steps { + sh ''' + julia -e 'using Pkg; Pkg.activate(temp=true); Pkg.Registry.update(); Pkg.update(); Pkg.develop(path="./NDTensors"); Pkg.develop(path="."); Pkg.test("NDTensors"; test_args=["cuda"])' + ''' + } + } + stage('NDTensorscuTENSORExt julia-lts') { options { timeout(time: 45, unit: 'MINUTES') } @@ -55,7 +79,52 @@ pipeline { ''' } } - stage('NDTensorsMetalExt Julia-1.10'){ + stage('NDTensorscuTENSORExt julia-1') { + options { + timeout(time: 45, unit: 'MINUTES') + } + agent { + dockerfile { + label 'gpu&&v100' + filename 'Dockerfile' + dir 'jenkins' + additionalBuildArgs '--build-arg JULIA=1.11' + args '--gpus "device=1"' + } + } + environment { + HOME = pwd(tmp:true) + OMP_NUM_THREADS = 4 + JULIA_NUM_THREADS = 4 + } + steps { + sh ''' + julia -e 'using Pkg; Pkg.activate(temp=true); Pkg.Registry.update(); Pkg.update(); Pkg.develop(path="./NDTensors"); Pkg.develop(path="."); Pkg.test("NDTensors"; test_args=["cutensor"])' + ''' + } + } + stage('NDTensorsMetalExt Julia-lts'){ + options { + timeout(time: 45, unit: 'MINUTES') + } + agent { + label 'm1' + } + environment{ + PATH="${env.HOME}/.juliaup/bin:${env.PATH}" + PLATFORM = 'macos' + } + steps{ + sh ''' + juliaup add lts + juliaup default lts + ''' + sh ''' + julia -e 'using Pkg; Pkg.activate(temp=true); Pkg.develop(path="./NDTensors"); Pkg.develop(path="."); Pkg.test("NDTensors"; test_args=["metal"])' + ''' + } + } + stage('NDTensorsMetalExt Julia-1'){ options { timeout(time: 45, unit: 'MINUTES') } @@ -69,6 +138,7 @@ pipeline { steps{ sh ''' juliaup update + juliaup default release ''' sh ''' julia -e 'using Pkg; Pkg.activate(temp=true); Pkg.develop(path="./NDTensors"); Pkg.develop(path="."); Pkg.test("NDTensors"; test_args=["metal"])' @@ -78,4 +148,4 @@ pipeline { } } } -} +} \ No newline at end of file diff --git a/src/lib/ITensorMPS/test/Project.toml b/src/lib/ITensorMPS/test/Project.toml index 127ce9e065..7345ba4285 100644 --- a/src/lib/ITensorMPS/test/Project.toml +++ b/src/lib/ITensorMPS/test/Project.toml @@ -6,5 +6,6 @@ ITensors = "9136182c-28ba-11e9-034c-db9fb085ebd5" JLD2 = "033835bb-8acc-5ee8-8aae-3f567f8a3819" NDTensors = "23ae76d9-e61a-49c4-8f12-3f1a16adf9cf" OptimKit = "77e91f04-9b3b-57a6-a776-40b61faaebe0" +StableRNGs = "860ef19b-820b-49d6-a774-d7a799459cd3" Suppressor = "fd094767-a336-5f1f-9728-57cf17d0bbfb" Zygote = "e88e6eb3-aa80-5325-afca-941959d7151f" diff --git a/src/lib/ITensorMPS/test/base/Project.toml b/src/lib/ITensorMPS/test/base/Project.toml index 895d21daab..0522110b73 100644 --- a/src/lib/ITensorMPS/test/base/Project.toml +++ b/src/lib/ITensorMPS/test/base/Project.toml @@ -4,4 +4,5 @@ HDF5 = "f67ccb44-e63f-5c2f-98bd-6dc0ccc4ba2f" ITensors = "9136182c-28ba-11e9-034c-db9fb085ebd5" JLD2 = "033835bb-8acc-5ee8-8aae-3f567f8a3819" NDTensors = "23ae76d9-e61a-49c4-8f12-3f1a16adf9cf" +StableRNGs = "860ef19b-820b-49d6-a774-d7a799459cd3" Suppressor = "fd094767-a336-5f1f-9728-57cf17d0bbfb" diff --git a/src/lib/ITensorMPS/test/base/test_mpo.jl b/src/lib/ITensorMPS/test/base/test_mpo.jl index 32746a752b..929eaa2d7b 100644 --- a/src/lib/ITensorMPS/test/base/test_mpo.jl +++ b/src/lib/ITensorMPS/test/base/test_mpo.jl @@ -2,6 +2,7 @@ using Combinatorics using ITensors using NDTensors: scalartype +using StableRNGs: StableRNG using Test include(joinpath(@__DIR__, "utils", "util.jl")) @@ -812,11 +813,11 @@ end N = 6 sites = [Index(2, "Site,n=$n") for n in 1:N] seed = 623 - mt = MersenneTwister(seed) - K = random_mps(mt, sites) + rng = StableRNG(seed) + K = random_mps(rng, sites) L = MPO(K) - result = sample(mt, L) - @test result ≈ [1, 2, 1, 1, 2, 2] + result = sample(rng, L) + @test result ≈ [1, 1, 2, 1, 1, 1] end @testset "MPO+MPO sum (directsum)" begin diff --git a/test/Project.toml b/test/Project.toml index 34fe930acb..48b6cfc79e 100644 --- a/test/Project.toml +++ b/test/Project.toml @@ -15,6 +15,7 @@ OptimKit = "77e91f04-9b3b-57a6-a776-40b61faaebe0" Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f" QuadGK = "1fd47b50-473d-5c70-9696-f719f8f3bcdc" Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c" +StableRNGs = "860ef19b-820b-49d6-a774-d7a799459cd3" Suppressor = "fd094767-a336-5f1f-9728-57cf17d0bbfb" Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" VectorInterface = "409d34a3-91d5-4945-b6ec-7529ddf182d8"