From 8ecea12f67939fb35f04578bc82b566d5a06eb9e Mon Sep 17 00:00:00 2001 From: Qingyu Qu <2283984853@qq.com> Date: Thu, 24 Apr 2025 17:40:02 +0800 Subject: [PATCH] Revive GPU tests --- .buildkite/pipeline.yml | 28 ++++++++++++++++++++++++ test/CUDA/Project.toml | 8 +++++++ test/{ => CUDA}/cuda.jl | 48 ++++++++++++++++++++--------------------- test/Project.toml | 1 - test/runtests.jl | 8 +------ 5 files changed, 60 insertions(+), 33 deletions(-) create mode 100644 .buildkite/pipeline.yml create mode 100644 test/CUDA/Project.toml rename test/{ => CUDA}/cuda.jl (50%) diff --git a/.buildkite/pipeline.yml b/.buildkite/pipeline.yml new file mode 100644 index 00000000..6c94ccd4 --- /dev/null +++ b/.buildkite/pipeline.yml @@ -0,0 +1,28 @@ +env: + # SECRET_CODECOV_TOKEN can be added here if needed for coverage reporting + +steps: + - label: "Julia v{{matrix.version}}, {{matrix.label}}" + plugins: + - JuliaCI/julia#v1: + version: "{{matrix.version}}" + # - JuliaCI/julia-coverage#v1: + # dirs: + # - src + # - ext + command: julia --eval='println(pwd()); println(readdir()); include("test/CUDA/cuda.jl")' + agents: + queue: "juliagpu" + cuda: "*" + if: build.message !~ /\[skip tests\]/ + timeout_in_minutes: 60 + env: + LABEL: "{{matrix.label}}" + TEST_TYPE: ext + matrix: + setup: + version: + - "1" + - "1.10" + label: + - "cuda" \ No newline at end of file diff --git a/test/CUDA/Project.toml b/test/CUDA/Project.toml new file mode 100644 index 00000000..09d0835a --- /dev/null +++ b/test/CUDA/Project.toml @@ -0,0 +1,8 @@ +[deps] +Bijectors = "76274a88-744f-5084-9051-94815aaf08c4" +CUDA = "052768ef-5323-5732-b1bb-66c8b64840ba" +Distributions = "31c24e10-a181-5473-b8eb-7969acd0382f" +ForwardDiff = "f6369f11-7733-5829-9624-2563aa707210" +LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" +LogDensityProblems = "6fdf6af0-433a-55f7-b3ed-c6c6e0b8df7c" +Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" \ No newline at end of file diff --git a/test/cuda.jl b/test/CUDA/cuda.jl similarity index 50% rename from test/cuda.jl rename to test/CUDA/cuda.jl index 39c02f92..4e376d47 100644 --- a/test/cuda.jl +++ b/test/CUDA/cuda.jl @@ -1,4 +1,10 @@ -using ReTest +using Pkg +Pkg.activate(@__DIR__) +Pkg.develop(; path=joinpath(@__DIR__, "..", "..")) + +include(joinpath(@__DIR__, "..", "common.jl")) + +using Test using AdvancedHMC using AdvancedHMC: DualValue, PhasePoint using CUDA @@ -22,31 +28,24 @@ using CUDA samples, stats = sample(hamiltonian, proposal, θ₀, n_samples) end -#= -Broken! See https://github.com/JuliaTesting/ReTest.jl/issues/50 @testset "PhasePoint GPU" begin for T in [Float32, Float64] - init_z1() = PhasePoint( - CuArray([T(NaN) T(NaN)]), - CuArray([T(NaN) T(NaN)]), - DualValue(CuArray(zeros(T, 2)), CuArray(zeros(T, 1, 2))), - DualValue(CuArray(zeros(T, 2)), CuArray(zeros(T, 1, 2))), - ) - init_z2() = PhasePoint( - CuArray([T(Inf) T(Inf)]), - CuArray([T(Inf) T(Inf)]), - DualValue(CuArray(zeros(T, 2)), CuArray(zeros(T, 1, 2))), - DualValue(CuArray(zeros(T, 2)), CuArray(zeros(T, 1, 2))), - ) - - @test_logs ( - :warn, - "The current proposal will be rejected due to numerical error(s).", - ) init_z1() - @test_logs ( - :warn, - "The current proposal will be rejected due to numerical error(s).", - ) init_z2() + function init_z1() + return PhasePoint( + CuArray([T(NaN) T(NaN)]), + CuArray([T(NaN) T(NaN)]), + DualValue(CuArray(zeros(T, 2)), CuArray(zeros(T, 1, 2))), + DualValue(CuArray(zeros(T, 2)), CuArray(zeros(T, 1, 2))), + ) + end + function init_z2() + return PhasePoint( + CuArray([T(Inf) T(Inf)]), + CuArray([T(Inf) T(Inf)]), + DualValue(CuArray(zeros(T, 2)), CuArray(zeros(T, 1, 2))), + DualValue(CuArray(zeros(T, 2)), CuArray(zeros(T, 1, 2))), + ) + end z1 = init_z1() z2 = init_z2() @@ -55,4 +54,3 @@ Broken! See https://github.com/JuliaTesting/ReTest.jl/issues/50 @test z1.ℓκ.value == z2.ℓκ.value end end -=# diff --git a/test/Project.toml b/test/Project.toml index 9d7ee347..e09013ca 100644 --- a/test/Project.toml +++ b/test/Project.toml @@ -3,7 +3,6 @@ ADTypes = "47edcb42-4c32-4615-8424-f2b9edc5f35b" AbstractMCMC = "80f14c24-f653-4e6a-9b94-39d6b0f70001" Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595" Bijectors = "76274a88-744f-5084-9051-94815aaf08c4" -CUDA = "052768ef-5323-5732-b1bb-66c8b64840ba" Comonicon = "863f3e99-da2a-4334-8734-de3dacbe5542" ComponentArrays = "b0b7db55-cfe3-40fc-9ded-d10e2dbeff66" Distributions = "31c24e10-a181-5473-b8eb-7969acd0382f" diff --git a/test/runtests.jl b/test/runtests.jl index 8e44d366..ce21ac35 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -17,7 +17,7 @@ const GROUP = get(ENV, "AHMC_TEST_GROUP", "AdvancedHMC") include("common.jl") if GROUP == "All" || GROUP == "AdvancedHMC" - using ReTest, CUDA + using ReTest include("aqua.jl") include("metric.jl") @@ -33,12 +33,6 @@ if GROUP == "All" || GROUP == "AdvancedHMC" include("mcmcchains.jl") include("constructors.jl") - if CUDA.functional() - include("cuda.jl") - else - @warn "Skipping GPU tests because no GPU available." - end - Comonicon.@main function runtests(patterns...; dry::Bool=false) return retest(patterns...; dry=dry, verbose=Inf) end