Skip to content

Revive GPU tests #430

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 25, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions .buildkite/pipeline.yml
Original file line number Diff line number Diff line change
@@ -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"
8 changes: 8 additions & 0 deletions test/CUDA/Project.toml
Original file line number Diff line number Diff line change
@@ -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"
48 changes: 23 additions & 25 deletions test/cuda.jl → test/CUDA/cuda.jl
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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()
Expand All @@ -55,4 +54,3 @@ Broken! See https://github.com/JuliaTesting/ReTest.jl/issues/50
@test z1.ℓκ.value == z2.ℓκ.value
end
end
=#
1 change: 0 additions & 1 deletion test/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
8 changes: 1 addition & 7 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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
Expand Down
Loading