From 9f371f8bf69bcf1312d168619d8fd36d1ab5ae0d Mon Sep 17 00:00:00 2001 From: Carlo Lucibello Date: Sat, 9 Sep 2023 15:25:25 +0200 Subject: [PATCH 1/2] cl/test --- .buildkite/pipeline.yml | 9 +- Project.toml | 20 ++++ test/Project.toml | 20 ---- test/runtests.jl | 196 +++++++++++++++++----------------------- 4 files changed, 109 insertions(+), 136 deletions(-) delete mode 100644 test/Project.toml diff --git a/.buildkite/pipeline.yml b/.buildkite/pipeline.yml index 66ab56e2a..59de97f0a 100644 --- a/.buildkite/pipeline.yml +++ b/.buildkite/pipeline.yml @@ -14,9 +14,10 @@ steps: queue: "juliagpu" cuda: "*" env: - NNLIB_TEST_CUDA: true + NNLIB_TEST_CUDA: "true" + NNLIB_TEST_CPU: "false" if: build.message !~ /\[skip tests\]/ - timeout_in_minutes: 60 + timeout_in_minutes: 180 matrix: setup: julia: @@ -47,10 +48,10 @@ steps: JULIA_AMDGPU_CORE_MUST_LOAD: "1" JULIA_AMDGPU_HIP_MUST_LOAD: "1" JULIA_AMDGPU_DISABLE_ARTIFACTS: "1" - NNLIB_TEST_AMDGPU: true + NNLIB_TEST_AMDGPU: "true" + NNLIB_TEST_CPU: "false" JULIA_NUM_THREADS: 4 - - label: "Benchmarks" plugins: - JuliaCI/julia#v1: diff --git a/Project.toml b/Project.toml index 0b624bbe0..5c72488c2 100644 --- a/Project.toml +++ b/Project.toml @@ -35,3 +35,23 @@ GPUArraysCore = "0.1" KernelAbstractions = "0.9.2" Requires = "1.0" julia = "1.9" + +[extras] +AMDGPU = "21141c5a-9bdb-4563-92ae-f87d6854732e" +CUDA = "052768ef-5323-5732-b1bb-66c8b64840ba" +ChainRulesTestUtils = "cdddcdb0-9152-4a09-a978-84456f9df70a" +Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4" +FiniteDifferences = "26cc04aa-876d-5657-8c51-4c34ba976000" +ForwardDiff = "f6369f11-7733-5829-9624-2563aa707210" +Logging = "56ddb016-857b-54e1-b83d-db4d58db5568" +ReverseDiff = "37e2e3b7-166d-5795-8a7a-e32c996b4267" +StableRNGs = "860ef19b-820b-49d6-a774-d7a799459cd3" +Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" +UnicodePlots = "b8865327-cd53-5732-bb35-84acbb429228" +Zygote = "e88e6eb3-aa80-5325-afca-941959d7151f" +cuDNN = "02a925ec-e4fe-4b08-9a7e-0d78e3d38ccd" + +[targets] +test = ["AMDGPU", "CUDA", "ChainRulesTestUtils", "Documenter", + "FiniteDifferences", "ForwardDiff", "Logging", "ReverseDiff", + "StableRNGs", "Test", "UnicodePlots", "Zygote", "cuDNN"] diff --git a/test/Project.toml b/test/Project.toml deleted file mode 100644 index 46c468f9b..000000000 --- a/test/Project.toml +++ /dev/null @@ -1,20 +0,0 @@ -[deps] -Adapt = "79e6a3ab-5dfb-504d-930d-738a2a938a0e" -CUDA = "052768ef-5323-5732-b1bb-66c8b64840ba" -ChainRulesCore = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4" -ChainRulesTestUtils = "cdddcdb0-9152-4a09-a978-84456f9df70a" -Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4" -FiniteDifferences = "26cc04aa-876d-5657-8c51-4c34ba976000" -ForwardDiff = "f6369f11-7733-5829-9624-2563aa707210" -KernelAbstractions = "63c18a36-062a-441e-b654-da1e3ab1ce7c" -LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" -Logging = "56ddb016-857b-54e1-b83d-db4d58db5568" -Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f" -Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c" -ReverseDiff = "37e2e3b7-166d-5795-8a7a-e32c996b4267" -StableRNGs = "860ef19b-820b-49d6-a774-d7a799459cd3" -Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2" -Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" -UnicodePlots = "b8865327-cd53-5732-bb35-84acbb429228" -Zygote = "e88e6eb3-aa80-5325-afca-941959d7151f" -cuDNN = "02a925ec-e4fe-4b08-9a7e-0d78e3d38ccd" \ No newline at end of file diff --git a/test/runtests.jl b/test/runtests.jl index ece02b0ed..03602a40d 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -13,8 +13,9 @@ import ReverseDiff as RD # used in `pooling.jl` DocMeta.setdocmeta!(NNlib, :DocTestSetup, :(using NNlib, UnicodePlots); recursive=true) -ENV["NNLIB_TEST_CUDA"] = true # uncomment to run CUDA tests -# ENV["NNLIB_TEST_AMDGPU"] = true # uncomment to run AMDGPU tests +# ENV["NNLIB_TEST_CUDA"] = "true" # uncomment to run CUDA tests +# ENV["NNLIB_TEST_AMDGPU"] = "true" # uncomment to run AMDGPU tests +# ENV["NNLIB_TEST_CPU"] = "false" # uncomment to skip CPU tests const rng = StableRNG(123) include("test_utils.jl") @@ -49,138 +50,109 @@ function nnlib_testsuite(Backend; skip_tests = Set{String}()) end end -@testset "NNlib.jl" verbose=true begin - @testset verbose=true "Test Suite" begin - @testset "CPU" begin - nnlib_testsuite(CPU) - end +@testset verbose=true "NNlib.jl" begin - if get(ENV, "NNLIB_TEST_CUDA", "false") == "true" - using CUDA - if CUDA.functional() - @testset "CUDABackend" begin - nnlib_testsuite(CUDABackend; skip_tests=Set(("Scatter", "Gather"))) - end - else - @info "CUDA.jl is not functional. Skipping test suite for CUDABackend." + if get(ENV, "NNLIB_TEST_CPU", "true") == "true" + @testset "CPU" begin + @testset "Doctests" begin + doctest(NNlib, manual=false) end - else - @info "Skipping CUDA tests, set NNLIB_TEST_CUDA=true to run them." - end - if get(ENV, "NNLIB_TEST_AMDGPU", "false") == "true" - import Pkg - test_info = Pkg.project() - Pkg.develop("AMDGPU") - - using AMDGPU - if AMDGPU.functional() - @testset "ROCBackend" begin - nnlib_testsuite(ROCBackend) - AMDGPU.synchronize(; blocking=false) - end - else - @info "AMDGPU.jl is not functional. Skipping test suite for ROCBackend." - end - else - @info "Skipping AMDGPU tests, set NNLIB_TEST_AMDGPU=true to run them." - end - end + nnlib_testsuite(CPU) - @testset verbose=true "Tests" begin - if get(ENV, "NNLIB_TEST_CUDA", "false") == "true" - using CUDA - if CUDA.functional() - @testset "CUDA" begin - include("ext_cuda/runtests.jl") - end - else - @info "Insufficient version or CUDA not found; Skipping CUDA tests" + @testset "Activation Functions" begin + include("activations.jl") + include("bias_act.jl") end - else - @info "Skipping CUDA tests, set NNLIB_TEST_CUDA=true to run them" - end - if get(ENV, "NNLIB_TEST_AMDGPU", "false") == "true" - import Pkg - test_info = Pkg.project() - Pkg.develop("AMDGPU") - - using AMDGPU - AMDGPU.versioninfo() - if AMDGPU.functional() && AMDGPU.functional(:MIOpen) - @show AMDGPU.MIOpen.version() - @testset "AMDGPU" begin - include("ext_amdgpu/runtests.jl") - AMDGPU.synchronize(; blocking=false) - end - else - @info "AMDGPU.jl package is not functional. Skipping AMDGPU tests." + @testset "Attention" begin + include("attention.jl") end - else - @info "Skipping AMDGPU tests, set NNLIB_TEST_AMDGPU=true to run them." - end - - @testset "Doctests" begin - doctest(NNlib, manual=false) - end - @testset "Activation Functions" begin - include("activations.jl") - include("bias_act.jl") - end + @testset "Batched Multiplication" begin + include("batchedmul.jl") + end - @testset "Attention" begin - include("attention.jl") - end + @testset "Convolution" begin + include("conv.jl") + include("conv_bias_act.jl") + end - @testset "Batched Multiplication" begin - include("batchedmul.jl") - end + @testset "CTC Loss" begin + include("ctc.jl") + end - @testset "Convolution" begin - include("conv.jl") - include("conv_bias_act.jl") - end + @testset "Dropout" begin + include("dropout.jl") + end - @testset "CTC Loss" begin - include("ctc.jl") - end + @testset "Fold/Unfold" begin + include("fold.jl") + end - @testset "Dropout" begin - include("dropout.jl") - end + @testset "Inference" begin + include("inference.jl") + end - @testset "Fold/Unfold" begin - include("fold.jl") - end + @testset "Pooling" begin + include("pooling.jl") + end - @testset "Inference" begin - include("inference.jl") - end + @testset "Padding" begin + include("padding.jl") + end - @testset "Pooling" begin - include("pooling.jl") - end + @testset "Softmax" begin + include("softmax.jl") + end - @testset "Padding" begin - include("padding.jl") - end + @testset "Utilities" begin + include("utils.jl") + end - @testset "Softmax" begin - include("softmax.jl") - end + @testset "Grid Sampling" begin + include("sampling.jl") + end - @testset "Utilities" begin - include("utils.jl") + @testset "Functions" begin + include("functions.jl") + end end + else + @info "Skipping CPU tests, set NNLIB_TEST_CPU=true to run them." + end - @testset "Grid Sampling" begin - include("sampling.jl") - end + if get(ENV, "NNLIB_TEST_CUDA", "false") == "true" + using CUDA + if CUDA.functional() + @testset "CUDA" begin + nnlib_testsuite(CUDABackend; skip_tests=Set(("Scatter", "Gather"))) - @testset "Functions" begin - include("functions.jl") + include("ext_cuda/runtests.jl") + end + else + @info "Insufficient version or CUDA not found; Skipping CUDA tests" + end + else + @info "Skipping CUDA tests, set NNLIB_TEST_CUDA=true to run them" + end + + if get(ENV, "NNLIB_TEST_AMDGPU", "false") == "true" + using AMDGPU + AMDGPU.versioninfo() + if AMDGPU.functional() && AMDGPU.functional(:MIOpen) + @show AMDGPU.MIOpen.version() + @testset "AMDGPU" begin + nnlib_testsuite(ROCBackend) + AMDGPU.synchronize(; blocking=false) + + include("ext_amdgpu/runtests.jl") + AMDGPU.synchronize(; blocking=false) + end + else + @info "AMDGPU.jl package is not functional. Skipping AMDGPU tests." end + else + @info "Skipping AMDGPU tests, set NNLIB_TEST_AMDGPU=true to run them." end end From 3cbb5a608dd220d2e420f21f342768a5f22e235a Mon Sep 17 00:00:00 2001 From: Carlo Lucibello Date: Sat, 9 Sep 2023 18:30:36 +0200 Subject: [PATCH 2/2] reinstate cpu tests on CUDA worker --- .buildkite/pipeline.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.buildkite/pipeline.yml b/.buildkite/pipeline.yml index 59de97f0a..7e39a9e16 100644 --- a/.buildkite/pipeline.yml +++ b/.buildkite/pipeline.yml @@ -49,7 +49,8 @@ steps: JULIA_AMDGPU_HIP_MUST_LOAD: "1" JULIA_AMDGPU_DISABLE_ARTIFACTS: "1" NNLIB_TEST_AMDGPU: "true" - NNLIB_TEST_CPU: "false" + NNLIB_TEST_CPU: "true" # Could be useful to uncover multithreading related issues + # Buildkite workers have more threads. JULIA_NUM_THREADS: 4 - label: "Benchmarks"